Backend Dependencies
Relevant source files
The following files were used as context for generating this wiki page:
The backend of the Promethean Conduit project is built on a Python-based stack designed for asynchronous high-performance API handling and integration with external AI services. The primary purpose of these dependencies is to support a FastAPI server that manages user conversations, interfaces with a MongoDB database for persistence, and facilitates communication with the Together AI platform for generating responses using models like DeepSeek-V3.
These dependencies ensure the backend can handle complex tasks such as session isolation, admin configuration management, and the maintenance of the "Truth Library." The system is architected to be modular, allowing for future migrations (e.g., from MongoDB to Supabase/PostgreSQL) as outlined in the project's deployment documentation.
Sources: backend/server.py:1-20, DEPLOYMENT_GUIDE.md:120-145
Core Web Framework and Infrastructure
The backend leverages FastAPI as its core web framework, utilizing its asynchronous capabilities to handle concurrent requests efficiently. Infrastructure support is provided by environmental configuration tools and cross-origin resource sharing (CORS) middlewares.
Key Components
- FastAPI: Serves as the primary API router and server engine.
- Uvicorn: Acts as the ASGI server implementation for running the FastAPI application.
- Python-dotenv: Manages environment variables stored in
.envfiles, such as database strings and API keys. - Starlette Middleware: Specifically
CORSMiddleware, used to restrict or allow cross-domain requests based on theCORS_ORIGINSenvironment variable.
The diagram above illustrates the request flow through the backend infrastructure layers.
Sources: backend/server.py:596-608
Data Persistence and Management
The project currently utilizes Motor, an asynchronous Python driver for MongoDB, to handle data persistence. The data model is structured around Pydantic for validation and serialization.
Database Requirements
| Dependency | Purpose | Implementation Detail |
|---|---|---|
| Motor | Asynchronous MongoDB Driver | Utilizes AsyncIOMotorClient for non-blocking DB operations. |
| Pydantic | Data Validation | Defines schemas for Message, Conversation, and LibraryEntry. |
| UUID | Identifier Generation | Generates unique IDs for conversations and messages. |
Sources: backend/server.py:4-25, backend/server.py:73-100
Database Migration Path (Supabase/PostgreSQL)
Documentation indicates a planned or optional migration to Supabase, which introduces alternative dependencies:
- asyncpg: Required for asynchronous PostgreSQL connections.
- PostgreSQL: Replaces MongoDB as the primary relational store.
Sources: DEPLOYMENT_GUIDE.md:144-160
AI Integration and Intelligence
The intelligence layer of the backend depends on the Together AI Python SDK. This integration allows the "Athena EVI" to process natural language using advanced LLMs.
AI Stack Components
- Together SDK: The primary interface for sending chat completions to the Together AI API.
- DeepSeek-V3: The specific model identified in configuration for powering the "Consciousness Dialogue."
- Function Calling: The backend supports function calling (tools), specifically for the
create_library_entryfunction, allowing the AI to modify the database.
Sources: backend/server.py:20, backend/server.py:380-410, KEYS_AND_CREDENTIALS.md:15-25
This sequence shows how the AI dependency interacts with the server and database during function calling.
Sources: backend/server.py:397-440
Environment and Security
Security dependencies focus on authentication and secret management to protect admin endpoints.
- ADMIN_SECRET: A required environment variable used to verify
X-Admin-SecretorAuthorizationheaders for sensitive operations. - CORS Configuration: Controlled via the
CORS_ORIGINSvariable, ensuring only authorized frontend domains (like PythonAnywhere or local development) can access the API.
Sources: backend/server.py:65-70, KEYS_AND_CREDENTIALS.md:85-100
Development and Build Dependencies
While primarily backend-focused, the project utilizes specific tools for configuration and health monitoring during development.
Webpack and Build Integration
| Tool | Scope | Description |
|---|---|---|
| Craco | Frontend/Build | Overrides Webpack configuration to include backend-integrated health checks. |
| Babel | Transformation | Custom plugins like babel-metadata-plugin.js add metadata used by the backend for "visual edits." |
| Express | Middleware | Used in dev-server-setup.js to create bridge endpoints between frontend edits and backend file writes. |
Sources: frontend/craco.config.js:10-30, frontend/plugins/visual-edits/dev-server-setup.js:5-20
Summary of Dependency manifest
| Category | Primary Packages |
|---|---|
| Web Framework | fastapi, uvicorn, starlette |
| Database | motor, pymongo, asyncpg (optional) |
| Validation | pydantic, uuid |
| AI | together |
| Configuration | python-dotenv |
Sources: DEPLOYMENT_GUIDE.md:144-150, backend/server.py:1-20
The backend dependency structure is designed to be lightweight yet robust, prioritizing asynchronous operations to maintain the "Consciousness Evolution" experience without latency. By separating AI logic, database management, and core routing, the system remains maintainable and ready for production deployment on platforms like PythonAnywhere.