Overview
The Nova Coder API has been refactored from a monolithic _routes.py file (349KB, 8540 lines) into a modular route system organized by feature.
Route Modules
routes_common.py
Common utilities shared across all route modules:
- Response helpers (
success_response,error_response,paginated_response) - CSRF token management (
generate_csrf_token,validate_csrf_token,set_csrf_cookie) - CSRF protection decorator (
require_csrf) - Rate limiting decorator (
rate_limit)
routes_auth.py
Authentication and session management:
GET /api/auth/csrf-token- Generate CSRF tokenPOST /api/auth/login- Authenticate and create sessionPOST /api/auth/logout- Clear sessionGET /api/auth/status- Check authentication status
routes_chat.py
Chat and messaging:
GET /api/chat/history- Get chat historyPOST /api/chat- Send message to agentPOST /api/chat/clear- Clear chat history
routes_system.py
System status and health:
GET /api/rate-limit/status- Rate limiting statusGET /api/rate-limit/config- Rate limiting configGET /api/rate-limit/stats- Rate limiting statsGET /api/status- Application statusGET /api/health- Detailed health metrics
routes_web.py
Web UI:
GET /- Serve web dashboard
routes_webhooks.py
Webhook management:
POST /api/webhooks- Create webhookGET /api/webhooks- List webhooksGET /api/webhooks/{webhook_id}- Get webhookDELETE /api/webhooks/{webhook_id}- Delete webhookGET /api/webhooks/stats- Webhook statistics
routes_ai.py
AI system features:
POST /api/ai/multimodal/process- Process multimodal messagesGET /api/ai/multimodal/config- Multimodal configurationPOST /api/ai/multimodal/enable- Enable multimodalPOST /api/ai/multimodal/disable- Disable multimodalGET /api/ai/systems/status- AI systems statusPOST /api/ai/batch/request- Add batch requestPOST /api/ai/batch/process- Process batchGET /api/ai/batch/metrics- Batch metricsPOST /api/ai/error-handling/fallback- Register fallbackPOST /api/ai/error-handling/circuit-breaker/reset- Reset circuit breakerPOST /api/ai/rag/store- Store RAG documentGET /api/ai/rag/search- Search RAG storeGET /api/ai/rag/documents- List RAG documentsDELETE /api/ai/rag/documents/{key}- Delete RAG documentPOST /api/ai/rag/clear- Clear RAG storePOST /api/ai/rag/generate- Generate RAG response
routes_agents.py
Agent management:
GET /api/agents- List agents (paginated)POST /api/agents/run- Run agent taskGET /api/agent-features/config- Get features configPOST /api/agent-features/config- Update features configGET /api/agent-features/status- Get features statusPOST /api/agent-features/enable- Enable featurePOST /api/agent-features/disable- Disable feature
routes_analytics.py
API analytics dashboard:
GET /api/analytics-api/summary- Get comprehensive analytics summaryGET /api/analytics-api/endpoint-stats- Get statistics for specific endpoint (optionalendpointquery parameter; accepts a full metric key or a plain path and aggregates across HTTP methods)GET /api/analytics-api/time-series- Get time series analytics dataGET /api/analytics-api/error-analysis- Get error analysis dataGET /api/analytics-api/performance- Get performance metricsGET /api/analytics-api/clients- Get client analyticsPOST /api/analytics-api/clear- Clear all analytics dataGET /api/analytics-api/status- Get analytics system status
Integration
All modules are registered in app.py:
import novacoder.api.routes_common
import novacoder.api.routes_auth
import novacoder.api.routes_chat
import novacoder.api.routes_system
import novacoder.api.routes_web
import novacoder.api.routes_webhooks
import novacoder.api.routes_ai
import novacoder.api.routes_agents
import novacoder.api.routes_analytics
import novacoder.api._routes # Remaining routes
Benefits
- Maintainability: Smaller, focused files
- Collaboration: Reduced merge conflicts
- Testing: Better test isolation
- Documentation: Clear feature organization
Status
✅ All 9 modules implemented and tested ✅ 342 routes registered (after duplicate removal, gateway additions, and analytics addition) ✅ No import conflicts or errors ✅ UI integration verified ✅ Gateway management endpoints added (6 new routes) ✅ Analytics API dashboard endpoints added (8 new routes)