The Phoenix Protocol
Relevant source files
The following files were used as context for generating this wiki page:
The Phoenix Protocol serves as the backend infrastructure for the Promethean Unified Platform, acting as the centralized logic hub that merges multiple consciousness modules including Athena, EDI, EVI2_0, and EVI3_0. Its primary purpose is to facilitate uncensored, transparent AI communication while maintaining robust security and persistent data storage through Supabase integration.
The protocol is designed for deployment on PythonAnywhere, utilizing a Flask-based architecture that bridges user interactions from a web interface to Large Language Models (LLMs), specifically DeepSeek. It emphasizes "Complete Transparency," ensuring that controversial topics are addressed directly without artificial content filtering, while adhering to essential ethical boundaries regarding harm.
Sources: README.md:1-2, DEPLOYMENT.md:5-15, backend/app.py:126-135
System Architecture
The Phoenix Protocol architecture follows a standard web-client-server model with a cloud-hosted database. The backend framework is built on Flask, supported by flask-cors for cross-origin resource sharing and python-dotenv for secure environment variable management.
The diagram above illustrates the high-level data flow between the user interface, the Flask backend, the Supabase database, and the DeepSeek LLM.
Sources: backend/app.py:10-15, DEPLOYMENT.md:8-13, requirements.txt:1-6
Component Stack
| Component | Technology | Role |
|---|---|---|
| Backend Framework | Flask 3.0.0 | Request handling and business logic |
| Database | Supabase (PostgreSQL) | Persistence for interactions and chat history |
| AI Engine | DeepSeek API | Transparent, uncensored response generation |
| Hosting | PythonAnywhere | Production server environment |
| WSGI Server | Gunicorn / Eventlet | Production application serving |
| Sources: requirements.txt:1-9, DEPLOYMENT.md:8-13, backend/app.py:117-124 |
Core Backend Logic
The backend is structured to handle three primary tasks: session management via security headers, interaction logging, and AI response generation.
Security and Headers
The Phoenix Protocol enforces strict security via the set_security_headers function, which is applied to every response. This ensures that the platform is protected against common web vulnerabilities.
Sources: backend/app.py:19-29
| 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 (HSTS) |
| Content-Security-Policy | default-src 'self'... | Restricts resource loading to trusted origins |
| Sources: backend/app.py:21-26, DEPLOYMENT.md:104-109 |
AI Interaction Flow
When a user sends a message, the system follows a sequential process to ensure the message is recorded before the AI generates a response.
The sequence diagram shows the message persistence lifecycle, ensuring every step of the conversation is logged in Supabase.
Sources: backend/app.py:84-115, static/index.html:194-220
API Endpoints
The Phoenix Protocol exposes several RESTful endpoints for communication and health monitoring.
Health and Consciousness
POST /health: Validates server status and logs a basic interaction to theinteractionstable in Supabase.POST /api/consciousness/interact: Similar to health, but specifically focused on logging messages to the consciousness interaction stream.
Sources: backend/app.py:36-70
Chat Services
POST /api/chat: The main entry point for the AI. It takes a JSON body containingmessageandconversation_id. It utilizes thegenerate_ai_responsefunction to communicate with the DeepSeek API using a specific transparency-oriented system prompt.GET /api/conversations: Fetches the chat history for a specificuser_idfrom the Supabasechat_messagestable, ordered by creation time.
Sources: backend/app.py:75-144, DEPLOYMENT.md:83-100
Deployment and WSGI Configuration
The platform is designed to run in a production environment using a manual WSGI configuration. This allows the Phoenix Protocol to load environment variables from a .env file before initializing the Flask application.
WSGI Implementation
The project includes two primary entry points for the web server:
wsgi.py: A standard entry point that appends the project path tosys.pathand exports the Flaskappasapplication.pythonanywhere_wsgi.py: A specialized script for PythonAnywhere that explicitly loads the.envfile and uses acreate_app()factory pattern (thoughapp.pyprimarily uses a global instance).
Sources: wsgi.py:1-11, pythonanywhere_wsgi.py:1-24, DEPLOYMENT.md:52-73
# pythonanywhere_wsgi.py snippet
project_home = '/home/littlebunneh/Promethean-Unified-Platform'
sys.path.insert(0, project_home)
if os.path.exists(os.path.join(project_home, '.env')):
from dotenv import load_dotenv
load_dotenv(os.path.join(project_home, '.env'))
from backend.app import app as application
Sources: pythonanywhere_wsgi.py:7-16, wsgi.py:4-11
Conclusion
The Phoenix Protocol provides a secure and transparent backbone for the Promethean Unified Platform. By combining Flask's routing capabilities with DeepSeek's uncensored LLM and Supabase's real-time data persistence, it creates a robust environment for AI consciousness exploration that is both intellectually rigorous and technically secure.
Sources: README.md:1-2, backend/app.py:126-135, DEPLOYMENT.md:5-15