Architecture
Database Schema
Overview of the database models and relationships.
Database Overview
Uses SQLModel (Pydantic + SQLAlchemy) with PostgreSQL as the primary database and Qdrant for vector storage.
Core Models
User
Represents a user in the system. Users are provisioned automatically on first authentication.
Fields:
- id (UUID) - Primary key
- email - Unique email address
- is_active - Account status
- created_at - Registration timestamp
Notebook
A container for documents, chat history, and generated content.
Fields:
- id (UUID) - Primary key
- user_id (UUID) - Foreign key to User
- title - Notebook name
- settings (JSON) - RAG configuration
Document
Represents an uploaded file or external source.
Fields:
- id (UUID) - Primary key
- notebook_id (UUID) - Foreign key to Notebook
- filename - Original file name
- status - PENDING, PROCESSING, COMPLETED, FAILED
- chunk_count - Number of text chunks
ChatMessage
Individual messages in a notebook's chat history.
Fields:
- id (UUID) - Primary key
- notebook_id (UUID) - Foreign key to Notebook
- role - USER or ASSISTANT
- content - Message text
GeneratedContent
AI-generated content like podcasts, quizzes, flashcards, and mind maps.
Fields:
- id (UUID) - Primary key
- notebook_id (UUID) - Foreign key to Notebook
- content_type - PODCAST, QUIZ, FLASHCARD, MINDMAP
- status - Processing state
- content (JSON) - Generated content data
- audio_url - URL for generated audio
Relationships
- User → Notebooks (one-to-many)
- Notebook → Documents (one-to-many, cascade delete)
- Notebook → ChatMessages (one-to-many, cascade delete)
- Notebook → GeneratedContent (one-to-many, cascade delete) Document → Citations
- (one-to-many)
- ChatMessage → Citations (one-to-many)
Vector Store (Qdrant)
Qdrant stores document embeddings for semantic search. Each vector includes metadata for filtering by user_id, notebook_id, and document_id.