scientific-skills/open-notebook/references/architecture.md
Open Notebook is built as a modern Python web application with a clear separation between frontend and backend, using Docker for deployment.
┌─────────────────────────────────────────────────────┐
│ Docker Compose │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
│ │ Next.js │ │ FastAPI │ │ SurrealDB │ │
│ │ Frontend │──│ Backend │──│ │ │
│ │ (port 8502) │ │ (port 5055) │ │ (port 8K) │ │
│ └──────────────┘ └──────────────┘ └───────────┘ │
│ │ │
│ ┌─────┴─────┐ │
│ │ LangChain │ │
│ │ Esperanto │ │
│ └─────┬─────┘ │
│ │ │
│ ┌───────────┼───────────┐ │
│ │ │ │ │
│ ┌───┴───┐ ┌───┴───┐ ┌───┴───┐ │
│ │OpenAI │ │Claude │ │Ollama │ ... │
│ └───────┘ └───────┘ └───────┘ │
└─────────────────────────────────────────────────────┘
The REST API is built with FastAPI and organized into routers:
SurrealDB serves as the primary data store, providing both document and relational capabilities:
AI features are powered by LangChain with the Esperanto multi-provider library:
prompts/ directoryEsperanto provides a unified interface to 16+ AI providers:
The user interface is a React application built with Next.js:
Upload/URL → Source Record Created → Processing Queue
│
┌──────────┼──────────┐
▼ ▼ ▼
Text Embedding Metadata
Extraction Generation Extraction
│ │ │
└──────────┼──────────┘
▼
Source Updated
(searchable)
User Message → Build Context (sources + notes)
│
▼
LangGraph State Machine
│
├─ Retrieve relevant context
├─ Format prompt with citations
└─ Stream LLM response
│
▼
Response with
source citations
Notebook Content → Episode Profile → Script Generation (LLM)
│
▼
Speaker Assignment
│
▼
Text-to-Speech
(per segment)
│
▼
Audio Assembly
│
▼
Episode Record
+ Audio File
open-notebook/
├── api/ # FastAPI REST API
│ ├── main.py # App setup, middleware, routers
│ ├── routers/ # Route handlers (20 modules)
│ ├── models.py # Pydantic request/response models
│ └── auth.py # Authentication middleware
├── open_notebook/ # Core library
│ ├── ai/ # AI integration (LangChain, Esperanto)
│ ├── database/ # SurrealDB operations
│ ├── domain/ # Domain models and business logic
│ ├── graphs/ # LangGraph chat and processing graphs
│ ├── podcasts/ # Podcast generation pipeline
│ └── utils/ # Shared utilities
├── frontend/ # Next.js React application
├── prompts/ # AI prompt templates
├── tests/ # Test suite
└── docker-compose.yml # Deployment configuration