# sevan1211/prism architecture

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

- Interactive diagram: https://gitdiagram.com/sevan1211/prism
- Repository: https://github.com/sevan1211/prism

## Overview

PRISM is a browser-based reading workspace: users import and inspect a PDF, request and approve a source-grounded lesson plan, then read, revise, and retain the lesson alongside the evidence. The README also describes optional compatible-agent authoring and opt-in account cloud storage; local reading does not depend on either. The graph emphasizes those documented product branches and the sampled call paths. Some lesson and reader wiring is documented but not present in the excerpts, so uncertain internal links are omitted.

Main entry points: [`apps/web/src/storage/browserVault.ts`](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/browserVault.ts) (Browser library), [`apps/web/src/App.tsx`](https://github.com/sevan1211/prism/blob/main/apps/web/src/App.tsx) (PRISM workspace), [`apps/web/src/reader/SourceReader.tsx`](https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/SourceReader.tsx) (Source reader), [`apps/web/src/webmcp/usePrismLibraryTools.ts`](https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/usePrismLibraryTools.ts) (Library tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Reading workspace"]
  node_reader["PRISM workspace<br/>[App.tsx]"]
  node_source_library_ui["Source library<br/>[SourceLibrary.tsx]"]
  node_source_reader["Source reader<br/>[SourceReader.tsx]"]
  node_lesson_reader["Lesson reader"]
end

subgraph group_sources["Source handling"]
  node_pdf_import["PDF import<br/>[browserSources.ts]"]
  node_source_index["Source indexing"]
  node_contents_scan["Contents analysis"]
  node_visual_inspection["Visual inspection"]
end

subgraph group_authoring["Lesson authoring"]
  node_brief_composer["Request composer"]
  node_plan_management["Plan and scope<br/>[lessonPlans.ts]"]
  node_coverage_review["Coverage review"]
  node_lesson_documents["Lesson documents<br/>[lessonDocuments.ts]"]
  node_revision["Lesson revisions"]
end

subgraph group_agent["Agent tools"]
  node_tool_registration["Tool registration"]
  node_library_tools["Library tools"]
  node_topic_tools["Topic tools<br/>[useTopicTools.ts]"]
end

subgraph group_storage["Library and sync"]
  node_browser_vault[("Browser library<br/>[browserVault.ts]")]
  node_sync_database[("Sync journal<br/>[syncDatabase.ts]")]
  node_cloud_panel["Cloud settings"]
  node_synced_library["Cloud sync client<br/>[syncedLibrary.ts]"]
  node_sync_worker["Cloud API<br/>[worker.ts]"]
  node_cloud_db[("Cloud metadata<br/>[schema.ts]")]
end

node_user(("Reader"))
node_agent_actor(("Compatible agent"))
node_clerk["Clerk"]
node_r2[("Private R2 files")]

node_user -->|"uses"| node_reader
node_reader -->|"shows library"| node_source_library_ui
node_reader -->|"opens source"| node_source_reader
node_reader -->|"opens lesson"| node_lesson_reader
node_source_library_ui -->|"imports PDF"| node_pdf_import
node_pdf_import -->|"stores source"| node_browser_vault
node_source_index -->|"reads source"| node_browser_vault
node_source_reader -->|"reads evidence"| node_browser_vault
node_source_reader -->|"scans contents"| node_contents_scan
node_source_reader -->|"inspects figures"| node_visual_inspection
node_reader -->|"starts request"| node_brief_composer
node_brief_composer -->|"saves plan"| node_plan_management
node_plan_management -->|"reviews scope"| node_coverage_review
node_lesson_reader -->|"reads lesson"| node_lesson_documents
node_lesson_reader -->|"reviews revisions"| node_revision
node_agent_actor -->|"invokes tools"| node_tool_registration
node_tool_registration -->|"registers tools"| node_library_tools
node_tool_registration -->|"registers tools"| node_topic_tools
node_library_tools -->|"reads source"| node_browser_vault
node_library_tools -->|"reads and patches"| node_lesson_documents
node_library_tools -->|"checks plan access"| node_plan_management
node_topic_tools -->|"accesses plans"| node_plan_management
node_cloud_panel -->|"manages sync"| node_synced_library
node_synced_library -->|"syncs library"| node_browser_vault
node_sync_database -->|"tracks writes"| node_browser_vault
node_synced_library -->|"journals changes"| node_sync_database
node_synced_library -->|"sends requests"| node_sync_worker
node_sync_worker -->|"authenticates"| node_clerk
node_sync_worker -->|"reads and writes"| node_cloud_db
node_sync_worker -->|"stores objects"| node_r2

click node_reader "https://github.com/sevan1211/prism/blob/main/apps/web/src/App.tsx"
click node_source_library_ui "https://github.com/sevan1211/prism/blob/main/apps/web/src/workspace/SourceLibrary.tsx"
click node_source_reader "https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/SourceReader.tsx"
click node_lesson_reader "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/LessonReaderPage.tsx"
click node_pdf_import "https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/browserSources.ts"
click node_source_index "https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/sourceIndexWorker.ts"
click node_contents_scan "https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/contentsScanWorker.ts"
click node_visual_inspection "https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/SourceVisualViewer.tsx"
click node_brief_composer "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/LessonBriefComposer.tsx"
click node_plan_management "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonPlans.ts"
click node_coverage_review "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonCoverageReview.ts"
click node_lesson_documents "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonDocuments.ts"
click node_revision "https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonRevisionDiff.ts"
click node_tool_registration "https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/useModelContextTool.ts"
click node_library_tools "https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/usePrismLibraryTools.ts"
click node_topic_tools "https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/useTopicTools.ts"
click node_browser_vault "https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/browserVault.ts"
click node_sync_database "https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/syncDatabase.ts"
click node_cloud_panel "https://github.com/sevan1211/prism/blob/main/apps/web/src/account/CloudStoragePanel.tsx"
click node_synced_library "https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/syncedLibrary.ts"
click node_sync_worker "https://github.com/sevan1211/prism/blob/main/apps/sync/worker.ts"
click node_cloud_db "https://github.com/sevan1211/prism/blob/main/db/schema.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_reader,node_source_library_ui,node_source_reader,node_lesson_reader toneBlue
class node_pdf_import,node_source_index,node_contents_scan,node_visual_inspection,node_r2 toneAmber
class node_brief_composer,node_plan_management,node_coverage_review,node_lesson_documents,node_revision toneMint
class node_tool_registration,node_library_tools,node_topic_tools toneRose
class node_browser_vault,node_sync_database,node_cloud_panel,node_synced_library,node_sync_worker,node_cloud_db,node_user,node_agent_actor,node_clerk toneIndigo
```

## Components

### Reading workspace

- [PRISM workspace](https://github.com/sevan1211/prism/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Source library](https://github.com/sevan1211/prism/blob/main/apps/web/src/workspace/SourceLibrary.tsx): `apps/web/src/workspace/SourceLibrary.tsx`
- [Source reader](https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/SourceReader.tsx): `apps/web/src/reader/SourceReader.tsx`
- [Lesson reader](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/LessonReaderPage.tsx): `apps/web/src/lesson/LessonReaderPage.tsx`

### Source handling

- [PDF import](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/browserSources.ts): `apps/web/src/storage/browserSources.ts`
- [Source indexing](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/sourceIndexWorker.ts): `apps/web/src/storage/sourceIndexWorker.ts`
- [Contents analysis](https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/contentsScanWorker.ts): `apps/web/src/reader/contentsScanWorker.ts`
- [Visual inspection](https://github.com/sevan1211/prism/blob/main/apps/web/src/reader/SourceVisualViewer.tsx): `apps/web/src/reader/SourceVisualViewer.tsx`

### Lesson authoring

- [Request composer](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/LessonBriefComposer.tsx): `apps/web/src/lesson/LessonBriefComposer.tsx`
- [Plan and scope](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonPlans.ts): `apps/web/src/lesson/lessonPlans.ts`
- [Coverage review](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonCoverageReview.ts): `apps/web/src/lesson/lessonCoverageReview.ts`
- [Lesson documents](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonDocuments.ts): `apps/web/src/lesson/lessonDocuments.ts`
- [Lesson revisions](https://github.com/sevan1211/prism/blob/main/apps/web/src/lesson/lessonRevisionDiff.ts): `apps/web/src/lesson/lessonRevisionDiff.ts`

### Agent tools

- [Tool registration](https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/useModelContextTool.ts): `apps/web/src/webmcp/useModelContextTool.ts`
- [Library tools](https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/usePrismLibraryTools.ts): `apps/web/src/webmcp/usePrismLibraryTools.ts`
- [Topic tools](https://github.com/sevan1211/prism/blob/main/apps/web/src/webmcp/useTopicTools.ts): `apps/web/src/webmcp/useTopicTools.ts`

### Library and sync

- [Browser library](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/browserVault.ts): `apps/web/src/storage/browserVault.ts`
- [Sync journal](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/syncDatabase.ts): `apps/web/src/storage/syncDatabase.ts`
- [Cloud settings](https://github.com/sevan1211/prism/blob/main/apps/web/src/account/CloudStoragePanel.tsx): `apps/web/src/account/CloudStoragePanel.tsx`
- [Cloud sync client](https://github.com/sevan1211/prism/blob/main/apps/web/src/storage/syncedLibrary.ts): `apps/web/src/storage/syncedLibrary.ts`
- [Cloud API](https://github.com/sevan1211/prism/blob/main/apps/sync/worker.ts): `apps/sync/worker.ts`
- [Cloud metadata](https://github.com/sevan1211/prism/blob/main/db/schema.ts): `db/schema.ts`

### Other components

- **Reader**
- **Compatible agent**
- **Clerk**
- **Private R2 files**

## Connections

- Reader → PRISM workspace: uses
- PRISM workspace → Source library: shows library
- PRISM workspace → Source reader: opens source
- PRISM workspace → Lesson reader: opens lesson
- Source library → PDF import: imports PDF
- PDF import → Browser library: stores source
- Source indexing → Browser library: reads source
- Source reader → Browser library: reads evidence
- Source reader → Contents analysis: scans contents
- Source reader → Visual inspection: inspects figures
- PRISM workspace → Request composer: starts request
- Request composer → Plan and scope: saves plan
- Plan and scope → Coverage review: reviews scope
- Lesson reader → Lesson documents: reads lesson
- Lesson reader → Lesson revisions: reviews revisions
- Compatible agent → Tool registration: invokes tools
- Tool registration → Library tools: registers tools
- Tool registration → Topic tools: registers tools
- Library tools → Browser library: reads source
- Library tools → Lesson documents: reads and patches
- Library tools → Plan and scope: checks plan access
- Topic tools → Plan and scope: accesses plans
- Cloud settings → Cloud sync client: manages sync
- Cloud sync client → Browser library: syncs library
- Sync journal → Browser library: tracks writes
- Cloud sync client → Sync journal: journals changes
- Cloud sync client → Cloud API: sends requests
- Cloud API → Clerk: authenticates
- Cloud API → Cloud metadata: reads and writes
- Cloud API → Private R2 files: stores objects
