Web Frameworks
This content is for Backend. Switch to the latest version for up-to-date documentation.
A web framework helps you build backend applications faster by giving you common building blocks and a consistent structure.
Even though frameworks look different (Express, Django, Spring, Laravel, ASP.NET), they all solve the same problems.
What Web Frameworks Have in Common
Section titled “What Web Frameworks Have in Common”1) Routing
Section titled “1) Routing”Routing maps a request to a handler based on:
- HTTP method (GET/POST/PUT/PATCH/DELETE)
- URL path (like
/users/42)
Example idea (framework-agnostic):
GET /users→ list usersGET /users/:id→ get one user
2) Request + Response
Section titled “2) Request + Response”Frameworks provide an abstraction for:
- the incoming request (headers, params, body)
- the outgoing response (status code, JSON/HTML)
You always do the same flow:
- Read input from the request
- Execute business logic
- Return a response
3) Middleware / Filters / Interceptors
Section titled “3) Middleware / Filters / Interceptors”Most frameworks have a concept of “code that runs before/after your routes”.
Typical uses:
- logging
- authentication
- rate limiting
- adding shared data to the request
Naming differs:
- Express: middleware
- Spring: filters, interceptors
- ASP.NET: middleware
- NestJS: guards, interceptors
4) Controllers / Handlers
Section titled “4) Controllers / Handlers”A handler (sometimes called a controller action) is the function that runs when a route matches.
Handlers are usually kept small and call services/helpers to do the real work.
5) Error Handling
Section titled “5) Error Handling”Frameworks provide a standard way to:
- handle “not found” routes
- return consistent server errors
- centralize error formatting
6) Parsing the Body
Section titled “6) Parsing the Body”Almost every backend needs to read request bodies:
- JSON (
application/json) - form data (
application/x-www-form-urlencoded) - file uploads (
multipart/form-data)
Frameworks either include body parsing or plug it in.
7) Serving Static Files
Section titled “7) Serving Static Files”Many frameworks can serve static files (images, CSS, downloads) or integrate with a reverse proxy.
8) Configuration + Environments
Section titled “8) Configuration + Environments”Frameworks support:
- configuration files
- environment variables
- dev vs production behavior
9) Database Integration (Common Pattern)
Section titled “9) Database Integration (Common Pattern)”Frameworks don’t have to include databases, but most projects add:
- an ORM/query builder
- migrations
- connection pooling
One Concept, Many Frameworks (Mapping)
Section titled “One Concept, Many Frameworks (Mapping)”This is the same idea written in different frameworks:
| Concept | Express (Node) | Django (Python) | Spring (Java) | Laravel (PHP) |
|---|---|---|---|---|
| Route | app.get('/users', ...) | path('users/', ...) | @GetMapping("/users") | Route::get('/users', ...) |
| Handler | function | view function/class | controller method | controller method |
| Middleware | app.use(...) | middleware classes | filters/interceptors | middleware |
| JSON response | res.json(...) | JsonResponse(...) | return object | return response()->json(...) |
You don’t need to memorize syntax—focus on the concept and then learn the framework’s way of writing it.
Choosing a Web Framework
Section titled “Choosing a Web Framework”- Minimal frameworks (Express): more freedom, less structure
- Opinionated frameworks (NestJS, Django, Spring): more structure, more built-in patterns
Where Web Frameworks Are Used
Section titled “Where Web Frameworks Are Used”- Backend APIs (REST, GraphQL)
- Server-rendered apps (HTML pages)
- Internal tools and admin panels
Industry examples:
- Netflix: large Node.js usage for web services
- Google: heavy Java/Spring usage across many systems
- Shopify: Ruby on Rails for large parts of its product
- Learn a concrete framework: Express.js
- For API design concepts: API Styles