Full-stack AI observability app with:
- FastAPI backend (
app/) - React + Vite dashboard (
dashboard/) - SQLite by default (
ai_logs.db)
- Register and login with role-based users (
admin,employee) - Send prompts to an LLM
- Track request cost and latency
- View request logs
admin: sees all logsemployee: sees only their own logs
app/
├── api/
│ ├── admin_routes.py
│ ├── auth_routes.py
│ ├── employee_routes.py
│ ├── __init__.py
├── core/
│ ├── dependencies.py
│ ├── security.py
│ ├── __init__.py
├── models/
│ ├── llm_log.py
│ ├── user.py
│ ├── __init__.py
├── services/
│ ├── auth_service.py
│ ├── llm_service.py
│ ├── logging_service.py
│ ├── __init__.py
├── config.py
├── database.py
├── main.py
├── schemas.py
- Python 3.11+
- Node.js 18+ (or latest LTS)
- npm
- OpenAI API key
From project root:
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install -r requirements.txt
pip install "python-jose[cryptography]" "passlib[bcrypt]"Create/update .env in project root:
DATABASE_URL=sqlite:///./ai_logs.db
OPENAI_API_KEY=your_openai_api_key_here
SECRET_KEY=your_secret_key_hereRun backend:
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000Backend URL: http://127.0.0.1:8000
In a new terminal:
cd dashboard
npm install
npm run devDashboard URL (usually): http://127.0.0.1:5173
- Open the dashboard.
- Register a user using API (Swagger/Postman/curl), then login in UI.
- Submit prompts from the dashboard.
Open Swagger docs:
http://127.0.0.1:8000/docs
Useful endpoints:
POST /auth/registerPOST /auth/loginPOST /employee/generate(Bearer token required)GET /admin/logs(Bearer token required)
Example register payload:
{
"name": "Admin User",
"email": "admin@example.com",
"password": "admin123",
"role": "admin"
}Employee payload is the same with "role": "employee".
From project root:
docker build -t ai-observability .
docker run --rm -p 8000:8000 --env-file .env ai-observability403 Not authorizedon generate/logs:- Login again to refresh token.
- Ensure role is
adminoremployee.
401 Invalid token:- Token missing/expired, login again.
- OpenAI errors:
- Check
OPENAI_API_KEYin.env.
- Check
- Missing module errors (
jose,passlib):- Install extra packages:
pip install "python-jose[cryptography]" "passlib[bcrypt]"
- Install extra packages:
- CORS is currently open (
allow_origins=["*"]) for local development. - Default DB is SQLite file
ai_logs.db.