# thedeductor/inkcoach architecture

> Architecture diagram of the GitHub repository thedeductor/inkcoach, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thedeductor/inkcoach
- Repository: https://github.com/thedeductor/inkcoach

## Overview

InkCoach is an offline desktop writing assistant. Writers edit and manage documents in the React app; editor analysis requests travel through Electron’s secure bridge to the Python backend, while document operations and exports use the same backend route. The backend combines grammar checking with readability and tone analysis, and streams rewriting or generated text from local Ollama back to the assistant panel. Document content, settings, and version history are persisted locally. The README documents these major capabilities; wiring details are based on the sampled source, so uncertain links are omitted.

Main entry points: [`src/preload.js`](https://github.com/thedeductor/inkcoach/blob/main/src/preload.js) (Secure API Bridge), [`backend/api.py`](https://github.com/thedeductor/inkcoach/blob/main/backend/api.py) (JSON Request Router), [`src/App.jsx`](https://github.com/thedeductor/inkcoach/blob/main/src/App.jsx) (App State), [`src/components/Editor.jsx`](https://github.com/thedeductor/inkcoach/blob/main/src/components/Editor.jsx) (Rich Editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Writing Interface"]
  node_app["App State<br/>[App.jsx]"]
  node_editor["Rich Editor<br/>[Editor.jsx]"]
  node_assistant["Assistant Panel<br/>[AssistantPanel.jsx]"]
  node_sidebar["Document Sidebar<br/>[Sidebar.jsx]"]
  node_status["Status Bar<br/>[StatusBar.jsx]"]
  node_topbar["Top Bar<br/>[TopBar.jsx]"]
end

subgraph group_desktop["Desktop Bridge"]
  node_preload["Secure API Bridge<br/>[preload.js]"]
  node_electron["Electron Main<br/>[main.js]"]
end

subgraph group_backend["Writing Services"]
  node_api["JSON Request Router<br/>[api.py]"]
  node_grammar["Grammar Checking<br/>[grammar.py]"]
  node_analysis["Readability and Tone<br/>[readability.py]"]
  node_rewriter["AI Rewrite and Generate<br/>[rewriter.py]"]
end

subgraph group_persistence["Documents and Export"]
  node_storage["Document Storage<br/>[storage.py]"]
  node_exporter["PDF and DOCX Export<br/>[exporter.py]"]
end

node_writer(("Writer"))
node_ollama["Local Ollama"]
node_languagetool["LanguageTool"]
node_sqlite[("SQLite")]
node_exportfiles["Export Files"]

node_writer -->|"edits text"| node_editor
node_writer -->|"requests writing help"| node_assistant
node_writer -->|"manages documents"| node_sidebar
node_editor -->|"reports edits and analysis"| node_app
node_assistant -->|"requests rewrite or generation"| node_preload
node_editor -->|"requests analysis"| node_preload
node_app -->|"requests document actions"| node_preload
node_topbar -->|"triggers app actions"| node_app
node_sidebar -->|"triggers document actions"| node_app
node_app -->|"provides writing status"| node_status
node_preload -->|"dispatches IPC"| node_electron
node_electron -->|"sends JSON requests"| node_api
node_api -->|"checks grammar"| node_grammar
node_api -->|"computes writing metrics"| node_analysis
node_grammar -->|"checks text"| node_languagetool
node_api -->|"starts rewrite or generation"| node_rewriter
node_rewriter -->|"streams chat request"| node_ollama
node_api -->|"dispatches document operations"| node_storage
node_storage -->|"reads and writes"| node_sqlite
node_api -->|"dispatches export"| node_exporter
node_exporter -->|"writes PDF or DOCX"| node_exportfiles
node_api -->|"returns results and stream chunks"| node_electron
node_electron -->|"forwards results and stream events"| node_preload
node_preload -->|"delivers stream events"| node_assistant
node_preload -->|"returns analysis"| node_editor
node_preload -->|"returns document results"| node_app

click node_app "https://github.com/thedeductor/inkcoach/blob/main/src/App.jsx"
click node_editor "https://github.com/thedeductor/inkcoach/blob/main/src/components/Editor.jsx"
click node_assistant "https://github.com/thedeductor/inkcoach/blob/main/src/components/AssistantPanel.jsx"
click node_sidebar "https://github.com/thedeductor/inkcoach/blob/main/src/components/Sidebar.jsx"
click node_status "https://github.com/thedeductor/inkcoach/blob/main/src/components/StatusBar.jsx"
click node_topbar "https://github.com/thedeductor/inkcoach/blob/main/src/components/TopBar.jsx"
click node_preload "https://github.com/thedeductor/inkcoach/blob/main/src/preload.js"
click node_electron "https://github.com/thedeductor/inkcoach/blob/main/src/main.js"
click node_api "https://github.com/thedeductor/inkcoach/blob/main/backend/api.py"
click node_grammar "https://github.com/thedeductor/inkcoach/blob/main/backend/grammar.py"
click node_analysis "https://github.com/thedeductor/inkcoach/blob/main/backend/readability.py"
click node_rewriter "https://github.com/thedeductor/inkcoach/blob/main/backend/rewriter.py"
click node_storage "https://github.com/thedeductor/inkcoach/blob/main/backend/storage.py"
click node_exporter "https://github.com/thedeductor/inkcoach/blob/main/backend/exporter.py"

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,node_assistant,node_sidebar,node_status,node_topbar toneBlue
class node_preload,node_electron,node_sqlite toneAmber
class node_api,node_grammar,node_analysis,node_rewriter toneMint
class node_storage,node_exporter toneRose
class node_writer,node_ollama,node_languagetool,node_exportfiles toneIndigo
```

## Components

### Writing Interface

- [App State](https://github.com/thedeductor/inkcoach/blob/main/src/App.jsx): `src/App.jsx`
- [Rich Editor](https://github.com/thedeductor/inkcoach/blob/main/src/components/Editor.jsx): `src/components/Editor.jsx`
- [Assistant Panel](https://github.com/thedeductor/inkcoach/blob/main/src/components/AssistantPanel.jsx): `src/components/AssistantPanel.jsx`
- [Document Sidebar](https://github.com/thedeductor/inkcoach/blob/main/src/components/Sidebar.jsx): `src/components/Sidebar.jsx`
- [Status Bar](https://github.com/thedeductor/inkcoach/blob/main/src/components/StatusBar.jsx): `src/components/StatusBar.jsx`
- [Top Bar](https://github.com/thedeductor/inkcoach/blob/main/src/components/TopBar.jsx): `src/components/TopBar.jsx`

### Desktop Bridge

- [Secure API Bridge](https://github.com/thedeductor/inkcoach/blob/main/src/preload.js): `src/preload.js`
- [Electron Main](https://github.com/thedeductor/inkcoach/blob/main/src/main.js): `src/main.js`

### Writing Services

- [JSON Request Router](https://github.com/thedeductor/inkcoach/blob/main/backend/api.py): `backend/api.py`
- [Grammar Checking](https://github.com/thedeductor/inkcoach/blob/main/backend/grammar.py): `backend/grammar.py`
- [Readability and Tone](https://github.com/thedeductor/inkcoach/blob/main/backend/readability.py): `backend/readability.py`
- [AI Rewrite and Generate](https://github.com/thedeductor/inkcoach/blob/main/backend/rewriter.py): `backend/rewriter.py`

### Documents and Export

- [Document Storage](https://github.com/thedeductor/inkcoach/blob/main/backend/storage.py): `backend/storage.py`
- [PDF and DOCX Export](https://github.com/thedeductor/inkcoach/blob/main/backend/exporter.py): `backend/exporter.py`

### Other components

- **Writer**
- **Local Ollama**
- **LanguageTool**
- **SQLite**
- **Export Files**

## Connections

- Writer → Rich Editor: edits text
- Writer → Assistant Panel: requests writing help
- Writer → Document Sidebar: manages documents
- Rich Editor → App State: reports edits and analysis
- Assistant Panel → Secure API Bridge: requests rewrite or generation
- Rich Editor → Secure API Bridge: requests analysis
- App State → Secure API Bridge: requests document actions
- Top Bar → App State: triggers app actions
- Document Sidebar → App State: triggers document actions
- App State → Status Bar: provides writing status
- Secure API Bridge → Electron Main: dispatches IPC
- Electron Main → JSON Request Router: sends JSON requests
- JSON Request Router → Grammar Checking: checks grammar
- JSON Request Router → Readability and Tone: computes writing metrics
- Grammar Checking → LanguageTool: checks text
- JSON Request Router → AI Rewrite and Generate: starts rewrite or generation
- AI Rewrite and Generate → Local Ollama: streams chat request
- JSON Request Router → Document Storage: dispatches document operations
- Document Storage → SQLite: reads and writes
- JSON Request Router → PDF and DOCX Export: dispatches export
- PDF and DOCX Export → Export Files: writes PDF or DOCX
- JSON Request Router → Electron Main: returns results and stream chunks
- Electron Main → Secure API Bridge: forwards results and stream events
- Secure API Bridge → Assistant Panel: delivers stream events
- Secure API Bridge → Rich Editor: returns analysis
- Secure API Bridge → App State: returns document results
