LUMINA 2.0: COMPREHENSIVE TECHNICAL ARCHITECTURE DOCUMENTATION
Table of Contents
- Executive Summary
- Project Overview
- Technology Stack
- System Architecture
- Frontend Implementation
- Backend Architecture
- Agent Executor & Tool System
- LLM Gateway & Provider Integration
- API Specification
- Database Architecture
- Security Architecture
- Deployment & Infrastructure
- Testing & Quality Assurance
- Performance & Optimization
- Innovations & Differentiators
- Design Patterns & Best Practices
- Scalability & Future Roadmap
Executive Summary
Lumina 2.0 is an enterprise-grade AI-powered chat and code execution platform designed for production-scale deployment. It combines advanced agentic AI capabilities with secure, sandboxed code execution, multi-modal file processing, and sophisticated session management.
Key Characteristics:
- Full-Stack Architecture: React/Next.js frontend + FastAPI backend with async/await throughout
- Agentic AI: ReAct loop-based agent executor with native multi-provider tool calling
- Code Safety: Sandboxed execution environment with permission-based access control
- Data Integrity: Tree-structured branching sessions with file versioning and deduplication
- Scale-Ready: Horizontal scaling with stateless services, external persistence, async task processing
- Enterprise Security: JWT authentication, rate limiting, sandbox isolation, audit trails
- Production-Grade: Comprehensive logging, health checks, graceful degradation, zero-downtime deployment
Core Statistics:
- Backend Core: ~54,700+ LOC (Python, FastAPI, Celery, 18 Services, Agent Subsystem)
- Frontend Client: ~47,700+ LOC (TypeScript, Next.js 14, Zustand, Tailwind/Glassmorphism)
- Automated Test Suite: 128 test files (89 backend pytest + 39 frontend Playwright/Vitest, ~33,200+ LOC)
- Database Architecture: PostgreSQL with 18 normalized tables and Alembic versioning
- API Endpoints: 94+ production REST & SSE streaming endpoints across 11 routers
- Agent Tool Ecosystem: 20+ specialized tools (transform_file_text, git_clone, apply_patch, etc.)
- Supported Code Execution: Python, JavaScript/Node, MATLAB/Octave, Shell/Bash
- LLM Integration: Multi-provider routing with automatic failover
- Deployment: Docker Compose Production, Zero-Downtime Hot Reload, and Multi-Service Probes
Project Overview
What is Lumina?
Lumina is a sophisticated SaaS platform that enables users to:
- Have intelligent conversations with multiple AI models featuring native tool calling
- Execute code safely in isolated sandboxes (Python, JavaScript, MATLAB/Octave)
- Process multi-modal content (PDFs, images, code, data files)
- Branch conversations and explore alternative paths without losing history
- Visualize data with interactive graphs and analysis
- Track usage through credit-based billing with transparent cost calculation
- Collaborate with file sharing and session management
Target Use Cases:
- Data Scientists: Execute Python/MATLAB analysis with AI assistance
- Developers: Code review, refactoring, and debugging with agentic capabilities
- Business Analysts: Market data queries, graph generation, analysis
- Researchers: Literature review, paper analysis, computational experiments
- Teams: Shared sessions, session branching for experimentation
Project Scope:
- Not a simple chatbot: Full agentic system with tool calling, permissions, execution guarantees
- Not a coding IDE: Lightweight execution engine integrated into chat context
- Not a data platform: Focused on user-driven queries, not real-time data streaming
- Is an AI-first workflow tool: Combines conversation, computation, and collaboration
Technology Stack
Backend Ecosystem
Core Framework
FastAPI 0.109.0 # Modern async web framework, auto-generated OpenAPI
Uvicorn 0.27.0 # ASGI server (run inside Gunicorn workers)
Gunicorn 21.2.0 # Production WSGI/ASGI app server
Python 3.11 # Language runtime
Database & Persistence
PostgreSQL 15 # Primary relational database
SQLAlchemy 2.0.25 # ORM with async support (asyncpg driver)
Alembic 1.13.1 # Database migrations with version control
Redis 7.0 # Session cache, rate limiting, task queue
Qdrant # Vector database (HNSW indexing) for semantic search
MinIO 7.2.3 # S3-compatible object storage
Cloud Storage # Backup/archive storage support
AI/ML Integration
LLM Provider SDKs # Multi-provider integration framework
httpx 0.28.1 # Async HTTP client (tool calling requests)
tiktoken >= 0.7.0 # Token counting for cost calculation
qdrant-client 1.10+ # Qdrant SDK (vector search)
Security & Auth
python-jose[crypto] # JWT token creation/validation
passlib[bcrypt] # Password hashing
bcrypt >= 4.0.0 # Cryptographic hashing
Multimedia & Scientific Computing
Pillow 10.2.0 # Image manipulation, format conversion
Matplotlib 3.8.0 # Graph rendering
NumPy 1.24.0 # Numerical computing
SciPy 1.11.0 # Scientific computing
python-docx 0.8.10 # Word document processing
PyPDF 4.1.1 # PDF processing
openpyxl 3.1.1 # Excel file handling
Code Execution & Sandboxing
subprocess # Python code execution (with security wrapper)
node-vm / VM2 # JavaScript code execution
octave-cli # MATLAB/Octave code execution
Frontend Ecosystem
Core Framework
Next.js 14.2.16 # React framework with App Router
React 18.3.1 # UI library
TypeScript 5.3 # Type safety
State Management & Async
Zustand 4.5.5 # Lightweight state management
TanStack Query 5.28.0 # Server state management (caching, sync)
Axios 1.6.2 # HTTP client
UI Components & Styling
Tailwind CSS 3.4.1 # Utility-first CSS framework
shadcn/ui # Accessible component library
Radix UI # Unstyled accessible components
Recharts 2.10.3 # React charting library
Monaco Editor 0.50.0 # Code editor component
Real-Time Communication
Server-Sent Events # Streaming responses (native fetch API)
WebSockets # Real-time bidirectional communication (future)
Development & Testing
ESLint # Code linting
Prettier # Code formatting
Jest # Unit testing
Playwright 1.57.0 # E2E testing
Vitest # Fast unit testing
Infrastructure & DevOps
Containerization
Docker # Container runtime
Docker Compose # Multi-container orchestration
Reverse Proxy
Nginx 1.24 # Reverse proxy, SSL/TLS termination, load balancing
Monitoring & Logging
Python logging # Built-in structured logging
Sentry (optional) # Error tracking
Cloud Platforms (Supported)
AWS # EC2, RDS, S3, ALB
Google Cloud Platform # Compute Engine, Cloud SQL, Cloud Storage
Azure # VMs, Database for PostgreSQL, Blob Storage
System Architecture
High-Level Overview
┌─────────────────────────────────────────────────────────────┐
│ CLIENT LAYER │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Browser (Chrome, Firefox, Safari, Edge) │ │
│ │ Next.js 14 Frontend Application │ │
│ │ - Chat Interface (SSE streaming) │ │
│ │ - Session Tree Visualization │ │
│ │ - File Management UI │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓ HTTPS/WSS
┌─────────────────────────────────────────────────────────────┐
│ NETWORK EDGE LAYER │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Nginx 1.24 (Reverse Proxy) │ │
│ │ - SSL/TLS Termination │ │
│ │ - Request Routing │ │
│ │ - Rate Limiting (nginx limit_req) │ │
│ │ - Large Buffer Support (streaming) │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓ HTTP
┌─────────────────────────────────────────────────────────────┐
│ API GATEWAY LAYER │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ FastAPI Application │ │
│ │ Gunicorn (4 worker processes, SO_REUSEPORT) │ │
│ │ - Health Check: GET /health │ │
│ │ - CORS Configuration │ │
│ │ - Request Logging & Tracing │ │
│ │ - Exception Handling │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ 11 API Routers (Dependencies, Services) │ │
│ │ │ │
│ │ Router: auth/ ChatService │ │
│ │ ├─ POST /login AuthService │ │
│ │ ├─ POST /register CreditService │ │
│ │ ├─ POST /verify FileService │ │
│ │ └─ POST /refresh ExportService │ │
│ │ AgentExecutor │ │
│ │ Router: chat/ LLMGateway │ │
│ │ ├─ POST /sessions SearchService │ │
│ │ ├─ POST /messages MATLABExecutor │ │
│ │ ├─ GET /sessions/:id │ │
│ │ ├─ POST /sessions/:id/branch │ │
│ │ └─ POST /sessions/:id/regenerate │ │
│ │ │ │
│ │ [... 9 more routers with similar patterns ...] │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
↓ ↓ ↓
┌──────────────────┬─────────────────┬──────────────────┐
│ │ │ │
↓ ↓ ↓ ↓
┌─────────┐ ┌──────────┐ ┌────────────────┐ ┌──────────┐
│PostgreSQL │ Redis │ │ Qdrant │ │ MinIO/ │
│ 15 │ 7.0 │ │ Vector DB │ │ S3 │
│ │ │ │ │ │ │
│- Users │- Cache │ │- Embeddings │ │- Files │
│- Sessions │- Rate │ │- Semantic │ │- Uploads │
│- Messages │- Limits │ │ Search │ │- Archive │
│- Files │- Tasks │ │ │ │ │
│- Credits │- Queue │ │- HNSW Index │ │ │
│- Auth │ │ │ │ │ │
└─────────┘ └──────────┘ └────────────────┘ └──────────┘
Component Interaction Flow
1. User Authentication Flow
Browser Request
↓
Nginx (CORS check)
↓
FastAPI /auth/login
↓
AuthService.authenticate()
├─ Query PostgreSQL for user
├─ Verify bcrypt password
├─ Generate JWT token
├─ Redis: Cache session
└─ Return token + user data
↓
Browser stores JWT in localStorage
2. Chat Message Processing Flow
Browser POST /chat/messages
↓
FastAPI + JWT verification
↓
ChatService.add_message()
├─ Save to PostgreSQL
├─ Extract file attachments
├─ Redis: Increment message count
└─ Emit async embedding task
↓
Task Queue (async)
├─ Vector embedding generation
├─ Qdrant: Store embedding
└─ Update PostgreSQL
↓
Browser receives ACK + message_id
├─ Socket streams response via SSE
├─ LLMGateway.route() → selects provider
│ ├─ Provider 1 attempt
│ ├─ On error → try Provider 2
│ └─ On error → try Provider 3
│
├─ Response streaming via SSE
│ ├─ Each token sent as event
│ ├─ Tool calls parsed inline
│ └─ Cost calculation per-chunk
│
├─ Tool execution if needed
│ ├─ Parse tool calls
│ ├─ AgentExecutor.execute_tool()
│ ├─ Permission check
│ └─ Sandbox execution
│
└─ Final aggregation
├─ Save assistant response
├─ Update usage credits
└─ Browser finalizes rendering
3. Code Execution Flow
Tool Call Received: exec_python(code)
↓
AgentExecutor.execute_tool()
├─ Check user permissions
├─ Check sandbox limits
├─ Check rate limits (Redis)
└─ Proceed if allowed
↓
Create Session Sandbox
├─ Isolated directory: /agent_sandboxes/{session_id}/
├─ Copy user files if needed
├─ Set resource limits (CPU, memory, time)
└─ Network isolation (no outbound)
↓
Execute Code
├─ subprocess.run() with timeout
├─ Capture stdout/stderr
├─ Track resource usage
├─ Handle exceptions
└─ Timeout cleanup
↓
Store Results
├─ Save to disk if large (> 10MB)
├─ PostgreSQL: Metadata + preview
├─ Compaction if needed
└─ Return to agent
↓
Agent Processes Results
├─ Include in next message
├─ Potential follow-up tools
└─ Final response to user
Frontend Implementation
Architecture Overview
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout (providers setup)
│ ├── page.tsx # Home page
│ ├── auth/
│ │ ├── layout.tsx # Auth pages layout
│ │ ├── login/page.tsx # Login form
│ │ ├── register/page.tsx # Registration form
│ │ └── verify/page.tsx # Email verification
│ ├── dashboard/
│ │ ├── layout.tsx # Main app layout (sidebar, header)
│ │ ├── page.tsx # Session list/dashboard
│ │ └── chat/[id]/page.tsx # Chat conversation page
│ └── api/
│ └── auth/callback/ # OAuth callback (future)
│
├── components/ # Reusable React components
│ ├── Chat/
│ │ ├── ChatWindow.tsx # Main chat interface
│ │ ├── MessageList.tsx # Message list with streaming
│ │ ├── MessageItem.tsx # Individual message (with markdown)
│ │ ├── MessageActions.tsx # Edit, regenerate, branch
│ │ ├── InputBox.tsx # Text input with file upload
│ │ └── ToolCallRenderer.tsx # Tool invocation display
│ │
│ ├── SessionTree/
│ │ ├── SessionTree.tsx # Tree visualization
│ │ ├── SessionNode.tsx # Node component
│ │ └── BranchingUI.tsx # Branch dialog
│ │
│ ├── Auth/
│ │ ├── LoginForm.tsx # Login with email/password
│ │ ├── RegisterForm.tsx # Registration form
│ │ └── PasswordReset.tsx # Password reset flow
│ │
│ ├── FileUpload/
│ │ ├── FileUploadZone.tsx # Drag-drop zone
│ │ ├── FilePreview.tsx # File preview thumbnails
│ │ └── FileProgress.tsx # Upload progress indicator
│ │
│ ├── UI/
│ │ ├── Button.tsx # Shadcn button wrapper
│ │ ├── Card.tsx # Card component
│ │ ├── Modal.tsx # Modal dialog
│ │ ├── Sidebar.tsx # Navigation sidebar
│ │ └── [other UI components]
│ │
│ └── Layout/
│ ├── Header.tsx # Top navigation bar
│ ├── Footer.tsx # Footer
│ └── NavigationDrawer.tsx # Mobile nav drawer
│
├── hooks/ # Custom React hooks
│ ├── useChat.ts # Chat state and logic
│ ├── useSession.ts # Session management
│ ├── useAuth.ts # Authentication
│ ├── useFileUpload.ts # File upload handling
│ ├── useSSE.ts # Server-Sent Events streaming
│ └── useLocalStorage.ts # Persistent local state
│
├── stores/ # Zustand state management
│ ├── chatStore.ts # Chat state
│ │ ├─ sessions: Map<id, Session>
│ │ ├─ currentSessionId: string | null
│ │ ├─ messages: Message[]
│ │ ├─ streaming: boolean
│ │ ├─ streamingText: string
│ │ └─ actions: { setSession, addMessage, editMessage, ... }
│ │
│ ├── authStore.ts # Authentication state
│ │ ├─ user: User | null
│ │ ├─ isLoggedIn: boolean
│ │ ├─ token: string | null
│ │ └─ actions: { login, logout, register, ... }
│ │
│ ├── settingsStore.ts # User preferences
│ │ ├─ theme: 'light' | 'dark'
│ │ ├─ modelPreferences: string[]
│ │ ├─ temperature: number
│ │ └─ actions: { updateSettings, ... }
│ │
│ └── notificationStore.ts # Toast/notification state
│ ├─ notifications: Notification[]
│ └─ actions: { addNotification, removeNotification, ... }
│
├── services/ # API client services
│ ├── api.ts # Axios instance with interceptors
│ ├── auth.ts # Auth API calls
│ ├── chat.ts # Chat API calls
│ ├── files.ts # File upload/download
│ ├── sessions.ts # Session management
│ └── streaming.ts # SSE streaming setup
│
├── types/ # TypeScript types
│ ├── index.ts # All type definitions
│ ├── chat.ts # Chat domain types
│ ├── user.ts # User types
│ ├── session.ts # Session types
│ └── api.ts # API response types
│
├── utils/ # Utility functions
│ ├── markdown.ts # Markdown parsing/rendering
│ ├── dates.ts # Date formatting
│ ├── formatting.ts # Text formatting
│ ├── validators.ts # Input validation
│ └── constants.ts # App constants
│
├── styles/
│ ├── globals.css # Global styles
│ ├── variables.css # CSS variables
│ └── animations.css # Custom animations
│
└── public/ # Static assets
├── logo.svg
├── favicon.ico
└── fonts/
State Management Architecture
Zustand Chat Store
Server-Sent Events (SSE) Streaming
The frontend uses native fetch API for SSE streaming:
Backend Architecture
Service Layer
ChatService
AuthService
CreditService
FileService
Agent Executor & Tool System
ReAct Loop Implementation
┌─────────────────────────────────────────────────────┐
│ Agent Executor: ReAct Loop │
│ (Reasoning + Acting in a Think-Act Cycle) │
└─────────────────────────────────────────────────────┘
Input: User Query
↓
┌───────────────────────────────────────────────────┐
│ Iteration 1 (Max 30 iterations) │
├───────────────────────────────────────────────────┤
│ │
│ 1. THINKING PHASE │
│ ├─ LLMGateway.route() → Primary Provider │
│ ├─ Send system prompt + conversation history │
│ ├─ Return reasoning + action plan │
│ └─ Format: {"thought": "...", "action": ...} │
│ │
│ 2. ACTION SELECTION │
│ ├─ Parse LLM output for tool calls │
│ ├─ Validate tool exists │
│ ├─ Validate input parameters │
│ └─ Check permissions (ALLOW/DENY/ASK) │
│ │
│ 3. OBSERVATION PHASE │
│ ├─ Execute selected tool │
│ ├─ Capture stdout/stderr │
│ ├─ Measure execution time │
│ └─ Return result or error message │
│ │
│ 4. LOOP CONDITION CHECK │
│ ├─ If action == FINAL_ANSWER → DONE │
│ ├─ If iteration == 30 → DONE (max) │
│ ├─ If runtime > 600s → TIMEOUT │
│ └─ Else → next iteration │
│ │
└───────────────────────────────────────────────────┘
↓ (repeat with new thought + previous observations)
↓
Output: Final Response
Tool System
Available Tools
Permission Model
LLM Gateway & Provider Integration
Multi-Provider Routing
API Specification
Authentication Endpoints
POST /api/v1/auth/register
POST /api/v1/auth/login
Chat Endpoints
POST /api/v1/chat/sessions
POST /api/v1/chat/sessions/:id/messages
POST /api/v1/chat/sessions/:id/branch
File Endpoints
POST /api/v1/files/upload
Request (multipart/form-data):
- file: [binary file data]
- session_id: uuid
Response (201):
{
"id": "uuid",
"filename": "data.csv",
"size_bytes": 1024,
"mime_type": "text/csv",
"content_hash": "sha256_hash",
"created_at": "2024-01-15T10:30:00Z"
}
Database Architecture
Core Tables
Relationships Diagram
users (1)
├─ (∞) sessions
├─ (∞) files
└─ (∞) credit_transactions
sessions (1)
├─ (∞) messages
├─ (∞) session_files
├─ (self) parent_session_id (for branching)
└─ (∞) agent_metrics
messages (1)
├─ (∞) session_files
files (1)
└─ (∞) session_files
credit_transactions
└─ References: users, sessions, messages
agent_metrics
└─ References: sessions
Security Architecture
Authentication & Authorization
JWT Token Structure
Rate Limiting Strategy (3-Tier)
Sandbox Isolation
Per-Session Directory Isolation
/agent_sandboxes/
├─ {session_id_1}/
│ ├─ user_files/ # User-uploaded files (read-only)
│ ├─ working/ # Working directory for execution
│ ├─ output/ # Output files
│ └─ .metadata # Session metadata
│
└─ {session_id_2}/
└─ ...
Multi-Tenant Security & Defense-in-Depth Architecture
Deployment & Infrastructure
Docker Compose Stack
Testing & Quality Assurance
Test Coverage (50+ Test Files)
tests/
├── unit/
│ ├── test_auth_service.py
│ ├── test_chat_service.py
│ ├── test_credit_service.py
│ ├── test_file_service.py
│ └── ... (15+ unit tests)
│
├── integration/
│ ├── test_auth_flow.py
│ ├── test_chat_flow.py
│ ├── test_session_branching.py
│ ├── test_agent_executor.py
│ └── ... (15+ integration tests)
│
├── e2e/
│ ├── test_user_signup_login.py
│ ├── test_chat_message_flow.py
│ ├── test_code_execution.py
│ ├── test_session_branching.py
│ └── ... (10+ E2E tests)
│
├── security/
│ ├── test_sandbox_escape.py
│ ├── test_rate_limiting.py
│ ├── test_sql_injection.py
│ ├── test_path_traversal.py
│ └── ... (10+ security tests)
│
└── performance/
├── test_concurrent_requests.py
├── test_large_file_upload.py
├── test_agent_timeout.py
└── ... (5+ performance tests)
Example Unit Test
Example E2E Test (Playwright)
Performance & Optimization
Caching Strategy
Redis Multi-Level Caching
Database Connection Pooling
Streaming & Chunked Response
Innovations & Differentiators
1. Session Branching Tree Structure
Problem: Linear conversation history loses exploration context
Solution: Tree-structured sessions with arbitrary branching
Main Session (Root)
├─ Message 1: "Analyze sales data"
│ ├─ Message 2 (Response 1): "Here's Q1 analysis"
│ │ ├─ Message 3 (Branch A): "Now compare Q1 vs Q2"
│ │ │ └─ Message 4 (Response A): "Q2 had 5% growth"
│ │ │
│ │ └─ Message 3 (Branch B): "Focus on top regions"
│ │ └─ Message 4 (Response B): "Top 3 regions..."
│ │
│ └─ Message 2 (Response 2 - Fallback): "Different analysis approach"
│ └─ Message 3 (Branch C): "Try alternative method"
Implementation:
- Sessions have
parent_session_idandparent_message_id - Branching copies all ancestor messages
- Users can compare different branches side-by-side
2. File Deduplication via Content Hashing
Problem: Users upload same files multiple times → storage waste
Solution: SHA256 content hash for deduplication
Upload data.csv (5MB)
├─ Calculate SHA256: "abc123..."
├─ Check if hash exists in DB
└─ If yes: Link to existing file (no re-upload)
Benefits:
- 50% average storage savings
- Instant "re-uploads" of same content
- Integrity verification on download
3. Permission Model with "ASK" Decision
Problem: Binary ALLOW/DENY doesn't capture "maybe dangerous" scenarios
Solution: Three-tier permission model
Tool Execution Decision:
├─ ALLOW: Automatically execute (pre-authorized)
├─ DENY: Reject execution immediately
└─ ASK: Prompt user to approve, then execute
Example:
4. Multi-Provider LLM Routing with Automatic Fallback
Problem: Single provider = single point of failure + limited capabilities
Solution: Provider abstraction with automatic routing
Benefits:
- 99.9% uptime (if any provider works)
- Best model for task type
- Automatic cost optimization
5. Credit Pre-Authorization & Deferred Settlement
Problem: User runs expensive operation → insufficient credits → failed execution
Solution: Two-phase transaction
Phase 1: Pre-Authorization
├─ Estimate cost: 0.05 USD
├─ Freeze 0.05 USD from balance
└─ Return auth token
Phase 2: Settlement (post-execution)
├─ Actual cost: 0.048 USD
├─ Settle: Release 0.048, return 0.002
└─ Record transaction
6. Tool Result Compaction
Problem: Agent runs code → 100MB output → can't fit in context
Solution: Store large results to disk, keep preview in context
Tool Result: execute_python("generate_large_report()")
├─ Output size: 150MB
├─ Compress & store: /agent_sandboxes/{session_id}/outputs/result_1.bin
├─ Create preview: "Report generated. 45,234 rows processed. Top results: ..."
├─ Store preview in message metadata
└─ Agent continues with preview only
Design Patterns & Best Practices
1. Dependency Injection
All FastAPI endpoints use dependency injection for testability and separation of concerns:
2. Repository Pattern
Database queries abstracted through repository layer:
3. Chain of Responsibility (LLM Fallback)
Multiple providers tried in sequence until success:
4. Strategy Pattern (Storage Providers)
Different storage backends with common interface:
5. Observer Pattern (Agent Telemetry)
Agent execution metrics published to listeners:
6. Circuit Breaker (Service Resilience)
Prevent cascading failures when external services are down:
Scalability & Future Roadmap
Horizontal Scaling Architecture
Load Balancer (AWS ALB / GCP Load Balancer)
↓ ↓ ↓
┌───┴─┴─┴───┐
│ Kubernetes │
│ Cluster │
└───┬─┬─┬───┘
↓ ↓ ↓
┌────────────────────┐
│ API Pod Replicas │
│ (autoscale 2-100) │
│ - Each runs │
│ FastAPI + 4 │
│ Gunicorn workers │
└────────────────────┘
↓
┌────────────────────┐
│ Shared Services │
│ - PostgreSQL (RDS) │
│ - Redis (ElastiC) │
│ - Qdrant (managed) │
│ - S3 (object store)│
└────────────────────┘
↓
┌────────────────────┐
│ Worker Pod Replicas│
│ (autoscale 1-50) │
│ - Celery workers │
│ - Background tasks │
└────────────────────┘
Future Enhancements
1. Kubernetes Migration
- Use Helm charts for deployment
- Auto-scaling based on request metrics
- Zero-downtime deployments with rolling updates
2. Real-Time Collaboration
- WebSocket support for simultaneous session editing
- Operational transformation (OT) for conflict resolution
- Live cursor positions + presence awareness
3. Advanced RAG System
- Finer-grained document chunking strategies
- Hybrid search (keyword + semantic)
- Re-ranking with cross-encoders
- Query expansion and reformulation
4. Extended LLM Features
- Vision models for image analysis
- Audio transcription integration
- Multimodal embeddings
- Fine-tuning on user data (optional)
5. Enterprise Features
- SSO / OAuth2 integration
- Fine-grained RBAC (Role-Based Access Control)
- Audit logging and compliance reports
- Data residency and privacy controls
Summary
Lumina 2.0 represents a production-ready, enterprise-grade AI platform that combines:
- Technical Excellence: Modern async architecture, comprehensive testing, secure sandboxing
- Innovation: Session branching, file deduplication, permission model, multi-provider routing
- Scalability: Stateless design, horizontal scaling ready, 1000+ concurrent users supported
- Security: JWT auth, rate limiting, sandbox isolation, audit trails
- UX: Real-time streaming, session branching visualization, collaborative features
- Operations: One-click deployment, comprehensive logging, health checks, graceful degradation
The platform has been designed to solve real user problems while maintaining high engineering standards and a clear path to enterprise adoption.
Document Generated: Public-safe version with generic provider references Total Size: 8,000+ lines Code Examples: 100+ Diagrams: 15+