- Add web router with all frontend pages
- Login/Register pages with form validation
- Dashboard with stats cards and Chart.js
- API Keys management with CRUD operations
- Stats page with filtering and pagination
- API Tokens management with generation/revocation
- User profile with password change and account deletion
- Add shared templates_config.py to avoid circular imports
- Add CSRF protection middleware
- Add get_current_user_optional dependency for web routes
All routes verified working:
- GET /login, POST /login
- GET /register, POST /register
- POST /logout
- GET /dashboard
- GET /keys, POST /keys, DELETE /keys/{id}
- GET /stats
- GET /tokens, POST /tokens, DELETE /tokens/{id}
- GET /profile, POST /profile/password, DELETE /profile
301 lines
13 KiB
Markdown
301 lines
13 KiB
Markdown
# Progress Tracking
|
|
|
|
## Feature: Fase 1 - MVP OpenRouter API Key Monitor
|
|
|
|
---
|
|
|
|
## 📊 Stato Generale
|
|
|
|
| Metrica | Valore |
|
|
|---------|--------|
|
|
| **Stato** | 🟢 Gestione Token API Completata |
|
|
| **Progresso** | 52% |
|
|
| **Task Totali** | 74 |
|
|
| **Task Completati** | 38 |
|
|
| **Task In Progress** | 0 |
|
|
|
|
---
|
|
|
|
## 🎯 Obiettivi Fase 1 (MVP)
|
|
|
|
### Core Features
|
|
1. ✅ **Autenticazione utenti** (registrazione/login JWT)
|
|
2. ✅ **CRUD API key** (cifrate AES-256)
|
|
3. ✅ **Dashboard statistiche base** (aggregazione dati)
|
|
4. ✅ **API pubblica autenticata** (sola lettura)
|
|
|
|
### Requisiti Non Funzionali
|
|
- [ ] Tempo di risposta web < 2 secondi
|
|
- [ ] API response time < 500ms
|
|
- [ ] Supporto 100+ utenti concorrenti
|
|
- [ ] Test coverage >= 90%
|
|
- [ ] Sicurezza: AES-256, bcrypt, JWT, rate limiting
|
|
|
|
---
|
|
|
|
## 📋 Task Pianificate
|
|
|
|
### 🔧 Setup Progetto (T01-T05) - 5/5 completati
|
|
- [x] T01: Creare struttura cartelle progetto (2024-04-07)
|
|
- [x] T02: Inizializzare virtual environment e .gitignore (2024-04-07)
|
|
- [x] T03: Creare requirements.txt con dipendenze (2024-04-07)
|
|
- [x] T04: Setup file configurazione (.env, config.py) (2024-04-07)
|
|
- [x] T05: Configurare pytest e struttura test (2024-04-07)
|
|
|
|
### 🗄️ Database & Models (T06-T11) - 6/6 completati
|
|
- [x] T06: Creare database.py (connection & session) - ✅ Completato (2026-04-07 11:00)
|
|
- [x] T07: Creare model User (SQLAlchemy) - ✅ Completato (2026-04-07 11:15)
|
|
- [x] T08: Creare model ApiKey (SQLAlchemy) - ✅ Completato (2026-04-07 11:15)
|
|
- [x] T09: Creare model UsageStats (SQLAlchemy) - ✅ Completato (2026-04-07 11:15)
|
|
- [x] T10: Creare model ApiToken (SQLAlchemy) - ✅ Completato (2026-04-07 11:15)
|
|
- [x] T11: Setup Alembic e creare migrazione iniziale - ✅ Completato (2026-04-07 11:20)
|
|
|
|
### 🔐 Servizi di Sicurezza (T12-T16) - 5/5 completati
|
|
- [x] T12: Implementare EncryptionService (AES-256) - ✅ Completato (2026-04-07 12:00, commit: 2fdd9d1)
|
|
- [x] T13: Implementare password hashing (bcrypt) - ✅ Completato (2026-04-07 12:15, commit: 54e8116)
|
|
- [x] T14: Implementare JWT utilities - ✅ Completato (2026-04-07 12:30, commit: 781e564)
|
|
- [x] T15: Implementare API token generation - ✅ Completato (2026-04-07 12:45, commit: 649ff76)
|
|
- [x] T16: Scrivere test per servizi di sicurezza - ✅ Completato (test inclusi in T12-T15)
|
|
|
|
**Progresso sezione:** 100% (5/5 task)
|
|
**Test totali servizi:** 71 test passanti
|
|
**Coverage servizi:** 100%
|
|
|
|
### 👤 Autenticazione Utenti (T17-T22) - 6/6 completati
|
|
- [x] T17: Creare Pydantic schemas auth (register/login) - ✅ Completato (2026-04-07 14:30)
|
|
- [x] T18: Implementare endpoint POST /api/auth/register - ✅ Completato (2026-04-07 15:00)
|
|
- [x] T19: Implementare endpoint POST /api/auth/login - ✅ Completato (2026-04-07 15:00)
|
|
- [x] T20: Implementare endpoint POST /api/auth/logout - ✅ Completato (2026-04-07 15:00)
|
|
- [x] T21: Creare dipendenza get_current_user - ✅ Completato (2026-04-07 15:00)
|
|
- [x] T22: Scrivere test per auth endpoints - ✅ Completato (2026-04-07 15:15)
|
|
|
|
**Progresso sezione:** 100% (6/6 task)
|
|
**Test totali auth:** 34 test (19 schemas + 15 router)
|
|
**Coverage auth:** 98%+
|
|
|
|
### 🔑 Gestione API Keys (T23-T29) - 7/7 completati ✅
|
|
- [x] T23: Creare Pydantic schemas per API keys - ✅ Completato (2026-04-07 16:00, commit: 2e4c1bb)
|
|
- [x] T24: Implementare POST /api/keys (create) - ✅ Completato (2026-04-07 16:30, commit: abf7e7a)
|
|
- [x] T25: Implementare GET /api/keys (list) - ✅ Completato (2026-04-07 16:30, commit: abf7e7a)
|
|
- [x] T26: Implementare PUT /api/keys/{id} (update) - ✅ Completato (2026-04-07 16:30, commit: abf7e7a)
|
|
- [x] T27: Implementare DELETE /api/keys/{id} - ✅ Completato (2026-04-07 16:30, commit: abf7e7a)
|
|
- [x] T28: Implementare servizio validazione key - ✅ Completato (2026-04-07 17:10, commit: 3824ce5)
|
|
- [x] T29: Scrivere test per API keys CRUD - ✅ Completato (2026-04-07 17:15, incluso in T24-T27)
|
|
|
|
**Progresso sezione:** 100% (7/7 task)
|
|
**Test totali API keys:** 38 test (25 router + 13 schema)
|
|
**Coverage router:** 100%
|
|
|
|
### 📊 Dashboard & Statistiche (T30-T34) - 4/5 completati
|
|
- [x] T30: Creare Pydantic schemas per stats - ✅ Completato (2026-04-07 17:45)
|
|
- Creato: UsageStatsCreate, UsageStatsResponse, StatsSummary, StatsByModel, StatsByDate, DashboardResponse
|
|
- Test: 16 test passanti, 100% coverage su schemas/stats.py
|
|
- [x] T31: Implementare servizio aggregazione stats - ✅ Completato (2026-04-07 18:30)
|
|
- Creato: get_summary(), get_by_model(), get_by_date(), get_dashboard_data()
|
|
- Query SQLAlchemy con join ApiKey per filtro user_id
|
|
- Test: 11 test passanti, 84% coverage su services/stats.py
|
|
- [x] T32: Implementare endpoint GET /api/stats/dashboard - ✅ Completato (2026-04-07 19:00)
|
|
- Endpoint: GET /api/stats/dashboard
|
|
- Query param: days (1-365, default 30)
|
|
- Auth required via get_current_user
|
|
- Returns DashboardResponse
|
|
- [x] T33: Implementare endpoint GET /api/usage - ✅ Completato (2026-04-07 19:00)
|
|
- Endpoint: GET /api/usage
|
|
- Required params: start_date, end_date
|
|
- Optional filters: api_key_id, model
|
|
- Pagination: skip, limit (max 1000)
|
|
- Returns List[UsageStatsResponse]
|
|
- [ ] T34: Scrivere test per stats endpoints 🟡 In progress
|
|
- Test base creati (16 test)
|
|
- Alcuni test richiedono fixture condivisi
|
|
|
|
### 🌐 Public API v1 (T35-T43) - 6/9 completati
|
|
- [x] T35: Creare Pydantic schemas per API pubblica - ✅ Completato (2026-04-07)
|
|
- Creati: PublicStatsResponse, PublicUsageResponse, PublicKeyInfo, ApiToken schemas
|
|
- Test: 25 test passanti, 100% coverage
|
|
- [x] T36: Implementare GET /api/v1/stats - ✅ Completato (2026-04-07)
|
|
- Auth via API token, date range default 30 giorni, aggiorna last_used_at
|
|
- Test: 8 test passanti
|
|
- [x] T37: Implementare GET /api/v1/usage - ✅ Completato (2026-04-07)
|
|
- Paginazione con page/limit (max 1000), filtri date richiesti
|
|
- Test: 7 test passanti
|
|
- [x] T38: Implementare GET /api/v1/keys - ✅ Completato (2026-04-07)
|
|
- Lista keys con stats aggregate, NO key values in risposta (sicurezza)
|
|
- Test: 5 test passanti
|
|
- [x] T39: Implementare rate limiting per API pubblica - ✅ Completato (2026-04-07)
|
|
- 100 req/ora per token, 30 req/min per IP fallback, headers X-RateLimit-*
|
|
- Test: 18 test passanti, 98% coverage
|
|
- [x] T40: Scrivere test per public API endpoints - ✅ Completato (2026-04-07)
|
|
- 27 test endpoint + 18 test rate limit + 25 test schemas = 70 test totali
|
|
- Coverage: public_api.py 100%, rate_limit.py 98%
|
|
- [x] T41: Implementare POST /api/tokens (generate) - ✅ Completato (2026-04-07, commit: 5e89674)
|
|
- Endpoint: POST /api/tokens con auth JWT
|
|
- Limite: MAX_API_TOKENS_PER_USER (default 5)
|
|
- Token plaintext mostrato SOLO in risposta creazione
|
|
- Hash SHA-256 salvato nel DB
|
|
- Test: 8 test passanti, 100% coverage
|
|
- [x] T42: Implementare GET /api/tokens (list) - ✅ Completato (2026-04-07, commit: 5e89674)
|
|
- Endpoint: GET /api/tokens con auth JWT
|
|
- NO token values in risposta (sicurezza)
|
|
- Ordinamento: created_at DESC
|
|
- Solo token attivi (is_active=True)
|
|
- Test: 7 test passanti
|
|
- [x] T43: Implementare DELETE /api/tokens/{id} - ✅ Completato (2026-04-07, commit: 5e89674)
|
|
- Endpoint: DELETE /api/tokens/{id} con auth JWT
|
|
- Soft delete: is_active=False
|
|
- Verifica ownership (403 se non proprio)
|
|
- Token revocato non funziona su API pubblica
|
|
- Test: 9 test passanti
|
|
|
|
### 🎨 Frontend Web (T44-T54) - 11/11 completati ✅
|
|
- [x] T44: Setup Jinja2 templates e static files ✅ Completato (2026-04-07 16:00, commit: c1f47c8)
|
|
- Static files mounted on /static
|
|
- Jinja2Templates configured
|
|
- Directory structure created
|
|
- All 12 tests passing
|
|
- [x] T45: Creare base.html (layout principale) ✅ Completato (con T44)
|
|
- Base template con Pico.css, HTMX, Chart.js
|
|
- Components: navbar, footer
|
|
- [x] T46: HTMX e CSRF Protection ✅ Completato (2026-04-07 16:30, commit: ccd96ac)
|
|
- CSRFMiddleware con validazione token
|
|
- Meta tag CSRF in base.html
|
|
- 13 tests passing
|
|
- [x] T47: Pagina Login ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /login con template
|
|
- Route POST /login con validazione
|
|
- Redirect a dashboard dopo login
|
|
- [x] T48: Pagina Registrazione ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /register con template
|
|
- Route POST /register con validazione
|
|
- Validazione password client-side
|
|
- [x] T49: Logout ✅ Completato (2026-04-07 17:00)
|
|
- Route POST /logout
|
|
- Cancella cookie JWT
|
|
- Redirect a login
|
|
- [x] T50: Dashboard ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /dashboard (protetta)
|
|
- Card riepilogative con stats
|
|
- Grafici Chart.js
|
|
- [x] T51: Gestione API Keys ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /keys con tabella
|
|
- Route POST /keys per creazione
|
|
- Route DELETE /keys/{id}
|
|
- [x] T52: Statistiche Dettagliate ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /stats con filtri
|
|
- Tabella dettagliata usage
|
|
- Paginazione
|
|
- [x] T53: Gestione Token API ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /tokens con lista
|
|
- Route POST /tokens per generazione
|
|
- Route DELETE /tokens/{id} per revoca
|
|
- [x] T54: Profilo Utente ✅ Completato (2026-04-07 17:00)
|
|
- Route GET /profile
|
|
- Route POST /profile/password
|
|
- Route DELETE /profile per eliminazione account
|
|
|
|
### ⚙️ Background Tasks (T55-T58) - 4/4 completati ✅
|
|
- [x] T55: Configurare APScheduler - ✅ Completato (2026-04-07 20:30)
|
|
- Creato: AsyncIOScheduler singleton con timezone UTC
|
|
- Creato: Decorator @scheduled_job per registrare task
|
|
- Integrato: FastAPI lifespan per startup/shutdown
|
|
- Test: 10 test passanti
|
|
- [x] T56: Implementare task sync usage stats - ✅ Completato (2026-04-07 20:30)
|
|
- Task: sync_usage_stats ogni ora (IntervalTrigger)
|
|
- Features: Decripta key, chiama OpenRouter /usage, upsert in UsageStats
|
|
- Rate limiting: 0.35s tra richieste (20 req/min)
|
|
- Date range: ultimi 7 giorni
|
|
- Test: 6 test passanti
|
|
- [x] T57: Implementare task validazione key - ✅ Completato (2026-04-07 20:30)
|
|
- Task: validate_api_keys giornaliero alle 2:00 AM (CronTrigger)
|
|
- Features: Decripta key, chiama OpenRouter /auth/key, disattiva key invalide
|
|
- Test: 4 test passanti
|
|
- [x] T58: Implementare task cleanup dati vecchi - ✅ Completato (2026-04-07 20:30)
|
|
- Task: cleanup_old_usage_stats settimanale domenica 3:00 AM
|
|
- Features: Rimuove UsageStats più vecchi di 365 giorni (configurabile)
|
|
- Test: 6 test passanti
|
|
|
|
**Progresso sezione:** 100% (4/4 task)
|
|
**Test totali tasks:** 26 test passanti
|
|
|
|
### 🔒 Sicurezza & Hardening (T59-T63) - 0/5 completati
|
|
- [ ] T59: Implementare security headers middleware
|
|
- [ ] T60: Implementare rate limiting auth endpoints
|
|
- [ ] T61: Implementare CORS policy
|
|
- [ ] T62: Audit: verificare cifratura API keys
|
|
- [ ] T63: Audit: verificare SQL injection prevention
|
|
|
|
### 🧪 Testing & QA (T64-T68) - 0/5 completati
|
|
- [ ] T64: Scrivere test unitari per models
|
|
- [ ] T65: Scrivere test integrazione auth flow
|
|
- [ ] T66: Scrivere test integrazione API keys
|
|
- [ ] T67: Verificare coverage >= 90%
|
|
- [ ] T68: Eseguire security scan dipendenze
|
|
|
|
### 📝 Documentazione (T69-T71) - 0/3 completati
|
|
- [ ] T69: Scrivere README.md completo
|
|
- [ ] T70: Documentare API con OpenAPI
|
|
- [ ] T71: Creare esempi curl per API
|
|
|
|
### 🚀 Deployment (T72-T74) - 0/3 completati
|
|
- [ ] T72: Creare Dockerfile
|
|
- [ ] T73: Creare docker-compose.yml
|
|
- [ ] T74: Scrivere script avvio produzione
|
|
|
|
---
|
|
|
|
## 📈 Grafico Progresso
|
|
|
|
```
|
|
Progresso MVP Fase 1
|
|
|
|
TODO [██████████████████████████ ] 70%
|
|
IN PROGRESS [ ] 0%
|
|
REVIEW [ ] 0%
|
|
DONE [████████ ] 30%
|
|
|
|
0% 25% 50% 75% 100%
|
|
```
|
|
|
|
---
|
|
|
|
## 🔥 Blockers
|
|
|
|
*Nessun blocker attivo*
|
|
|
|
| ID | Descrizione | Impatto | Data Apertura | Data Risoluzione |
|
|
|----|-------------|---------|---------------|------------------|
|
|
| - | - | - | - | - |
|
|
|
|
---
|
|
|
|
## 📝 Decisioni Log
|
|
|
|
| Data | Decisione | Motivazione | Stato |
|
|
|------|-----------|-------------|-------|
|
|
| 2024-01-15 | Stack: FastAPI + SQLite + HTMX | MVP semplice, zero-config | ✅ Approvata |
|
|
| 2024-01-15 | Cifratura: AES-256-GCM | Requisito sicurezza PRD | ✅ Approvata |
|
|
| 2024-01-15 | Auth: JWT con cookie | Semplice per web + API | ✅ Approvata |
|
|
|
|
---
|
|
|
|
## 🐛 Issue Tracking
|
|
|
|
*Issue riscontrati durante lo sviluppo*
|
|
|
|
| ID | Descrizione | Severità | Stato | Assegnato | Note |
|
|
|----|-------------|----------|-------|-----------|------|
|
|
| - | - | - | - | - | - |
|
|
|
|
---
|
|
|
|
## 📚 Risorse
|
|
|
|
- PRD: `/home/google/Sources/LucaSacchiNet/openrouter-watcher/prd.md`
|
|
- Architettura: `/home/google/Sources/LucaSacchiNet/openrouter-watcher/export/architecture.md`
|
|
- Kanban: `/home/google/Sources/LucaSacchiNet/openrouter-watcher/export/kanban.md`
|
|
|
|
---
|
|
|
|
*Ultimo aggiornamento: 2026-04-07*
|
|
*Prossimo aggiornamento: Fase Security Services (T12-T16)*
|