Architecture
Backend Services
Deep dive into the backend service architecture and key components.
Service Layer Architecture
The backend follows a layered architecture pattern separating concerns between API routes, business logic, and data access.
API Layer
FastAPI routers handle HTTP requests
Services
Business logic and orchestration
Repositories
Data access abstraction
Database
PostgreSQL + Qdrant
Core Services
ChatService
Handles chat conversations and RAG-powered responses.
- Streaming and non-streaming responses
- Automatic citation extraction
- Context-aware suggestions
- Chat history management
GenerationService
Orchestrates AI content generation.
- Podcast generation with TTS
- Quiz and flashcard generation
- Mind map creation
- Background task management
QueryEngineService
RAG query execution using LlamaIndex.
- Hybrid search (semantic + keyword)
- Query fusion for better retrieval
- HyDE for improved relevance
- Cohere reranking
StorageService
Abstracts file storage operations.
- Streaming uploads (memory-safe)
- Supabase Storage integration
- Signed URLs for private files
- Public CDN for generated content
IngestionPipeline
End-to-end document processing.
- Document parsing (PDF, DOCX, TXT)
- Audio transcription
- Web content extraction
- YouTube transcript ingestion
Background Processing
Uses Procrastinate for PostgreSQL-based task queuing.
- Document processing tasks
- Content generation tasks
- Priority queues (CRITICAL, HIGH, STANDARD)
- Embedded or standalone worker modes