New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
main.py is nine hundred lines now and I can't find anything in it anymore.
What you'll have at the end
A main.py under 30 lines, with each domain's routes in its own file
You need
A running app with real routes for at least two clearly different resources, such as users and orders, all still defined directly in main.py.
Not covered
Splitting the request and response models or the database code out of the same file; this only moves the route functions and the router-level config that rides directly on them.
Leans on
One shared dependency instead of a check copied into every route
when the same check is still copied across many routes inside one now-split package, that recipe turns it into one shared dependency; this one only covers where the routes themselves live.
Turn FastAPI's bare auto-generated OpenAPI docs into ones consumers can use
once each resource carries its own tag from splitting, giving the docs page real names and descriptions is the natural next polish.
Checked 18 Aug 2026
Part of the FastAPI cookbook