Skip to content

Refactor API into modular routers #58

Description

@Presmanes3

Problem

The file src/climatevision/api/main.py has ~980 lines with all routes defined inline in create_app(). This makes maintenance, testing, and team collaboration difficult.

Proposed solution

Split routes into separate modules using FastAPI's APIRouter:

src/climatevision/api/
├── __init__.py
├── main.py              # Clean create_app() with include_routers()
├── routes/
│   ├── __init__.py
│   ├── health.py         # GET /api/health
│   ├── analysis.py      # GET /api/analysis-types
│   ├── runs.py          # CRUD /api/runs
│   ├── predict.py      # POST /api/predict, /api/predict/upload
│   ├── organizations.py # CRUD /api/organizations
│   ├── subscriptions.py # /api/organizations/{id}/subscriptions
│   └── alerts.py         # /api/organizations/{id}/alerts

Tasks

  • [ ] Create api/routes/ with __init__.py
  • [ ] Move each route group to its own module with APIRouter
  • [ ] Clean main.py to only use include_routers()
  • [ ] Move specific schemas or keep in schemas.py
  • [ ] Verify all endpoints still work
  • [ ] Update tests to reflect new structure

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions