# soaer01/popdoc architecture

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

- Interactive diagram: https://gitdiagram.com/soaer01/popdoc
- Repository: https://github.com/soaer01/popdoc

## Overview

PopDoc is a collaborative writing app where members edit private drafts and changes reach the shared document through reviewed pull requests. The workflow spans authentication, drafting with paragraph provenance, save-point history, review and conflict resolution, then contribution-ledger and process-record inspection. The frontend uses Redux-backed features and a selectable API transport; the Express backend exposes corresponding resource routes and shared state/helpers. The README documents AI-assisted change review and real-time presence. Some frontend and backend modules were not excerpted, so their relationships are included only where the README or source index supports them.

Main entry points: [`src/App.jsx`](https://github.com/soaer01/popdoc/blob/main/src/App.jsx) (App routing), [`backend/src/app.js`](https://github.com/soaer01/popdoc/blob/main/backend/src/app.js) (HTTP application), [`src/api/index.js`](https://github.com/soaer01/popdoc/blob/main/src/api/index.js) (API transport), [`backend/src/utils/store.js`](https://github.com/soaer01/popdoc/blob/main/backend/src/utils/store.js) (Runtime store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Writing client"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth["Authentication<br/>[authSlice.js]"]
  node_transport["API transport<br/>[index.js]"]
  node_draft["Private drafting<br/>[Draft.jsx]"]
  node_editor["Provenance editor<br/>[Editor.jsx]"]
  node_presence["Live presence<br/>[usePresence.js]"]
end

subgraph group_review["Review and record"]
  node_history["Commit history<br/>[History.jsx]"]
  node_diff["Diff engine<br/>[diff.js]"]
  node_pulls["Pull requests<br/>[pullsSlice.js]"]
  node_pullview["Pull review<br/>[PullRequest.jsx]"]
  node_ai_review["AI change review<br/>[AiReview.jsx]"]
  node_ledger["Contribution ledger<br/>[Ledger.jsx]"]
  node_record["Process record<br/>[Record.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["HTTP application<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_branch_routes["Branch routes<br/>[branches.js]"]
  node_history_routes["History routes<br/>[history.js]"]
  node_pull_routes["Pull routes<br/>[pulls.js]"]
  node_ai_routes["AI job routes<br/>[ai.js]"]
  node_ledger_routes["Ledger routes<br/>[ledger.js]"]
end

subgraph group_domain["Domain services"]
  node_store[("Runtime store<br/>[store.js]")]
  node_merge["Merge logic<br/>[merge.js]"]
  node_hash["Commit hashing<br/>[hash.js]"]
  node_llm["LLM integration<br/>[llm.js]"]
end

node_writer(("Collaborator"))

node_writer -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_draft
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_pulls
node_app -->|"routes to"| node_ledger
node_app -->|"routes to"| node_record
node_auth -->|"calls"| node_transport
node_draft -.->|"uses"| node_editor
node_draft -.->|"uses"| node_presence
node_history -->|"uses"| node_diff
node_pullview -->|"uses"| node_diff
node_pullview -->|"renders"| node_ai_review
node_ai_review -->|"dispatches"| node_pulls
node_pulls -->|"calls"| node_transport
node_history -->|"calls"| node_transport
node_ledger -->|"calls"| node_transport
node_record -->|"calls"| node_transport
node_presence -.->|"signals presence"| node_writer
node_transport -->|"sends API requests"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_branch_routes
node_server -->|"mounts"| node_history_routes
node_server -->|"mounts"| node_pull_routes
node_server -->|"mounts"| node_ai_routes
node_server -->|"mounts"| node_ledger_routes
node_auth_routes -->|"reads"| node_store
node_branch_routes -->|"reads and writes"| node_store
node_branch_routes -->|"calls"| node_merge
node_branch_routes -->|"calls"| node_hash
node_history_routes -->|"reads"| node_store
node_history_routes -->|"calls"| node_hash
node_pull_routes -->|"reads and writes"| node_store
node_pull_routes -->|"calls"| node_merge
node_pull_routes -->|"calls"| node_hash
node_ai_routes -->|"reads and writes"| node_store
node_ai_routes -->|"calls"| node_llm
node_ai_routes -->|"calls"| node_hash
node_ledger_routes -.->|"reads"| node_store

click node_app "https://github.com/soaer01/popdoc/blob/main/src/App.jsx"
click node_auth "https://github.com/soaer01/popdoc/blob/main/src/features/auth/authSlice.js"
click node_transport "https://github.com/soaer01/popdoc/blob/main/src/api/index.js"
click node_draft "https://github.com/soaer01/popdoc/blob/main/src/features/branches/Draft.jsx"
click node_editor "https://github.com/soaer01/popdoc/blob/main/src/features/editor/Editor.jsx"
click node_presence "https://github.com/soaer01/popdoc/blob/main/src/features/branches/usePresence.js"
click node_history "https://github.com/soaer01/popdoc/blob/main/src/features/history/History.jsx"
click node_diff "https://github.com/soaer01/popdoc/blob/main/src/lib/diff.js"
click node_pulls "https://github.com/soaer01/popdoc/blob/main/src/features/pulls/pullsSlice.js"
click node_pullview "https://github.com/soaer01/popdoc/blob/main/src/features/pulls/PullRequest.jsx"
click node_ai_review "https://github.com/soaer01/popdoc/blob/main/src/features/ai/AiReview.jsx"
click node_ledger "https://github.com/soaer01/popdoc/blob/main/src/features/ledger/Ledger.jsx"
click node_record "https://github.com/soaer01/popdoc/blob/main/src/features/record/Record.jsx"
click node_server "https://github.com/soaer01/popdoc/blob/main/backend/src/app.js"
click node_auth_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/auth.js"
click node_branch_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/branches.js"
click node_history_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/history.js"
click node_pull_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/pulls.js"
click node_ai_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/ai.js"
click node_ledger_routes "https://github.com/soaer01/popdoc/blob/main/backend/src/routes/ledger.js"
click node_store "https://github.com/soaer01/popdoc/blob/main/backend/src/utils/store.js"
click node_merge "https://github.com/soaer01/popdoc/blob/main/backend/src/utils/merge.js"
click node_hash "https://github.com/soaer01/popdoc/blob/main/backend/src/utils/hash.js"
click node_llm "https://github.com/soaer01/popdoc/blob/main/backend/src/utils/llm.js"

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_auth,node_transport,node_draft,node_editor,node_presence toneBlue
class node_history,node_diff,node_pulls,node_pullview,node_ai_review,node_ledger,node_record toneAmber
class node_server,node_auth_routes,node_branch_routes,node_history_routes,node_pull_routes,node_ai_routes,node_ledger_routes toneMint
class node_store,node_merge,node_hash,node_llm toneRose
class node_writer toneIndigo
```

## Components

### Writing client

- [App routing](https://github.com/soaer01/popdoc/blob/main/src/App.jsx): `src/App.jsx`
- [Authentication](https://github.com/soaer01/popdoc/blob/main/src/features/auth/authSlice.js): `src/features/auth/authSlice.js`
- [API transport](https://github.com/soaer01/popdoc/blob/main/src/api/index.js): `src/api/index.js`
- [Private drafting](https://github.com/soaer01/popdoc/blob/main/src/features/branches/Draft.jsx): `src/features/branches/Draft.jsx`
- [Provenance editor](https://github.com/soaer01/popdoc/blob/main/src/features/editor/Editor.jsx): `src/features/editor/Editor.jsx`
- [Live presence](https://github.com/soaer01/popdoc/blob/main/src/features/branches/usePresence.js): `src/features/branches/usePresence.js`

### Review and record

- [Commit history](https://github.com/soaer01/popdoc/blob/main/src/features/history/History.jsx): `src/features/history/History.jsx`
- [Diff engine](https://github.com/soaer01/popdoc/blob/main/src/lib/diff.js): `src/lib/diff.js`
- [Pull requests](https://github.com/soaer01/popdoc/blob/main/src/features/pulls/pullsSlice.js): `src/features/pulls/pullsSlice.js`
- [Pull review](https://github.com/soaer01/popdoc/blob/main/src/features/pulls/PullRequest.jsx): `src/features/pulls/PullRequest.jsx`
- [AI change review](https://github.com/soaer01/popdoc/blob/main/src/features/ai/AiReview.jsx): `src/features/ai/AiReview.jsx`
- [Contribution ledger](https://github.com/soaer01/popdoc/blob/main/src/features/ledger/Ledger.jsx): `src/features/ledger/Ledger.jsx`
- [Process record](https://github.com/soaer01/popdoc/blob/main/src/features/record/Record.jsx): `src/features/record/Record.jsx`

### Backend API

- [HTTP application](https://github.com/soaer01/popdoc/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Branch routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/branches.js): `backend/src/routes/branches.js`
- [History routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/history.js): `backend/src/routes/history.js`
- [Pull routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/pulls.js): `backend/src/routes/pulls.js`
- [AI job routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/ai.js): `backend/src/routes/ai.js`
- [Ledger routes](https://github.com/soaer01/popdoc/blob/main/backend/src/routes/ledger.js): `backend/src/routes/ledger.js`

### Domain services

- [Runtime store](https://github.com/soaer01/popdoc/blob/main/backend/src/utils/store.js): `backend/src/utils/store.js`
- [Merge logic](https://github.com/soaer01/popdoc/blob/main/backend/src/utils/merge.js): `backend/src/utils/merge.js`
- [Commit hashing](https://github.com/soaer01/popdoc/blob/main/backend/src/utils/hash.js): `backend/src/utils/hash.js`
- [LLM integration](https://github.com/soaer01/popdoc/blob/main/backend/src/utils/llm.js): `backend/src/utils/llm.js`

### Other components

- **Collaborator**

## Connections

- Collaborator → App routing: uses (evidence: `README.md`)
- App routing → Authentication: routes to (evidence: `src/App.jsx`)
- App routing → Private drafting: routes to (evidence: `src/App.jsx`)
- App routing → Commit history: routes to (evidence: `src/App.jsx`)
- App routing → Pull requests: routes to (evidence: `src/App.jsx`)
- App routing → Contribution ledger: routes to (evidence: `src/App.jsx`)
- App routing → Process record: routes to (evidence: `src/App.jsx`)
- Authentication → API transport: calls (evidence: `src/features/auth/authSlice.js`)
- Private drafting → Provenance editor: uses
- Private drafting → Live presence: uses
- Commit history → Diff engine: uses (evidence: `src/features/history/History.jsx`)
- Pull review → Diff engine: uses (evidence: `src/features/pulls/PullRequest.jsx`)
- Pull review → AI change review: renders (evidence: `src/features/pulls/PullRequest.jsx`)
- AI change review → Pull requests: dispatches (evidence: `src/features/ai/AiReview.jsx`)
- Pull requests → API transport: calls (evidence: `src/features/pulls/pullsSlice.js`)
- Commit history → API transport: calls (evidence: `src/features/history/History.jsx`)
- Contribution ledger → API transport: calls (evidence: `src/features/ledger/Ledger.jsx`)
- Process record → API transport: calls (evidence: `src/features/record/Record.jsx`)
- Live presence → Collaborator: signals presence (evidence: `README.md`)
- API transport → HTTP application: sends API requests (evidence: `README.md`)
- HTTP application → Auth routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → Branch routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → History routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → Pull routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → AI job routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → Ledger routes: mounts (evidence: `backend/src/app.js`)
- Auth routes → Runtime store: reads (evidence: `backend/src/routes/auth.js`)
- Branch routes → Runtime store: reads and writes (evidence: `backend/src/routes/branches.js`)
- Branch routes → Merge logic: calls (evidence: `backend/src/routes/branches.js`)
- Branch routes → Commit hashing: calls (evidence: `backend/src/routes/branches.js`)
- History routes → Runtime store: reads (evidence: `backend/src/routes/history.js`)
- History routes → Commit hashing: calls (evidence: `backend/src/routes/history.js`)
- Pull routes → Runtime store: reads and writes (evidence: `backend/src/routes/pulls.js`)
- Pull routes → Merge logic: calls (evidence: `backend/src/routes/pulls.js`)
- Pull routes → Commit hashing: calls (evidence: `backend/src/routes/pulls.js`)
- AI job routes → Runtime store: reads and writes (evidence: `backend/src/routes/ai.js`)
- AI job routes → LLM integration: calls (evidence: `backend/src/routes/ai.js`)
- AI job routes → Commit hashing: calls (evidence: `backend/src/routes/ai.js`)
- Ledger routes → Runtime store: reads
