Top-Level Structure
Electron App Workspace (apps/x)
The Electron app is a nested pnpm workspace with its own package management and build system.
Directory Layout
Workspace Configuration
The pnpm workspace is configured inapps/x/pnpm-workspace.yaml:
The
onlyBuiltDependencies field ensures that only these packages are built during installation, improving build performance.Package Descriptions
Internal Packages
@x/shared
Contains shared types, utilities, and validators used across all workspace packages.- Dependencies: Zod for schema validation
- Purpose: Type definitions, common utilities
- Build: TypeScript compilation only
@x/core
Contains core business logic and integrations:- AI provider integrations (Vercel AI SDK, Anthropic, OpenAI, Google)
- OAuth and authentication
- Model Context Protocol (MCP) implementation
- Document parsing (PDF, CSV, XLSX, DOCX)
- Git operations
Application Packages
apps/main
The Electron main process:- Entry:
apps/main/src/main.ts - Output:
.package/dist/main.cjs(bundled with esbuild) - Depends on:
@x/shared,@x/core
apps/renderer
The React UI:- Entry:
apps/renderer/src/main.tsx - Output:
apps/renderer/dist/(bundled with Vite) - Depends on:
@x/shared - Hot-reloads in development mode
apps/preload
Electron preload scripts for secure IPC:- Entry:
apps/preload/src/preload.ts - Output:
apps/preload/dist/preload.js - Depends on:
@x/shared
Workspace Dependencies
Packages reference each other using pnpm’sworkspace:* protocol:
The
workspace:* protocol tells pnpm to symlink local packages instead of installing from npm. This is why pnpm is required.Build Dependencies
The workspace has a specific build order based on dependencies:npm run deps command in the workspace root builds packages in order:
Key Files Reference
| Purpose | File |
|---|---|
| Electron main entry | apps/x/apps/main/src/main.ts |
| React app entry | apps/x/apps/renderer/src/main.tsx |
| Forge config (packaging) | apps/x/apps/main/forge.config.cjs |
| Main process bundler | apps/x/apps/main/bundle.mjs |
| Vite config | apps/x/apps/renderer/vite.config.ts |
| Shared types | apps/x/packages/shared/src/ |
| Core business logic | apps/x/packages/core/src/ |
| Workspace config | apps/x/pnpm-workspace.yaml |
| Root scripts | apps/x/package.json |