Module 08 Activity
Scenario
Split the application into layers a second developer can navigate.
What you build
Routers by resource, services with no framework imports, domain exceptions mapped in one place, and the vendor behind one file.
Steps
- Split the routes into one router per resource, with the prefix and tag declared once.
- Move the logic into services and confirm none imports FastAPI.
- Define domain exceptions and map them to status codes in one place in the router layer.
- Call one service function directly, with no client and no app, to prove it needs no HTTP.
- Confine the model provider to one client module.
- Hand the repository to someone who has not seen it and give them three 'where does X go?' questions.
Evidence to hand in
- The routers with prefixes and tags.
- The services, with the import check.
- The exception-to-status mapping.
- A service called with no HTTP involved.
- The client module.
- The navigation test results.
Review checklist
- Each router declares its prefix and tag once.
- No service imports FastAPI.
- Domain exceptions are mapped to statuses in one place.
- A service function was called with no client and no app.
- Someone unfamiliar answered the navigation questions unaided.
