Module 11 ยท Routers & Dependency Injection โ Lesson 1 of 4 ยท ~8 min
Routers
One file per resource
app/main.py doesn't hold every route โ that would be a repeat of Flask's giant app.py from module 19. Instead the real backend keeps one file per resource under app/routers/: walkers.py, bookings.py, payments.py, auth.py, and more. Each file builds its own APIRouter and gets wired into the app once, in main.py.
This is the exact same instinct as Flask's blueprints (module 19): a mini app for one resource's routes, defined in its own file, then registered onto the main app. APIRouter is FastAPI's blueprint โ same idea, typed.