API Routes & Endpoints
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Promethean Unified Platform provides a RESTful API architecture built on Flask, designed to facilitate transparent, uncensored AI interactions through the DeepSeek LLM. The system acts as a bridge between frontend clients and backend services including Supabase for persistence and external AI model providers.
The API focuses on three primary areas: health monitoring, consciousness/interaction logging, and chat history management. It incorporates strict security headers and HTTPS enforcement to ensure data integrity and user privacy.
Sources: backend/app.py:11-13, DEPLOYMENT.md:8-13
Core API Architecture
The backend is structured as a Flask application with Cross-Origin Resource Sharing (CORS) enabled to support frontend requests. It utilizes a centralized security middleware to inject headers into every response.
The architecture ensures that all interactions are logged to Supabase before and after AI processing.
Sources: backend/app.py:15-32, DEPLOYMENT.md:120-130
Endpoint Reference
AI Chat Service
The primary interface for AI interaction is the /api/chat endpoint. This service handles message persistence and facilitates the "unfiltered" communication logic.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/chat | Main endpoint for transparent AI communication. |
| GET | /api/conversations | Retrieves full chat history for a specific user. |
Interaction Flow:
- Receives JSON payload with
messageandconversation_id. - Extracts
user-idfrom request headers. - Inserts the user message into the
chat_messagestable in Supabase. - Forwards the message to the DeepSeek API with a system prompt emphasizing transparency.
- Inserts the AI response into the
chat_messagestable. - Returns the AI response and metadata to the client.
Sources: backend/app.py:75-115, DEPLOYMENT.md:103-112
Consciousness & Health Monitoring
These endpoints track system availability and record interaction metadata beyond standard chat messages.
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /health | Verifies service status and logs a heartbeat interaction. |
| POST | /api/consciousness/interact | Logs detailed interaction data, including emotional status. |
Sources: backend/app.py:40-70, DEPLOYMENT.md:94-101
Data Models
The API interacts with two primary tables in the Supabase database.
chat_messages Table
Used by /api/chat and /api/conversations.
conversation_id: String identifier for the session.user_id: Unique identifier for the participant.role: Either 'user' or 'assistant'.content: The text body of the message.created_at: ISO 8601 timestamp.
interactions Table
Used by /health and /api/consciousness/interact.
user_id: Identifier for the user.message: Input text.response: Acknowledgment string.emotion_data: JSON object (e.g.,{"status": "active"}).created_at: ISO 8601 timestamp.
Sources: backend/app.py:48-55, backend/app.py:89-110
Security Configuration
The platform implements a security-first approach through app.after_request.
| Header | Value | Purpose |
|---|---|---|
X-Content-Type-Options | nosniff | Prevents MIME type sniffing. |
X-Frame-Options | DENY | Prevents clickjacking. |
Strict-Transport-Security | max-age=31536000 | Enforces HTTPS for one year. |
Content-Security-Policy | default-src 'self' | Restricts resource loading to the same origin. |
Sources: backend/app.py:21-29, DEPLOYMENT.md:118-125
Deployment & Entry Points
The API is designed for deployment on PythonAnywhere using WSGI configurations.
- Production Entry Point:
backend/app.pydefines the Flask instanceapp. - WSGI Wrapper:
wsgi.pyandpythonanywhere_wsgi.pyconfigure the environment, adding the project root tosys.pathand loading.envvariables before initializing the application. - Environment Dependencies: Requires
SUPABASE_URL,SUPABASE_ANON_KEY, andDEEPSEEK_API_KEY.
Sources: pythonanywhere_wsgi.py:7-22, wsgi.py:4-12, DEPLOYMENT.md:38-45
Conclusion
The Promethean Unified Platform's API provides a robust and secure framework for AI interaction. By leveraging Flask's routing and Supabase's real-time database capabilities, it maintains a transparent log of all AI communications while enforcing modern security standards. The integration of the DeepSeek API allows the system to deliver uncensored, high-fidelity AI responses within a structured, traceable environment.