# adrienlawrence/sentia architecture

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

- Interactive diagram: https://gitdiagram.com/adrienlawrence/sentia
- Repository: https://github.com/adrienlawrence/sentia

## Overview

My Smart Notes is a web notebook with rich-text editing, notebook/page persistence, AI-assisted writing and study quizzes, imports/exports, drawing, and integrations. The principal workflow is editing a notebook and saving page or title changes through API routes; the editor session excerpt also shows page loading and notebook-open tracking. AI questions are handled by a dedicated route that moderates input, retrieves notebook context, and requests a grounded answer. Several capabilities are visible only in the tree, so their internal wiring is left unspecified.

Main entry points: [`my-smart-notes/src/app/api/ai/ask/route.ts`](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/ai/ask/route.ts) (AI ask endpoint), [`my-smart-notes/src/features/editor/hooks/useEditorTitles.ts`](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useEditorTitles.ts) (Title editing), [`my-smart-notes/src/features/editor/hooks/useNotebookMutationQueue.ts`](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useNotebookMutationQueue.ts) (Mutation queue), [`my-smart-notes/src/app/api/notebooks/[id]/route.ts`](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/notebooks/%5Bid%5D/route.ts) (Notebook endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Notebook experience"]
  node_dashboard["Notebook dashboard<br/>[page.tsx]"]
  node_editor["Editor workspace"]
  node_richtext["Rich-text editing<br/>[TiptapEditor.tsx]"]
  node_session["Editor session"]
  node_titles["Title editing<br/>[useEditorTitles.ts]"]
  node_mutation["Mutation queue"]
end

subgraph group_persistence["Notebook persistence"]
  node_notebook_api["Notebook endpoints<br/>[route.ts]"]
  node_page_api["Page endpoints<br/>[route.ts]"]
  node_database[("Application database<br/>[prisma.ts]")]
end

subgraph group_intelligence["AI and study"]
  node_ai_route["AI ask endpoint<br/>[route.ts]"]
  node_ai_service["Grounded AI service<br/>[openai.ts]"]
  node_rag["Notebook retrieval<br/>[rag.ts]"]
  node_safety["AI safety controls<br/>[safety.ts]"]
  node_quiz["Quiz generation<br/>[route.ts]"]
end

subgraph group_capabilities["Product capabilities"]
  node_file_transfer["Import and export<br/>[fileImport.ts]"]
  node_drawing["Notebook drawings<br/>[route.ts]"]
  node_local_mirror["Markdown mirror"]
  node_mcp["MCP integration<br/>[server.ts]"]
end

node_user(("Notebook user"))
node_openai{{"OpenAI service"}}

node_user -.->|"opens notebooks"| node_dashboard
node_user -.->|"edits notes"| node_editor
node_session -->|"loads and patches"| node_notebook_api
node_session -->|"loads and saves"| node_page_api
node_titles -->|"queues saves"| node_mutation
node_titles -->|"patches notebook"| node_notebook_api
node_titles -->|"patches title"| node_page_api
node_mutation -.->|"dispatches mutations"| node_notebook_api
node_mutation -.->|"dispatches mutations"| node_page_api
node_ai_route -->|"retrieves context"| node_rag
node_ai_route -->|"moderates and answers"| node_ai_service
node_ai_route -->|"serializes input"| node_safety
node_ai_route -->|"reads page"| node_database
node_ai_service -.->|"requests completions"| node_openai

click node_dashboard "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/dashboard/page.tsx"
click node_editor "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/EditorWorkspace.tsx"
click node_richtext "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/components/TiptapEditor.tsx"
click node_session "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useEditorSession.ts"
click node_titles "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useEditorTitles.ts"
click node_mutation "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useNotebookMutationQueue.ts"
click node_notebook_api "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/notebooks/%5Bid%5D/route.ts"
click node_page_api "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/pages/%5Bid%5D/route.ts"
click node_database "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/prisma.ts"
click node_ai_route "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/ai/ask/route.ts"
click node_ai_service "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/openai.ts"
click node_rag "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/rag.ts"
click node_safety "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/safety.ts"
click node_quiz "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/ai/quiz/route.ts"
click node_file_transfer "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/file-transfer/lib/fileImport.ts"
click node_drawing "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/draw-elements/route.ts"
click node_local_mirror "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/local-mirror/hooks/useLocalMarkdownMirror.ts"
click node_mcp "https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/mcp/server.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_dashboard,node_editor,node_richtext,node_session,node_titles,node_mutation,node_user toneBlue
class node_notebook_api,node_page_api,node_database toneAmber
class node_ai_route,node_ai_service,node_rag,node_safety,node_quiz toneMint
class node_file_transfer,node_drawing,node_local_mirror,node_mcp toneRose
class node_openai toneIndigo
```

## Components

### Notebook experience

- [Notebook dashboard](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/dashboard/page.tsx): `my-smart-notes/src/app/dashboard/page.tsx`
- [Editor workspace](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/EditorWorkspace.tsx): `my-smart-notes/src/features/editor/EditorWorkspace.tsx`
- [Rich-text editing](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/components/TiptapEditor.tsx): `my-smart-notes/src/components/TiptapEditor.tsx`
- [Editor session](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useEditorSession.ts): `my-smart-notes/src/features/editor/hooks/useEditorSession.ts`
- [Title editing](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useEditorTitles.ts): `my-smart-notes/src/features/editor/hooks/useEditorTitles.ts`
- [Mutation queue](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/editor/hooks/useNotebookMutationQueue.ts): `my-smart-notes/src/features/editor/hooks/useNotebookMutationQueue.ts`

### Notebook persistence

- [Notebook endpoints](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/notebooks/%5Bid%5D/route.ts): `my-smart-notes/src/app/api/notebooks/[id]/route.ts`
- [Page endpoints](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/pages/%5Bid%5D/route.ts): `my-smart-notes/src/app/api/pages/[id]/route.ts`
- [Application database](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/prisma.ts): `my-smart-notes/src/lib/prisma.ts`

### AI and study

- [AI ask endpoint](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/ai/ask/route.ts): `my-smart-notes/src/app/api/ai/ask/route.ts`
- [Grounded AI service](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/openai.ts): `my-smart-notes/src/lib/ai/openai.ts`
- [Notebook retrieval](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/rag.ts): `my-smart-notes/src/lib/ai/rag.ts`
- [AI safety controls](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/ai/safety.ts): `my-smart-notes/src/lib/ai/safety.ts`
- [Quiz generation](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/ai/quiz/route.ts): `my-smart-notes/src/app/api/ai/quiz/route.ts`

### Product capabilities

- [Import and export](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/file-transfer/lib/fileImport.ts): `my-smart-notes/src/features/file-transfer/lib/fileImport.ts`
- [Notebook drawings](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/app/api/draw-elements/route.ts): `my-smart-notes/src/app/api/draw-elements/route.ts`
- [Markdown mirror](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/features/local-mirror/hooks/useLocalMarkdownMirror.ts): `my-smart-notes/src/features/local-mirror/hooks/useLocalMarkdownMirror.ts`
- [MCP integration](https://github.com/adrienlawrence/sentia/blob/main/my-smart-notes/src/lib/mcp/server.ts): `my-smart-notes/src/lib/mcp/server.ts`

### Other components

- **Notebook user**
- **OpenAI service**

## Connections

- Notebook user → Notebook dashboard: opens notebooks
- Notebook user → Editor workspace: edits notes
- Editor session → Notebook endpoints: loads and patches (evidence: `my-smart-notes/src/features/editor/hooks/useEditorSession.ts`)
- Editor session → Page endpoints: loads and saves (evidence: `my-smart-notes/src/features/editor/hooks/useEditorSession.ts`)
- Title editing → Mutation queue: queues saves (evidence: `my-smart-notes/src/features/editor/hooks/useEditorTitles.ts`)
- Title editing → Notebook endpoints: patches notebook (evidence: `my-smart-notes/src/features/editor/hooks/useEditorTitles.ts`)
- Title editing → Page endpoints: patches title (evidence: `my-smart-notes/src/features/editor/hooks/useEditorTitles.ts`)
- Mutation queue → Notebook endpoints: dispatches mutations
- Mutation queue → Page endpoints: dispatches mutations
- AI ask endpoint → Notebook retrieval: retrieves context (evidence: `my-smart-notes/src/app/api/ai/ask/route.ts`)
- AI ask endpoint → Grounded AI service: moderates and answers (evidence: `my-smart-notes/src/app/api/ai/ask/route.ts`)
- AI ask endpoint → AI safety controls: serializes input (evidence: `my-smart-notes/src/app/api/ai/ask/route.ts`)
- AI ask endpoint → Application database: reads page (evidence: `my-smart-notes/src/app/api/ai/ask/route.ts`)
- Grounded AI service → OpenAI service: requests completions
