|
| 1 | +--- |
| 2 | +type: concept |
| 3 | +tags: [architecture, electron, obs-plugin, structure] |
| 4 | +updated: 2026-04-08 |
| 5 | +sources: 1 |
| 6 | +--- |
| 7 | + |
| 8 | +# Codebase Overview |
| 9 | + |
| 10 | +OpenClip is composed of two independently-built applications that communicate at runtime: an Electron desktop app and a native OBS Studio plugin. The Electron app drives the UI and business logic; the OBS plugin runs inside OBS to expose recording controls and scene management via HTTP. |
| 11 | + |
| 12 | +## Key Points |
| 13 | + |
| 14 | +- **Two-app architecture:** `electron-app/` (Electron + React + Node.js) and `obs-plugin/` (C plugin for OBS Studio). They are built and packaged separately but ship together in the NSIS installer. |
| 15 | +- **Communication:** The Electron app reaches the OBS plugin through a local HTTP transport (`pluginHttpTransport.js`). It also communicates with OBS directly over WebSocket for some operations. |
| 16 | +- **800-line file limit:** The project enforces a soft rule that no source file should exceed 800 lines. Files approaching this limit are candidates for extraction. |
| 17 | +- **Backend modules** live in `electron-app/electron/`. Key ones: |
| 18 | + - `fileManager.js` — file organization, week-folder logic, move operations (950 lines — over limit) |
| 19 | + - `recordingService.js` — recording lifecycle, clip numbering, date-based counting (932 lines — over limit) |
| 20 | + - `gameWatcher.js` — process detection loop, hotkey registration, OBS start/stop triggers (424 lines) |
| 21 | + - `apiServer.js` — Express HTTP server exposing the local REST API consumed by the frontend viewer (574 lines) |
| 22 | + - `ipcHandlers.js` + `ipcHandlers/` subdirectory — IPC dispatch; refactored into per-domain handler files (`gameHandlers.js`, `obsHandlers.js`, `recordingHandlers.js`, `shareHandlers.js`, `watcherHandlers.js`, `windowHandlers.js`) |
| 23 | + - `obsPlugin.js` — manages the OBS plugin installation and detection |
| 24 | + - `obsIntegration.js` — high-level OBS control bridge |
| 25 | + - `obsEncoding.js` — re-encoding pipeline (H.264/H.265/AV1) |
| 26 | + - `store.js` — electron-store config wrapper |
| 27 | + - `winUtils.js` — Windows-specific utilities (655 lines) |
| 28 | + - `waveformCache.js`, `waveformPreCache.js`, `waveformUtils.js` — audio waveform generation and caching |
| 29 | + - `fileOperations.js` — lower-level file operation helpers (split from fileManager) |
| 30 | + - `migrations.js` — store schema migrations |
| 31 | + - `pluginHttpTransport.js` — HTTP client for talking to the OBS plugin |
| 32 | +- **Frontend** lives in `electron-app/src/`. Key entry points: |
| 33 | + - `App.jsx` — root layout (vertical sidebar nav + main content area) |
| 34 | + - `pages/GamesPage.jsx` — game management UI (677 lines, near limit) |
| 35 | + - `pages/SettingsPage.jsx` — app settings |
| 36 | + - `viewer/` — the media viewer (Recordings, Clips, Storage pages) |
| 37 | + - `viewer/components/VideoPlayer.jsx` — video player with trim timeline (1207 lines — significantly over limit) |
| 38 | +- **OBS plugin source** lives in `obs-plugin/src/`. Written in C. Key files: `http-server.c`, `scene-handlers.c`, `audio-handlers.c`. See `obs-plugin/README.md` for the full plugin API reference. |
| 39 | +- **Tests** live in `electron-app/tests/`. Unit tests use Jest/Vitest; E2E tests use Playwright. Run the full suite with `npm run test` from `electron-app/` — do NOT use `npx vitest run` directly as it skips the Playwright E2E tests. |
| 40 | +- **Testing stubs** (`*-testing.js` files in `electron-app/electron/`) are Jest module mapping stubs required for tests; they are not imported by production code. |
| 41 | + |
| 42 | +## Files Over the 800-Line Limit (as of 2026-04-08) |
| 43 | + |
| 44 | +| File | Lines | |
| 45 | +|------|------:| |
| 46 | +| `electron/fileManager.js` | 950 | |
| 47 | +| `electron/recordingService.js` | 932 | |
| 48 | +| `src/viewer/components/VideoPlayer.jsx` | 1207 | |
| 49 | + |
| 50 | +## Related |
| 51 | + |
| 52 | +- [[ipc-patterns]] |
| 53 | +- [[fileManager]] |
| 54 | +- [[gameWatcher]] |
0 commit comments