An AI-powered chatbot with a Humble Scholar persona, focused on Eudaimonia (human flourishing) and personal growth. Built with a Python (Flask) backend and vanilla JavaScript frontend following Modular Minimalist and Wabi-Sabi design principles.
graph TB
subgraph Frontend ["π₯οΈ Frontend (Vanilla JS/HTML/CSS)"]
UI["index.html<br/>Semantic HTML5"]
CSS["style.css<br/>Design System"]
JS["app.js<br/>Chat Logic"]
end
subgraph Backend ["βοΈ Backend (Python/Flask)"]
APP["app.py<br/>Flask Server"]
CFG["config.py<br/>Configuration"]
ENV[".env<br/>Secrets"]
end
subgraph External ["βοΈ External Services"]
OAI["OpenRouter API<br/>Gemma 4 31B (free)"]
end
UI --> JS
CSS --> UI
JS -- "POST /chat<br/>Fetch API" --> APP
JS -- "GET /health" --> APP
CFG --> APP
ENV --> CFG
APP -- "Chat Completions" --> OAI
OAI -- "Structured Response" --> APP
APP -- "JSON Response" --> JS
style Frontend fill:#FAF3E0,stroke:#D4AF37,color:#1A1A2E
style Backend fill:#004B8D,stroke:#D4AF37,color:#F2F2F2
style External fill:#1A1A2E,stroke:#D4AF37,color:#F2F2F2
sequenceDiagram
participant U as User
participant FE as Frontend (JS)
participant BE as Backend (Flask)
participant AI as OpenRouter API
U->>FE: Types message & presses Enter
FE->>FE: Validate input, show typing indicator
FE->>BE: POST /chat { message, history }
BE->>BE: Validate request, build prompt
BE->>AI: chat.completions.create()
AI-->>BE: Completion response
BE-->>FE: { reply, model, usage }
FE->>FE: Render markdown, hide indicator
FE-->>U: Display formatted response
Note over FE,BE: Error path
BE--xFE: { error, code, suggestion }
FE->>FE: Show error with retry button
flowchart LR
REQ[Incoming Request] --> VAL{Valid JSON?}
VAL -- No --> E1["400: VALIDATION_INVALID_JSON"]
VAL -- Yes --> MSG{Has message?}
MSG -- No --> E2["400: VALIDATION_EMPTY_MESSAGE"]
MSG -- Yes --> KEY{API key set?}
KEY -- No --> E3["503: CONFIG_MISSING_API_KEY"]
KEY -- Yes --> API[Call OpenRouter API]
API --> R1{Rate limited?}
R1 -- Yes --> E4["429: API_RATE_LIMIT"]
R1 -- No --> R2{Auth error?}
R2 -- Yes --> E5["401: API_AUTH_ERROR"]
R2 -- No --> R3{API error?}
R3 -- Yes --> E6["502: API_SERVICE_ERROR"]
R3 -- No --> OK["200: Success Response"]
style OK fill:#22c55e,color:#000
style E1 fill:#ef4444,color:#fff
style E2 fill:#ef4444,color:#fff
style E3 fill:#ef4444,color:#fff
style E4 fill:#ef4444,color:#fff
style E5 fill:#ef4444,color:#fff
style E6 fill:#ef4444,color:#fff
Athena/
βββ backend/
β βββ app.py # Flask application with /chat and /health endpoints
β βββ config.py # Centralized configuration from environment variables
β βββ requirements.txt # Pinned Python dependencies
β βββ .env.example # Template for environment variables
β βββ .env # Your local secrets (git-ignored)
βββ frontend/
β βββ index.html # Main HTML with semantic structure
β βββ css/
β β βββ style.css # Complete design system (tokens, components, responsive)
β βββ js/
β βββ app.js # Chat logic, API communication, markdown rendering
βββ .gitignore # Git ignore rules
βββ README.md # This file
- Python 3.10+
- pip (Python package manager)
- OpenRouter API key (Get one free here)
git clone https://github.com/rajdangi31/Athena
cd Athena# Create the virtual environment
python -m venv venv
# Activate it
# Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# Windows (CMD):
.\venv\Scripts\activate.bat
# macOS / Linux:
source venv/bin/activatepip install -r backend/requirements.txt# Copy the template
cp backend/.env.example backend/.env
# Edit backend/.env and add your OpenRouter API key
# OPENROUTER_API_KEY=sk-or-v1-your-actual-key-herecd backend
python app.pyYou should see:
ποΈ Athena is listening on http://0.0.0.0:5000
Open frontend/index.html directly in your browser, or serve it with any static file server:
# Option A: Open directly
start frontend/index.html # Windows
open frontend/index.html # macOS
# Option B: Python HTTP server
cd frontend
python -m http.server 3000
# Then visit http://localhost:3000Health check endpoint for monitoring.
Response:
{
"status": "healthy",
"model": "google/gemma-4-31b-it:free",
"api_configured": true
}Send a message to the Humble Scholar AI.
Request Headers:
Content-Type: application/json
Request Body:
{
"message": "How should I design a real-time notification system?",
"history": [
{ "role": "user", "content": "What is event-driven architecture?" },
{ "role": "assistant", "content": "Event-driven architecture is a design pattern..." }
]
}| Field | Type | Required | Description |
|---|---|---|---|
message |
string |
β Yes | The user's current message |
history |
array |
β No | Previous conversation turns (max 20 retained) |
Success Response (200):
{
"reply": "## Real-Time Notification Architecture\n\n**Assess**: You're looking to build...",
"model": "google/gemma-4-31b-it:free",
"usage": {
"prompt_tokens": 342,
"completion_tokens": 512,
"total_tokens": 854
}
}Error Response (4xx/5xx):
{
"error": true,
"code": "API_RATE_LIMIT",
"message": "The AI service is currently rate-limited.",
"suggestion": "Please wait a moment and try your request again. Rate limits typically reset within 60 seconds."
}| Code | HTTP Status | Description |
|---|---|---|
VALIDATION_INVALID_JSON |
400 | Request body is not valid JSON |
VALIDATION_EMPTY_MESSAGE |
400 | No message provided |
CONFIG_MISSING_API_KEY |
503 | Server API key not configured |
API_RATE_LIMIT |
429 | OpenRouter rate limit exceeded |
API_AUTH_ERROR |
401 | Invalid or expired API key |
API_SERVICE_ERROR |
502 | OpenRouter returned an error |
INTERNAL_SERVER_ERROR |
500 | Unhandled server exception |
NOT_FOUND |
404 | Endpoint does not exist |
METHOD_NOT_ALLOWED |
405 | Wrong HTTP method |
The chatbot uses a meticulously crafted system prompt anchored in Eudaimonia:
| Section | Purpose |
|---|---|
### ROLE ### |
Defines the AI as Athena, a companion in the pursuit of Eudaimonia |
### TONE ### |
Warm, intellectually curious, and grounded (avoids grand language) |
### CORE MISSION ### |
Provides rigorous architectural advice tied back to human flourishing |
### RESPONSE STRUCTURE ### |
Listen (Acknowledge), Reflect (Insight), and Flourish (Growth thought) |
The full prompt is defined in config.py and can be customized via the SYSTEM_PROMPT constant.
- Modular Minimalist Theme β Book-Paper White, Linen White, Muted Sage Green, and Deep Charcoal palette
- Quiet Grid Layout β Generous whitespace, clean card components, and subtle low-contrast borders
- Reflective UI Interactions β Breath-like animations (600ms ease-in-out) and a steady pulsed typing indicator
- Subtle Eudaimonic Cues β A daily virtue quote gently anchoring the chat space
- Markdown Rendering β Lightweight renderer for headers, code blocks, lists, bold, italic
- Conversation History β Maintains context across the session (up to 20 turns)
- Seed Thoughts β Pre-built minimalist pill-shaped starter questions for architectural dialogue
- "A Momentary Pause" Modal β Context-aware error dialog with a gentle, apologetic tone
- API keys are never committed to version control (
.envis git-ignored) - Input is validated and sanitized on both frontend and backend
- CORS is configurable via the
CORS_ORIGINSenvironment variable - Conversation history is capped at 20 turns to prevent prompt injection attacks
- HTML output is escaped before DOM insertion to prevent XSS
This project was created for Software Engineering β Spring 2026.