# proteus-technologies-private-limited/opendraft architecture

> Architecture diagram of the GitHub repository proteus-technologies-private-limited/opendraft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/proteus-technologies-private-limited/opendraft
- Repository: https://github.com/proteus-technologies-private-limited/opendraft

## Overview

OpenDraft is an offline-first screenplay writing and production-planning app with desktop/mobile clients, optional cloud APIs, and a separate real-time collaboration server. The principal workflow is to create or import a project, write and plan a screenplay, save it locally or through an API, then export or collaborate. The graph preserves the README’s major capabilities and the indexed core modules. Source excerpts are partial, so several feature branches are included without speculative implementation-level links.

Main entry points: [`collab-server/src/server.ts`](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/server.ts) (Collaboration server), [`frontend/src/services/api.ts`](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/api.ts) (API client), [`backend/app/main.py`](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/main.py) (Backend API), [`frontend/src/components/ScreenplayEditor.tsx`](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/ScreenplayEditor.tsx) (Screenplay editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Writing client"]
  node_app["App shell<br/>[App.tsx]"]
  node_editor_state["Editor state<br/>[editorStore.ts]"]
  node_settings["App settings<br/>[settingsStore.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_auth_fetch["Authenticated fetch<br/>[authedFetch.ts]"]
  node_platform["Platform services<br/>[platform.ts]"]
end

subgraph group_local["Local project data"]
  node_local_storage["Local storage<br/>[local-storage.ts]"]
  node_sqlite[("SQLite database<br/>[db.ts]")]
  node_linked_files["Linked-file sync<br/>[linkedFiles.ts]"]
  node_storage_fallback["File fallback"]
  node_linked_format["Linked-file format"]
  node_location_data["Location data"]
  node_review_save["Review-safe saves"]
end

subgraph group_backend["Backend services"]
  node_backend_app["Backend API<br/>[main.py]"]
  node_backend_config["Backend configuration<br/>[config.py]"]
  node_trash["Trash retention<br/>[trash_service.py]"]
end

subgraph group_collab["Live collaboration"]
  node_collab_server["Collaboration server<br/>[server.ts]"]
  node_collab_db[("Collaboration database<br/>[db.ts]")]
  node_collab_config["Collab configuration<br/>[config.ts]"]
  node_review_guard["Suggestion guard<br/>[suggestionGuard.ts]"]
  node_review_protocol["Review protocol<br/>[reviewProtocol.ts]"]
  node_review_storage["Review persistence<br/>[reviewStorage.ts]"]
end

subgraph group_features["Writing features"]
  node_editor["Screenplay editor"]
  node_planning["Story planning<br/>[BeatBoard.tsx]"]
  node_profiles["Character profiles"]
  node_table_read["Table read<br/>[script.ts]"]
  node_format_io["Import and export<br/>[fdxParser.ts]"]
  node_version_ui["Version history<br/>[VersionHistory.tsx]"]
  node_plugins["Plugin runtime<br/>[runtimeLoader.ts]"]
end

node_writer(("Writer"))

node_writer -->|"uses"| node_app
node_app -.->|"presents"| node_editor
node_writer -->|"plans story"| node_planning
node_writer -->|"tracks characters"| node_profiles
node_writer -->|"hears script"| node_table_read
node_writer -->|"imports or exports"| node_format_io
node_writer -->|"reviews drafts"| node_version_ui
node_writer -->|"extends app"| node_plugins
node_editor -.->|"updates state"| node_editor_state
node_editor -.->|"saves locally"| node_local_storage
node_local_storage -->|"queries"| node_sqlite
node_linked_files -->|"uses storage"| node_local_storage
node_linked_files -->|"uses format"| node_linked_format
node_storage_fallback -->|"prepares writes"| node_review_save
node_api_client -->|"sends requests"| node_auth_fetch
node_api_client -->|"sanitizes locations"| node_location_data
node_api_client -->|"requests API"| node_backend_app
node_api_client -->|"requests collab API"| node_collab_server
node_backend_app -->|"loads settings"| node_backend_config
node_backend_app -->|"purges expired"| node_trash
node_backend_app -.->|"validates invites"| node_collab_server
node_collab_server -->|"initializes"| node_collab_db
node_collab_server -->|"loads settings"| node_collab_config
node_collab_server -->|"uses guard"| node_review_guard
node_review_protocol -->|"imports"| node_review_guard
node_review_storage -->|"uses version"| node_review_protocol
node_collab_server -->|"persists review state"| node_review_storage
node_platform -.->|"supports playback"| node_table_read

click node_app "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/App.tsx"
click node_editor "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/ScreenplayEditor.tsx"
click node_planning "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/BeatBoard.tsx"
click node_profiles "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/CharacterProfiles.tsx"
click node_table_read "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/tts/script.ts"
click node_format_io "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/utils/fdxParser.ts"
click node_version_ui "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/VersionHistory.tsx"
click node_plugins "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/plugins/runtimeLoader.ts"
click node_editor_state "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/stores/editorStore.ts"
click node_settings "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/stores/settingsStore.ts"
click node_api_client "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/api.ts"
click node_auth_fetch "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/authedFetch.ts"
click node_platform "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/platform.ts"
click node_local_storage "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/local-storage.ts"
click node_sqlite "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/db.ts"
click node_linked_files "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/linkedFiles.ts"
click node_storage_fallback "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/file-fallback-storage.ts"
click node_backend_app "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/main.py"
click node_backend_config "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/config.py"
click node_trash "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/services/trash_service.py"
click node_collab_server "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/server.ts"
click node_collab_db "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/db.ts"
click node_collab_config "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/config.ts"
click node_review_guard "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/suggestionGuard.ts"
click node_review_protocol "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/reviewProtocol.ts"
click node_review_storage "https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/reviewStorage.ts"
click node_linked_format "https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils"
click node_location_data "https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils"
click node_review_save "https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_editor_state,node_settings,node_api_client,node_auth_fetch,node_platform toneBlue
class node_local_storage,node_sqlite,node_linked_files,node_storage_fallback,node_linked_format,node_location_data,node_review_save toneAmber
class node_backend_app,node_backend_config,node_trash toneMint
class node_collab_server,node_collab_db,node_collab_config,node_review_guard,node_review_protocol,node_review_storage toneRose
class node_editor,node_planning,node_profiles,node_table_read,node_format_io,node_version_ui,node_plugins,node_writer toneIndigo
```

## Components

### Writing client

- [App shell](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Editor state](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/stores/editorStore.ts): `frontend/src/stores/editorStore.ts`
- [App settings](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/stores/settingsStore.ts): `frontend/src/stores/settingsStore.ts`
- [API client](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Authenticated fetch](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/authedFetch.ts): `frontend/src/services/authedFetch.ts`
- [Platform services](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/platform.ts): `frontend/src/services/platform.ts`

### Local project data

- [Local storage](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/local-storage.ts): `frontend/src/services/local-storage.ts`
- [SQLite database](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/db.ts): `frontend/src/services/db.ts`
- [Linked-file sync](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/linkedFiles.ts): `frontend/src/services/linkedFiles.ts`
- [File fallback](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/file-fallback-storage.ts): `frontend/src/services/file-fallback-storage.ts`
- [Linked-file format](https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils): `frontend/src/utils`
- [Location data](https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils): `frontend/src/utils`
- [Review-safe saves](https://github.com/proteus-technologies-private-limited/opendraft/tree/main/frontend/src/utils): `frontend/src/utils`

### Backend services

- [Backend API](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/main.py): `backend/app/main.py`
- [Backend configuration](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/config.py): `backend/app/config.py`
- [Trash retention](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/backend/app/services/trash_service.py): `backend/app/services/trash_service.py`

### Live collaboration

- [Collaboration server](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/server.ts): `collab-server/src/server.ts`
- [Collaboration database](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/db.ts): `collab-server/src/db.ts`
- [Collab configuration](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/config.ts): `collab-server/src/config.ts`
- [Suggestion guard](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/suggestionGuard.ts): `collab-server/src/services/suggestionGuard.ts`
- [Review protocol](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/reviewProtocol.ts): `collab-server/src/services/reviewProtocol.ts`
- [Review persistence](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/collab-server/src/services/reviewStorage.ts): `collab-server/src/services/reviewStorage.ts`

### Writing features

- [Screenplay editor](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/ScreenplayEditor.tsx): `frontend/src/components/ScreenplayEditor.tsx`
- [Story planning](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/BeatBoard.tsx): `frontend/src/components/BeatBoard.tsx`
- [Character profiles](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/CharacterProfiles.tsx): `frontend/src/components/CharacterProfiles.tsx`
- [Table read](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/services/tts/script.ts): `frontend/src/services/tts/script.ts`
- [Import and export](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/utils/fdxParser.ts): `frontend/src/utils/fdxParser.ts`
- [Version history](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/components/VersionHistory.tsx): `frontend/src/components/VersionHistory.tsx`
- [Plugin runtime](https://github.com/proteus-technologies-private-limited/opendraft/blob/main/frontend/src/plugins/runtimeLoader.ts): `frontend/src/plugins/runtimeLoader.ts`

### Other components

- **Writer**

## Connections

- Writer → App shell: uses (evidence: `README.md`)
- App shell → Screenplay editor: presents
- Writer → Story planning: plans story (evidence: `README.md`)
- Writer → Character profiles: tracks characters (evidence: `README.md`)
- Writer → Table read: hears script (evidence: `README.md`)
- Writer → Import and export: imports or exports (evidence: `README.md`)
- Writer → Version history: reviews drafts (evidence: `README.md`)
- Writer → Plugin runtime: extends app (evidence: `README.md`)
- Screenplay editor → Editor state: updates state
- Screenplay editor → Local storage: saves locally
- Local storage → SQLite database: queries (evidence: `frontend/src/services/local-storage.ts`)
- Linked-file sync → Local storage: uses storage (evidence: `frontend/src/services/linkedFiles.ts`)
- Linked-file sync → Linked-file format: uses format (evidence: `frontend/src/services/linkedFiles.ts`)
- File fallback → Review-safe saves: prepares writes (evidence: `frontend/src/services/file-fallback-storage.ts`)
- API client → Authenticated fetch: sends requests (evidence: `frontend/src/services/api.ts`)
- API client → Location data: sanitizes locations (evidence: `frontend/src/services/api.ts`)
- API client → Backend API: requests API (evidence: `frontend/src/services/api.ts`)
- API client → Collaboration server: requests collab API (evidence: `frontend/src/services/api.ts`)
- Backend API → Backend configuration: loads settings (evidence: `backend/app/main.py`)
- Backend API → Trash retention: purges expired (evidence: `backend/app/main.py`)
- Backend API → Collaboration server: validates invites
- Collaboration server → Collaboration database: initializes (evidence: `collab-server/src/server.ts`)
- Collaboration server → Collab configuration: loads settings (evidence: `collab-server/src/server.ts`)
- Collaboration server → Suggestion guard: uses guard (evidence: `collab-server/src/server.ts`)
- Review protocol → Suggestion guard: imports (evidence: `collab-server/src/services/reviewProtocol.ts`)
- Review persistence → Review protocol: uses version (evidence: `collab-server/src/services/reviewStorage.ts`)
- Collaboration server → Review persistence: persists review state (evidence: `collab-server/src/server.ts`)
- Platform services → Table read: supports playback
