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
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
JSONResponseandHTMLResponsebased on theAcceptheaderRationale
Acceptance Criteria
Labels: architecture, refactor, api, backend