Skill Tracer
Skills › Scientific Agent Skills › open-notebook › architecture.md

architecture.md

89 lines · skills/open-notebook/references/architecture.md at 5f2bc03

Open on GitHub
1# Open Notebook Architecture
2
3Reviewed 2026-09-30 using
4[application wiring](https://github.com/lfnovo/open-notebook/blob/v1.14.0/api/main.py),
5[storage paths](https://github.com/lfnovo/open-notebook/blob/v1.14.0/open_notebook/config.py),
6and [source installation](https://github.com/lfnovo/open-notebook/blob/v1.14.0/docs/1-INSTALLATION/from-source.md).
7These are source-level findings, not live deployment verification.
8

Open Notebook Architecture

Reviewed 2026-09-30 using application wiring, storage paths, and source installation. These are source-level findings, not live deployment verification.

Raw lines 1 to 8
9## Runtime components
11- **Next.js/React frontend:** Docker exposes port 8502; source development uses 3000.
12- **FastAPI backend:** default port 5055, business routes below `/api`, live schemas
13 at `/openapi.json`. Pydantic models validate known fields, but extra request fields
14 may be silently ignored. Use the deployed schema when relying on a filter.
15- **SurrealDB v2:** notebook/source/note/model/credential records, graph relations,
16 full-text/vector retrieval, background command records, and schema migrations.
17 The upstream Compose file persists its RocksDB data under `/mydata`.
18- **Background worker:** `surreal-commands-worker` processes extraction, embeddings,
19 and podcast work. It is a separate process even when bundled in the app container.
20 API health alone cannot demonstrate processing readiness.
21- **LangChain/LangGraph:** AI chains and conversation state. Chat checkpoint state
22 also uses SQLite under the application data directory, not just SurrealDB.
23- **Esperanto and processing libraries:** connect to independently configured
24 language, embedding, transcription, speech, and extraction providers.

Runtime components

  • Next.js/React frontend: Docker exposes port 8502; source development uses 3000.
  • FastAPI backend: default port 5055, business routes below /api, live schemas at /openapi.json. Pydantic models validate known fields, but extra request fields may be silently ignored. Use the deployed schema when relying on a filter.
  • SurrealDB v2: notebook/source/note/model/credential records, graph relations, full-text/vector retrieval, background command records, and schema migrations. The upstream Compose file persists its RocksDB data under /mydata.
  • Background worker: surreal-commands-worker processes extraction, embeddings, and podcast work. It is a separate process even when bundled in the app container. API health alone cannot demonstrate processing readiness.
  • LangChain/LangGraph: AI chains and conversation state. Chat checkpoint state also uses SQLite under the application data directory, not just SurrealDB.
  • Esperanto and processing libraries: connect to independently configured language, embedding, transcription, speech, and extraction providers.
Raw lines 9 to 25
26## Ingestion and evidence
281. A request specifies link/upload/text content and notebook associations.
292. The backend validates content type and path/URL policy, creates a source, and
30 either runs processing synchronously or submits a background command.
313. Extraction produces text; optional transformations produce insights; requested
32 embeddings enable vector retrieval.
334. Poll status and retrieve the source to inspect text, errors, and embedding
34 coverage. A successful queue submission does not show completion.
36PDF extraction, OCR, tables, and transcripts can lose important scientific detail.
37Compare extracted measurements, units, and section boundaries with the original
38before using an AI summary as evidence. Preserve source IDs and selected context
39with analysis outputs; generated notes are derivative material, not independent data.

Ingestion and evidence

  1. A request specifies link/upload/text content and notebook associations.
  2. The backend validates content type and path/URL policy, creates a source, and either runs processing synchronously or submits a background command.
  3. Extraction produces text; optional transformations produce insights; requested embeddings enable vector retrieval.
  4. Poll status and retrieve the source to inspect text, errors, and embedding coverage. A successful queue submission does not show completion.

PDF extraction, OCR, tables, and transcripts can lose important scientific detail. Compare extracted measurements, units, and section boundaries with the original before using an AI summary as evidence. Preserve source IDs and selected context with analysis outputs; generated notes are derivative material, not independent data.

Raw lines 26 to 40
41## Chat versus Ask
43Notebook chat first builds a context object from explicit source/note selections,
44then submits that object with a message to `/api/chat/execute`. The endpoint returns
45JSON message history. An empty context configuration has special meaning: it
46includes all notebook items in short form. Explicit ID selections and verification
47of returned content prevent accidental reliance on missing/full-text-free context.
48The context builder can skip individual unavailable records without failing.
50Ask searches the knowledge base with an embedding model and uses strategy, answer,
51and final-answer language models. It can return JSON or an SSE stream depending on
52the route. The release v1.14.0 Search/Ask API is global. Current main adds notebook
53scoping; a field silently ignored by an older server cannot enforce that boundary.

Chat versus Ask

Notebook chat first builds a context object from explicit source/note selections, then submits that object with a message to /api/chat/execute. The endpoint returns JSON message history. An empty context configuration has special meaning: it includes all notebook items in short form. Explicit ID selections and verification of returned content prevent accidental reliance on missing/full-text-free context. The context builder can skip individual unavailable records without failing.

Ask searches the knowledge base with an embedding model and uses strategy, answer, and final-answer language models. It can return JSON or an SSE stream depending on the route. The release v1.14.0 Search/Ask API is global. Current main adds notebook scoping; a field silently ignored by an older server cannot enforce that boundary.

Raw lines 41 to 54
55## Podcasts and persistence
57Podcast jobs combine an episode profile, one multi-speaker profile, supplied
58content, language models for scripts, and speech models for audio. They create an
59episode and audio under `/app/data/podcasts` in the container. A retry of a failed
60episode deletes its record/audio and starts a new job. Inspect the returned job
61result for the new episode ID.
63Back up SurrealDB **and** `/app/data`, which contains uploads, podcasts, SQLite
64checkpoints, and caches. Stored provider keys use the server's
65`OPEN_NOTEBOOK_ENCRYPTION_KEY`; changing or losing it can make credentials unreadable.
66This is not encryption of every stored document.

Podcasts and persistence

Podcast jobs combine an episode profile, one multi-speaker profile, supplied content, language models for scripts, and speech models for audio. They create an episode and audio under /app/data/podcasts in the container. A retry of a failed episode deletes its record/audio and starts a new job. Inspect the returned job result for the new episode ID.

Back up SurrealDB and /app/data, which contains uploads, podcasts, SQLite checkpoints, and caches. Stored provider keys use the server's OPEN_NOTEBOOK_ENCRYPTION_KEY; changing or losing it can make credentials unreadable. This is not encryption of every stored document.

Raw lines 55 to 67
68## Data boundaries
70Self-hosted storage and local AI inference are separate choices. Cloud models,
71embedding providers, transcription, speech, or external extraction services can
72receive research content. Source ingestion can also fetch public URLs from the
73server. Use only intended source URLs and inspect the selected provider for each
74stage. The password middleware is instance-wide bearer-password protection; it
75does not create per-notebook user permissions.

Data boundaries

Self-hosted storage and local AI inference are separate choices. Cloud models, embedding providers, transcription, speech, or external extraction services can receive research content. Source ingestion can also fetch public URLs from the server. Use only intended source URLs and inspect the selected provider for each stage. The password middleware is instance-wide bearer-password protection; it does not create per-notebook user permissions.

Raw lines 68 to 76
77## Source navigation
79| Upstream location | Responsibility |
80| --- | --- |
81| `api/main.py`, `api/auth.py` | Router mounting, middleware, password checks |
82| `api/models.py`, `api/routers/` | Request/response schemas and endpoints |
83| `api/podcast_service.py` | Podcast submission and job-result contract |
84| `open_notebook/domain/` | Notebook/source/note records and relationships |
85| `open_notebook/graphs/` | Chat, Ask, transformation and processing flows |
86| `open_notebook/utils/context_builder.py` | Source/note context selection |
87| `commands/` | Background jobs |
88| `frontend/` | Next.js client |
89| `docker-compose.yml` | Services and persistent mounts |

Source navigation

Upstream locationResponsibility
api/main.py, api/auth.pyRouter mounting, middleware, password checks
api/models.py, api/routers/Request/response schemas and endpoints
api/podcast_service.pyPodcast submission and job-result contract
open_notebook/domain/Notebook/source/note records and relationships
open_notebook/graphs/Chat, Ask, transformation and processing flows
open_notebook/utils/context_builder.pySource/note context selection
commands/Background jobs
frontend/Next.js client
docker-compose.ymlServices and persistent mounts
Raw lines 77 to 89