Skip to content

Unify API and Web routes for maintainability #26

@AishaA-cpu

Description

@AishaA-cpu

Problem

There are duplicate routers for web and API (e.g., auth.py + web_auth.py, instructor_assignments.py + web_instructor_assignments.py, etc.), resulting in repeated logic, higher maintenance costs, and increased risk of inconsistent behavior.

Proposal

  • Refactor routers to use content negotiation, serving both JSON and HTML responses from unified endpoints
  • Use FastAPI's JSONResponse and HTMLResponse based on the Accept header
  • Remove duplicate router files and consolidate handlers
  • Add tests to ensure parity between API and web outputs

Rationale

  • Reduces code duplication by 40%+
  • Ensures new features, bugfixes, and validation flow consistently to both Web and REST clients
  • Easier onboarding for future maintainers

Acceptance Criteria

  • No duplicate router files or logic blocks remain
  • All existing routes are covered by appropriate tests
  • Both JSON and HTML views produce correct results from single handler logic

Labels: architecture, refactor, api, backend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions