Backend Framework
You might say
Is there a ready-made framework for building the backend, so I don't have to start from scratch?
Use a shared structure for routes, requests, data, and server behaviorA backend framework supplies conventions and tools for routing, input handling, middleware, databases, and responses. It reduces repeated setup, but it does not decide the product's rules for you. Choose one that fits the language, hosting model, and size of the application.
Know first
When to use it
- Create consistent API routesFollow the existing project structure firstsrc/├─ routes/orders.ts├─ services/payment.ts└─ app.tsPut new code where the team already knows to find it.
- Share authentication and error handlingScale determines the needed conventionsSmall APIExpress · few foldersMulti-person projectNestJS · clear modules
- Connect data and request logicGet the official minimal example working firstGET /hello200 OKPOST /items201 CreatedError400 Bad Request
- Give a team a common project structureHave AI explain the contextWhere it goesroutes/orders.tsWho calls itPOST /api/ordersHow to verifynpm test
When NOT to use it
- Adopt a large framework for one tiny function without needA framework cannot decide the business for you.Switch to NestJS✓ Cleaner folder structure → Refund rules? Still undefined
- Mix several frameworks in the same service casuallyOne request passes through three frameworksNext Route→Express→FastifyRoutes, plugins, and error handling each use a separate system.
- Put business rules inside framework-specific glue everywhereTutorial version does not match the project versionOld tutorialFramework v3 → Current projectFramework v5Check the current version's official docs first
- Assume framework defaults match every security requirementThe template starts, but the request flow is unclear.Where does the request enter?→Who handles it?→Where does the response leave?
Anatomy
①Route entry→②Public processing→③Business processing
The HTTP method and path route the request to the matching handler
Complete log, identity, verification or error conversion uniformly before and after the business code
Execute this endpoint's own business rules and return an explicit response
Variants
Full-stack
Next.js · Nuxt
Keep frontend and backend in one project.
Minimal API
Express · Fastify · Flask
Build a small set of explicit endpoints.
Structured
NestJS · Django
For larger projects with more conventions.
Typical use cases
REST API
Next.js Route HandlerPage and interface are placed in the same project
app/api/posts/route.tsexport async function GET() { return Response.json(posts)}
Visit GET /api/posts
Server-rendered app
Express APIBuild a small service with a few routes
app.get("/api/tasks", listTasks)app.post("/api/tasks", createTask)app.use(errorHandler)
Internal service
FastAPISchema automatically generates interface documents
POST /itemsCreate itemsRequest bodyItemSchemaResponse201
Swagger documents can be debugged directly
Authentication backend
Django backendManagement interface for mature content projects
Articles1,284 itemsAuthors42 peopleTo be reviewed18 Strip
The framework comes with models, permissions and management background
Further reading
