# fooftilly/prks architecture

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

- Interactive diagram: https://gitdiagram.com/fooftilly/prks
- Repository: https://github.com/fooftilly/prks

## Overview

PRKS is a self-hosted, local-first research library. A user browses or edits library content in the browser; the server handles API requests and coordinates domain operations against the canonical library and managed files. The README documents research organization, PDF reading and annotation, structured research links, workspace tabs, offline-capable operations, and backup/restore. The graph preserves these major branches; several edges describe documented capabilities rather than inspected call sites, and are cited to the README.

Main entry points: [`backend/server.py`](https://github.com/fooftilly/prks/blob/master/backend/server.py) (API server), [`frontend/js/app.js`](https://github.com/fooftilly/prks/blob/master/frontend/js/app.js) (Browser UI), [`backend/db_manager.py`](https://github.com/fooftilly/prks/blob/master/backend/db_manager.py) (Works and metadata), [`backend/services/work_pdf_replace.py`](https://github.com/fooftilly/prks/blob/master/backend/services/work_pdf_replace.py) (PDF replacement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_browser["Browser UI<br/>[app.js]"]
  node_workspace["Tabs and panes<br/>[workspace-model.js]"]
  node_classic["Legacy browser runtime<br/>[app.js]"]
  node_vue_routes["Typed route surfaces<br/>[routes.ts]"]
end

subgraph group_api["HTTP application"]
  node_server["API server<br/>[server.py]"]
  node_identity["Identity boundary<br/>[session.py]"]
end

subgraph group_library["Library domains"]
  node_works["Works and metadata<br/>[db_manager.py]"]
  node_research["Research relationships"]
  node_search["Search and indexing<br/>[text_index.py]"]
  node_annotations["PDF annotations<br/>[pdf_annotations.py]"]
  node_pdfreplace["PDF replacement"]
end

subgraph group_persistence["Persistence and files"]
  node_database[("Library database<br/>[db_manager.py]")]
  node_storage[("Storage root<br/>[root_binding.py]")]
  node_pdfs["Managed PDFs<br/>[paths.py]"]
end

subgraph group_operations["Local-first operations"]
  node_offline["Offline runtime<br/>[offline-runtime.js]"]
  node_sync["Durable operations<br/>[sync-runtime.js]"]
  node_backup["Backup and restore<br/>[backup_restore.py]"]
end

node_user(("Researcher"))

node_user -->|"uses"| node_browser
node_browser -.->|"requests"| node_server
node_server -->|"admits requests"| node_identity
node_server -->|"handles library APIs"| node_works
node_server -->|"routes research edits"| node_research
node_server -->|"serves search"| node_search
node_server -->|"handles annotations"| node_annotations
node_server -->|"coordinates PDF updates"| node_pdfreplace
node_works -.->|"reads and writes"| node_database
node_pdfreplace -->|"publishes PDF bytes"| node_pdfs
node_storage -->|"roots file paths"| node_pdfs
node_user -->|"organizes work"| node_workspace
node_browser -->|"presents tabs"| node_workspace
node_browser -->|"runs library UI"| node_classic
node_browser -.->|"mounts route surfaces"| node_vue_routes
node_browser -->|"supports offline use"| node_offline
node_offline -.->|"queues durable operations"| node_sync
node_sync -.->|"synchronizes operations"| node_server
node_user -->|"backs up library"| node_backup
node_backup -->|"backs up canonical data"| node_database
node_user -->|"annotates PDFs"| node_annotations
node_user -->|"connects research"| node_research
node_user -->|"finds library items"| node_search

click node_browser "https://github.com/fooftilly/prks/blob/master/frontend/js/app.js"
click node_workspace "https://github.com/fooftilly/prks/blob/master/frontend/js/workspace-model.js"
click node_offline "https://github.com/fooftilly/prks/blob/master/frontend/js/offline-runtime.js"
click node_sync "https://github.com/fooftilly/prks/blob/master/frontend/js/sync-runtime.js"
click node_server "https://github.com/fooftilly/prks/blob/master/backend/server.py"
click node_identity "https://github.com/fooftilly/prks/blob/master/backend/api/session.py"
click node_works "https://github.com/fooftilly/prks/blob/master/backend/db_manager.py"
click node_research "https://github.com/fooftilly/prks/blob/master/backend/research_network.py"
click node_search "https://github.com/fooftilly/prks/blob/master/backend/text_index.py"
click node_annotations "https://github.com/fooftilly/prks/blob/master/backend/pdf_annotations.py"
click node_pdfreplace "https://github.com/fooftilly/prks/blob/master/backend/services/work_pdf_replace.py"
click node_database "https://github.com/fooftilly/prks/blob/master/backend/db_manager.py"
click node_storage "https://github.com/fooftilly/prks/blob/master/backend/storage/root_binding.py"
click node_pdfs "https://github.com/fooftilly/prks/blob/master/backend/storage/paths.py"
click node_backup "https://github.com/fooftilly/prks/blob/master/backend/backup_restore.py"
click node_classic "https://github.com/fooftilly/prks/blob/master/frontend/js/app.js"
click node_vue_routes "https://github.com/fooftilly/prks/blob/master/frontend-app/src/route-surface/routes.ts"

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_browser,node_workspace,node_classic,node_vue_routes toneBlue
class node_server,node_identity toneAmber
class node_works,node_research,node_search,node_annotations,node_pdfreplace toneMint
class node_database,node_storage,node_pdfs toneRose
class node_offline,node_sync,node_backup,node_user toneIndigo
```

## Components

### Browser experience

- [Browser UI](https://github.com/fooftilly/prks/blob/master/frontend/js/app.js): `frontend/js/app.js`
- [Tabs and panes](https://github.com/fooftilly/prks/blob/master/frontend/js/workspace-model.js): `frontend/js/workspace-model.js`
- [Legacy browser runtime](https://github.com/fooftilly/prks/blob/master/frontend/js/app.js): `frontend/js/app.js`
- [Typed route surfaces](https://github.com/fooftilly/prks/blob/master/frontend-app/src/route-surface/routes.ts): `frontend-app/src/route-surface/routes.ts`

### HTTP application

- [API server](https://github.com/fooftilly/prks/blob/master/backend/server.py): `backend/server.py`
- [Identity boundary](https://github.com/fooftilly/prks/blob/master/backend/api/session.py): `backend/api/session.py`

### Library domains

- [Works and metadata](https://github.com/fooftilly/prks/blob/master/backend/db_manager.py): `backend/db_manager.py`
- [Research relationships](https://github.com/fooftilly/prks/blob/master/backend/research_network.py): `backend/research_network.py`
- [Search and indexing](https://github.com/fooftilly/prks/blob/master/backend/text_index.py): `backend/text_index.py`
- [PDF annotations](https://github.com/fooftilly/prks/blob/master/backend/pdf_annotations.py): `backend/pdf_annotations.py`
- [PDF replacement](https://github.com/fooftilly/prks/blob/master/backend/services/work_pdf_replace.py): `backend/services/work_pdf_replace.py`

### Persistence and files

- [Library database](https://github.com/fooftilly/prks/blob/master/backend/db_manager.py): `backend/db_manager.py`
- [Storage root](https://github.com/fooftilly/prks/blob/master/backend/storage/root_binding.py): `backend/storage/root_binding.py`
- [Managed PDFs](https://github.com/fooftilly/prks/blob/master/backend/storage/paths.py): `backend/storage/paths.py`

### Local-first operations

- [Offline runtime](https://github.com/fooftilly/prks/blob/master/frontend/js/offline-runtime.js): `frontend/js/offline-runtime.js`
- [Durable operations](https://github.com/fooftilly/prks/blob/master/frontend/js/sync-runtime.js): `frontend/js/sync-runtime.js`
- [Backup and restore](https://github.com/fooftilly/prks/blob/master/backend/backup_restore.py): `backend/backup_restore.py`

### Other components

- **Researcher**

## Connections

- Researcher → Browser UI: uses (evidence: `README.md`)
- Browser UI → API server: requests
- API server → Identity boundary: admits requests (evidence: `backend/api/session.py`)
- API server → Works and metadata: handles library APIs (evidence: `backend/server.py`)
- API server → Research relationships: routes research edits (evidence: `backend/server.py`)
- API server → Search and indexing: serves search (evidence: `backend/server.py`)
- API server → PDF annotations: handles annotations (evidence: `backend/server.py`)
- API server → PDF replacement: coordinates PDF updates (evidence: `backend/server.py`)
- Works and metadata → Library database: reads and writes (evidence: `backend/db_manager.py`)
- PDF replacement → Managed PDFs: publishes PDF bytes (evidence: `backend/services/work_pdf_replace.py`)
- Storage root → Managed PDFs: roots file paths (evidence: `backend/storage/paths.py`)
- Researcher → Tabs and panes: organizes work (evidence: `README.md`)
- Browser UI → Tabs and panes: presents tabs (evidence: `README.md`)
- Browser UI → Legacy browser runtime: runs library UI (evidence: `README.md`)
- Browser UI → Typed route surfaces: mounts route surfaces
- Browser UI → Offline runtime: supports offline use (evidence: `README.md`)
- Offline runtime → Durable operations: queues durable operations
- Durable operations → API server: synchronizes operations
- Researcher → Backup and restore: backs up library (evidence: `README.md`)
- Backup and restore → Library database: backs up canonical data (evidence: `README.md`)
- Researcher → PDF annotations: annotates PDFs (evidence: `README.md`)
- Researcher → Research relationships: connects research (evidence: `README.md`)
- Researcher → Search and indexing: finds library items (evidence: `README.md`)
