Skip to content

Set up Litestar application with REST API skeleton #31

@Aureliolo

Description

@Aureliolo

Context

Set up the Litestar application that serves as the REST API interface for the AI company system. This provides programmatic access to all core resources and is the foundation for the web dashboard and external integrations.

Litestar was chosen over FastAPI for its built-in channels (pub/sub WebSocket), class-based controllers, native route guards, and batteries-included middleware (rate limiting, CSRF, compression). See DESIGN_SPEC §15.4 for full rationale.

Key aspects:

  • All routes under /api/v1/ prefix
  • OpenAPI 3.1 documentation auto-generated
  • Class-based controllers for each resource group
  • Built-in middleware for CORS, compression, rate limiting, logging
  • Application factory pattern for testability

Acceptance Criteria

  • Litestar application created with /api/v1/ prefix
  • Application factory pattern (create_app()) for testability
  • Controller stubs for all endpoint groups defined in §13.2
  • CORS middleware configured (configurable allowed origins)
  • GZip/Brotli compression middleware enabled
  • Rate limiting middleware configured (configurable limits)
  • Request logging middleware integrated with structlog (method, path, status, duration)
  • Error handling with consistent error response envelope
  • Interactive Scalar API docs at /docs/api (OpenAPI schema at /docs/openapi.json)
  • Health check endpoint at /api/v1/health
  • Uvicorn configuration (host, port, reload, workers)
  • Litestar + uvicorn added to pyproject.toml dependencies
  • Unit tests for middleware and health check

Dependencies

  • None (can start independently, route implementations depend on domain models)

Design Spec Reference

  • §13.1 — API architecture
  • §13.2 — API endpoint definitions
  • §15.4 — Key design decisions (Litestar rationale)

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:criticalBlocks other work, must do firstscope:medium1-3 days of workspec:architectureDESIGN_SPEC Section 15 - Technical Architecturespec:human-interactionDESIGN_SPEC Section 13 - Human Interaction Layertype:featureNew feature implementationtype:infraCI/CD, tooling, project setuptype:testTest coverage, test infrastructure

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions