Core Architecture
Flow Browser follows Electron’s standard architecture pattern with these key components:Main Process
Node.js environment managing windows, tabs, sessions, and system integration
Renderer Process
React 19 UI with TailwindCSS 4, handling browser chrome and user interface
IPC Communication
Type-safe communication between main and renderer processes
Preload Scripts
Secure context bridge exposing controlled APIs to renderer
Technology Stack
Main Process
- Runtime: Node.js 22+ (Electron)
- Language: TypeScript
- Database: SQLite via better-sqlite3 + Drizzle ORM
- Build Tool: electron-vite
Renderer Process
- Framework: React 19
- Styling: TailwindCSS 4
- Animations: Motion (Framer Motion)
- Build Tool: Vite 7
- State Management: React hooks + IPC subscriptions
Preload Layer
- Context Bridge: Secure API exposure
- Type Safety: Shared TypeScript interfaces
- Security: Permission-based API access
Process Architecture
Key Directories
src/main/ - Main Process
src/main/ - Main Process
Node.js backend code:
/controllers/- Core business logic (tabs, windows, sessions)/ipc/- IPC message handlers/modules/- Utility modules (extensions, favicons, logging)/saving/- Database persistence layer/app/- Application lifecycle management
src/main/index.ts:1src/renderer/ - Renderer Process
src/renderer/ - Renderer Process
React UI code:
/src/routes/- Page components (main-ui, settings, new-tab)/src/components/- Reusable UI components/src/hooks/- Custom React hooks/src/lib/- Frontend utilities
src/renderer/src/routes/main-ui/page.tsx:1src/preload/ - Preload Scripts
src/preload/ - Preload Scripts
Security bridge:
index.ts- Main preload exposing Flow APIwebauthn/- Passkey/WebAuthn support
src/preload/index.ts:1src/shared/ - Shared Code
src/shared/ - Shared Code
Controller Pattern
Flow Browser uses a controller-based architecture in the main process. Each controller is a singleton managing a specific domain:| Controller | Responsibility | File |
|---|---|---|
tabsController | Tab lifecycle, state, grouping | src/main/controllers/tabs-controller/index.ts:45 |
windowsController | Window creation, focus, state | src/main/controllers/windows-controller/index.ts:22 |
sessionsController | Electron sessions, profiles | src/main/controllers/sessions-controller/index.ts:10 |
spacesController | Workspace/space management | src/main/controllers/spaces-controller/index.ts |
profilesController | User profile data | src/main/controllers/profiles-controller/index.ts |
Controllers are initialized on app startup via
src/main/controllers/index.ts with careful dependency ordering.Data Flow Example
Here’s how creating a new tab flows through the architecture:- User clicks “New Tab” in UI (renderer process)
- React component calls
flow.tabs.newTab(url)via preload API - IPC message sent from renderer to main process
- IPC handler receives message at
src/main/ipc/browser/tabs.ts - Handler calls
tabsController.createTab() - Tab instance created, WebContentsView attached to window
- State persisted to SQLite database
- IPC event emitted back to renderer with updated tab data
- React UI updates via
flow.tabs.onDataUpdated()subscription
Security Model
Permission levels (seesrc/preload/index.ts:58):
all- Available to all pagesapp- Internal app pages only (flow:protocol)browser- Browser UI components onlysession- Session/profile management pagessettings- Settings window only
Extension Support
Flow Browser supports Chrome extensions via:- electron-chrome-extensions - Extension runtime
- electron-chrome-web-store - Web store integration
- Extensions run in profile-specific sessions
- Extension APIs exposed through main process
src/main/modules/extensions/main.ts for implementation.
Database Architecture
Flow uses an embedded SQLite database:- ORM: Drizzle ORM with better-sqlite3
- Schema:
src/main/saving/db/schema.ts - Persistence: Tabs, spaces, profiles, settings
- Flush Strategy: Dirty tabs written every ~2s
Next Steps
Main Process
Deep dive into controllers, lifecycle, and business logic
Renderer Process
Learn about the React UI architecture and component structure
IPC Communication
Understand the type-safe IPC messaging system