Home · Developers · Guides · API Modular Routes System

APIs

API Modular Routes System

Route module registration contract

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 token
  • POST /api/auth/login - Authenticate and create session
  • POST /api/auth/logout - Clear session
  • GET /api/auth/status - Check authentication status

routes_chat.py

Chat and messaging:

  • GET /api/chat/history - Get chat history
  • POST /api/chat - Send message to agent
  • POST /api/chat/clear - Clear chat history

routes_system.py

System status and health:

  • GET /api/rate-limit/status - Rate limiting status
  • GET /api/rate-limit/config - Rate limiting config
  • GET /api/rate-limit/stats - Rate limiting stats
  • GET /api/status - Application status
  • GET /api/health - Detailed health metrics

routes_web.py

Web UI:

  • GET / - Serve web dashboard

routes_webhooks.py

Webhook management:

  • POST /api/webhooks - Create webhook
  • GET /api/webhooks - List webhooks
  • GET /api/webhooks/{webhook_id} - Get webhook
  • DELETE /api/webhooks/{webhook_id} - Delete webhook
  • GET /api/webhooks/stats - Webhook statistics

routes_ai.py

AI system features:

  • POST /api/ai/multimodal/process - Process multimodal messages
  • GET /api/ai/multimodal/config - Multimodal configuration
  • POST /api/ai/multimodal/enable - Enable multimodal
  • POST /api/ai/multimodal/disable - Disable multimodal
  • GET /api/ai/systems/status - AI systems status
  • POST /api/ai/batch/request - Add batch request
  • POST /api/ai/batch/process - Process batch
  • GET /api/ai/batch/metrics - Batch metrics
  • POST /api/ai/error-handling/fallback - Register fallback
  • POST /api/ai/error-handling/circuit-breaker/reset - Reset circuit breaker
  • POST /api/ai/rag/store - Store RAG document
  • GET /api/ai/rag/search - Search RAG store
  • GET /api/ai/rag/documents - List RAG documents
  • DELETE /api/ai/rag/documents/{key} - Delete RAG document
  • POST /api/ai/rag/clear - Clear RAG store
  • POST /api/ai/rag/generate - Generate RAG response

routes_agents.py

Agent management:

  • GET /api/agents - List agents (paginated)
  • POST /api/agents/run - Run agent task
  • GET /api/agent-features/config - Get features config
  • POST /api/agent-features/config - Update features config
  • GET /api/agent-features/status - Get features status
  • POST /api/agent-features/enable - Enable feature
  • POST /api/agent-features/disable - Disable feature

routes_analytics.py

API analytics dashboard:

  • GET /api/analytics-api/summary - Get comprehensive analytics summary
  • GET /api/analytics-api/endpoint-stats - Get statistics for specific endpoint (optional endpoint query 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 data
  • GET /api/analytics-api/error-analysis - Get error analysis data
  • GET /api/analytics-api/performance - Get performance metrics
  • GET /api/analytics-api/clients - Get client analytics
  • POST /api/analytics-api/clear - Clear all analytics data
  • GET /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)

Source: wiki/api-modular-routes.md · rendered 2026-11-10