A full-featured Claude-style AI chat application with multi-provider support, real-time streaming, and token usage tracking.
Maya is now a multi-tenant B2B SaaS platform. See the docs below.
| Doc | Purpose |
|---|---|
docs/ARCHITECT.md |
Architecture, multi-tenancy model, design tokens |
docs/AGENTS.md |
Guidance for AI coding agents working in this repo |
docs/SKILLS.md |
Index of skills + design knowledge |
docs/progress.md |
Live progress log — read this to resume work |
docs/phase-b-plan.md |
Phase B work order — Claude features + B2B services |
backend/README.md |
Backend setup, config, API reference, multi-tenancy |
Skills (single consolidated folder): skills/ — maya-chat-setup, maya-chat-feature, frontend-design.
- Real-time streaming via WebSocket
- Multi-provider support — OpenAI, Anthropic, OpenRouter, 9Router, Surplus Intelligence
- Message history with full conversation persistence
- File upload support for images, PDFs, and documents
- Artifacts panel — rendered code blocks, HTML previews, SVG, JSON
- Projects — organize conversations with custom system prompts
- Memory — persistent context that carries across conversations
- Skills — reusable prompt templates with
{{message}}placeholder - Analytics dashboard — token usage, cost breakdown, daily trends
- Per-request token logging with cost calculation
- Cost breakdown by provider and model
- Daily usage trends over 30 days
- 9Router integration for free provider routing and RTK compression
| Layer | Technology |
|---|---|
| Backend | Python, FastAPI, SQLite, WebSocket |
| Frontend | React, Vite, TypeScript, Tailwind CSS |
| State | Zustand, React Query |
| Styling | Tailwind CSS with custom warm theme (Claude-inspired) |
| LLM | Multi-provider (OpenAI, Anthropic, OpenRouter, 9Router, Surplus) |
- Python 3.10+
- Node.js 18+
- npm or yarn
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your API keys
# Run server
uvicorn app.main:app --reloadServer starts at http://localhost:8000
cd frontend
npm install
npm run devApp available at http://localhost:5173
| Variable | Description | Default |
|---|---|---|
DEFAULT_PROVIDER |
LLM provider (openai, anthropic, openrouter, 9router, surplus) | openai |
DEFAULT_MODEL |
Default model to use | gpt-4o |
OPENAI_API_KEY |
OpenAI API key | — |
ANTHROPIC_API_KEY |
Anthropic API key | — |
OPENROUTER_API_KEY |
OpenRouter API key | — |
NINE_ROUTER_ENABLED |
Enable 9Router local proxy | true |
NINE_ROUTER_URL |
9Router proxy URL | http://localhost:20128 |
SURPLUS_INTELLIGENCE_ENABLED |
Enable Surplus Intelligence | false |
SURPLUS_INTELLIGENCE_API_KEY |
Surplus Intelligence API key | — |
TRACK_COSTS |
Enable token/cost tracking | true |
COST_ALERT_THRESHOLD |
Daily cost alert threshold ($) | 5.0 |
9Router routes requests to free providers and tracks usage.
# Run via npx
npx 9router
# Or via Docker
docker run -p 20128:20128 decolua/9routerDashboard: http://localhost:20128
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/api/v1/projects |
List projects |
POST |
/api/v1/projects |
Create project |
DELETE |
/api/v1/projects/{id} |
Delete project |
GET |
/api/v1/chat/conversations |
List conversations |
POST |
/api/v1/chat/conversations |
Create conversation |
GET |
/api/v1/chat/conversations/{id}/messages |
Get messages |
DELETE |
/api/v1/chat/conversations/{id} |
Delete conversation |
GET |
/api/v1/memory |
List memories |
POST |
/api/v1/memory |
Add memory |
DELETE |
/api/v1/memory/{id} |
Delete memory |
GET |
/api/v1/skills |
List skills |
POST |
/api/v1/skills |
Create skill |
DELETE |
/api/v1/skills/{id} |
Delete skill |
POST |
/api/v1/files/upload |
Upload file |
GET |
/api/v1/analytics/usage/today |
Today's usage |
GET |
/api/v1/analytics/usage/daily |
Daily trends |
GET |
/api/v1/analytics/usage/summary |
Usage summary |
| Endpoint | Description |
|---|---|
/ws/chat |
Real-time streaming chat |
┌─────────────────────────────────────────────────────────────┐
│ Frontend (React + Vite + TypeScript + Tailwind) │
│ ┌────────────┬────────────────────────────────────────┐ │
│ │ Sidebar │ Pages: Chat / Projects / Memory / ... │ │
│ │ Navigation │ ┌──────────────────────────────────┐ │ │
│ │ New Chat │ │ Messages + Artifacts │ │ │
│ │ Convos │ └──────────────────────────────────┘ │ │
│ │ │ [Input Area] │ │
│ └────────────┴────────────────────────────────────────┘ │
└─────────────────────────┬───────────────────────────────────┘
│ WebSocket + REST
┌─────────────────────────┴───────────────────────────────────┐
│ Backend (FastAPI + SQLite) │
│ ┌──────────┬──────────┬──────────┬──────────┐ │
│ │ Chat │ Memory │ Skills │ Analytics│ │
│ │ Service │ Service │ Service │ Service │ │
│ └────┬─────┴────┬─────┴────┬─────┴────┬─────┘ │
│ │ │ │ │ │
│ ┌────┴──────────┴──────────┴──────────┴────┐ │
│ │ LLM Service │ │
│ │ (OpenAI / Anthropic / OpenRouter / │ │
│ │ 9Router / Surplus Intelligence) │ │
│ └───────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
│ projects │────<│ conversations │────<│ messages │
└──────────────┘ └──────────────────┘ └──────────────┘
│ │
│ ▼
│ ┌──────────────┐
│ │ token_usage │
│ └──────────────┘
▼
┌──────────────┐
│ files │
└──────────────┘
┌──────────────┐ ┌──────────────┐
│ memories │ │ skills │
└──────────────┘ └──────────────┘
| Provider | Model | Input | Output |
|---|---|---|---|
| OpenAI | GPT-4o | $2.50 | $10.00 |
| OpenAI | GPT-4o Mini | $0.15 | $0.60 |
| Anthropic | Claude Sonnet 4 | $3.00 | $15.00 |
| Anthropic | Claude Opus 4 | $15.00 | $75.00 |
| OpenRouter | Varies | $2.50* | $10.00* |
| 9Router | Free tier | $0.00 | $0.00 |
| Surplus | Spot market | $0.50* | $2.00* |
*Approximate. Actual pricing varies by model and market conditions.
maya-chat/
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ ├── routes/
│ │ │ │ ├── analytics.py # Usage tracking endpoints
│ │ │ │ ├── chat.py # Conversation CRUD
│ │ │ │ ├── files.py # File upload
│ │ │ │ ├── memory.py # Memory management
│ │ │ │ ├── projects.py # Project CRUD
│ │ │ │ └── skills.py # Skill templates
│ │ │ └── websocket/
│ │ │ └── chat.py # WebSocket streaming
│ │ ├── core/
│ │ │ └── config.py # Settings & env vars
│ │ ├── db/
│ │ │ └── database.py # SQLite schema & connection
│ │ ├── models/
│ │ │ └── schemas.py # Pydantic models
│ │ ├── services/
│ │ │ ├── llm.py # Multi-provider LLM service
│ │ │ ├── memory.py # Memory context builder
│ │ │ └── token_tracker.py # Cost calculation & tracking
│ │ └── main.py # FastAPI app entry
│ ├── requirements.txt
│ └── .env.example
├── frontend/
│ ├── src/
│ │ ├── api/
│ │ │ └── client.ts # REST API client
│ │ ├── components/
│ │ │ ├── ArtifactRenderer.tsx # Code/SVG/HTML/JSON display
│ │ │ ├── ChatInput.tsx # Message input area
│ │ │ ├── ChatMessage.tsx # Individual message bubble
│ │ │ ├── CodeBlock.tsx # Code with copy button
│ │ │ ├── Layout.tsx # App shell
│ │ │ └── Sidebar.tsx # Navigation sidebar
│ │ ├── hooks/
│ │ │ └── useWebSocket.ts # WebSocket hook
│ │ ├── pages/
│ │ │ ├── AnalyticsPage.tsx # Usage dashboard
│ │ │ ├── ChatPage.tsx # Main chat interface
│ │ │ ├── MemoryPage.tsx # Memory management
│ │ │ ├── ProjectsPage.tsx # Project management
│ │ │ ├── SettingsPage.tsx # App settings
│ │ │ └── SkillsPage.tsx # Skill templates
│ │ ├── types/
│ │ │ └── index.ts # TypeScript interfaces
│ │ ├── App.tsx # Routes
│ │ ├── index.css # Global styles + theme
│ │ └── main.tsx # React entry
│ ├── index.html
│ ├── package.json
│ ├── tsconfig.json
│ └── vite.config.ts
├── .gitignore
└── README.md
# Backend
cd backend
pytest
# Frontend
cd frontend
npm run test# Frontend build
cd frontend
npm run build
# Serve with any static server
npm run preview- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License — see LICENSE for details.
- Claude — UI/UX inspiration
- FastAPI — Python web framework
- React — UI library
- Tailwind CSS — Styling
- OpenRouter — Unified LLM API
- 9Router — Multi-provider routing
Built with ❤️ by Aybis