The backend is the server side of an application: code that receives HTTP requests, checks data and permissions, applies business rules, talks to the database and external services, and returns a response. Users cannot see or change it, so everything that money, access and data integrity depend on is decided here. A minimal backend is a process with an API, a database, configuration in environment variables and logs; as it grows, it gains a cache, queues and background workers.
After this you will be able to
- list the backend responsibilities — validation, business logic, storage, permissions, integrations — and the steps of handling one request
- decide which work runs inside the request and which goes to a queue and a worker
- explain why HTTP is stateless, where to keep sessions and why not in process memory
- choose a stack for a learning project — Node.js, Java/Spring or Python — and justify the choice
Contents
- What the server does for one request
- Backend responsibilities: validation, logic, storage, permissions, integrations
- Synchronous requests and background work
- State: where to keep it and why the server forgets
- Logs, configuration and backing services
- Stacks: Node.js, Java/Spring, Python — how they differ
- Practice: a backend diagram for online booking, and what is next
What the server does for one request
In the lesson on how a website works, the backend was the restaurant kitchen, and in the HTTP and JSON lesson we took requests and responses apart. Here we look at what happens inside the server between the two. MDN describes the job of server-side code as validating submitted data and requests, storing and retrieving data in a database, and sending the right data back to the client. In practice, a single request like book a haircut on Friday at 3 pm goes roughly this way:
Routing
The server looks at the method and path, for example
POST /api/bookings, and picks a handler: the function responsible for one type of request.Authentication
Who sent the request? The server checks the session cookie or token and finds the user. No proof means a 401 response.
Validation
Are all fields present, of the right type, and is the date not in the past? Bad input gets a 400 with a clear description, not a crashed server.
Business logic and permissions
Is the salon open at that time, is the stylist free, may this client book? A broken rule means 409 or 403.
Storage
The booking is saved to the database so that two simultaneous requests cannot take the same slot.
Response and a log line
The client gets a 201 with the created booking, and a log line records what happened and how long it took.
Backend responsibilities: validation, logic, storage, permissions, integrations
Unlike browser code, server-side code has full access to the operating system and can be written in any language; MDN names this as the main difference between client-side and server-side programming. With that access comes responsibility. It is convenient to split it into five duties, using an online booking service for a salon as the example.
Validation
- What it means
- Stop data of the wrong shape or type at the door
- Example: online booking
- Phone in a valid format, date not in the past, the service exists
Business logic
- What it means
- Domain rules that cannot be trusted to the client
- Example: online booking
- Service duration, stylist working hours, no double booking
Storage
- What it means
- Write data reliably and find it quickly
- Example: online booking
- Clients, stylists, services and bookings in a database
Permissions
- What it means
- Who can see and change what
- Example: online booking
- Clients see their bookings, stylists their schedule, the admin everything
Integrations
- What it means
- Exchange data with external systems via their APIs
- Example: online booking
- SMS or messenger notifications, online deposit payment, calendar
Authentication and authorization sound alike but are different steps. Authentication answers who is this, authorization answers what are they allowed to do. A user can be successfully authenticated and still have no right to cancel someone else's booking. Both get dedicated lessons in this direction.
Synchronous requests and background work
Not everything has to happen while the user waits. Saving the booking does: without it you cannot say you are booked. Sending an SMS reminder, rebuilding a report or compressing an uploaded photo can happen a bit later. Such work goes into background jobs: the request handler puts a job on a queue and responds immediately, and a separate worker process takes jobs off the queue and runs them.
Synchronously, inside the request
- The user waits until everything finishes
- The result is needed for the response: was the booking created, what does the order cost
- A slow external service slows your response too
- An external outage becomes an error for the user
In the background, via a queue
- The response goes out at once; a separate process does the work
- Good for emails, SMS, reports, file processing, webhooks
- A job can be retried after a failure
- You need to store job status and monitor the queue
The Twelve-Factor App methodology describes these as process types: HTTP requests are handled by a web process and long-running background tasks by a worker process. The queue itself is another backing service on par with the database: a message broker such as RabbitMQ, a Redis store, or a jobs table in the same PostgreSQL. The choice depends on volume and reliability requirements; the background jobs lesson covers it in detail.
State: where to keep it and why the server forgets
HTTP is stateless by default: every request is new to the server, which does not remember that the same browser signed in a second ago. To remember the user, the server issues a cookie with a session ID after sign-in, the browser attaches it to every following request, and the server uses the ID to look up the session data. This is how MDN describes the mechanism.
The key question is where session data, and everything else that must survive between requests, lives. It is tempting to keep it in a variable in process memory: that works on a laptop and breaks in production. The Twelve-Factor App requires application processes to be stateless and share-nothing, with anything that must persist stored in an external backing service. The reason is simple: a restart on deploy wipes process memory, and with several server instances the next request may land on a different one.
Process memory
- What fits there
- A cache for a single request, reference data that can be rebuilt
- What to expect
- Gone on restart; every server instance has its own
Database
- What fits there
- Users, bookings, orders — anything you cannot lose
- What to expect
- Reliable, with transactions and backups
Store with expiration (Redis, Memcached)
- What fits there
- Sessions, cache, rate-limit counters
- What to expect
- Fast, data lives for a set time; the Twelve-Factor App recommends it for sessions
Cookie in the browser
- What fits there
- Session ID, UI preferences
- What to expect
- The user can read and change the value — never store permissions or prices there
Logs, configuration and backing services
Users cannot see the backend, and developers see it only through logs. A log is a stream of events: request received, booking created, SMS service returned an error. The Twelve-Factor App advises the app not to manage log files but to write events to standard output (stdout), one per line; collecting, storing and searching them is the job of the environment: the hosting, the container platform, the log collection system.
- Log the method, path, status code, duration and request ID — that is how you find a problem
- Log errors with the stack trace on the server, and give the client a short message without internals
- Never log passwords, tokens, card numbers or full personal data
- Keep settings that differ between environments — database URL, service keys — in environment variables, not in code
The last point also comes from the Twelve-Factor App: config is separated from code, and the test is simple — the codebase could be made public at any moment without exposing a single credential. The same methodology calls the database, queue, mail service and cache backing services: the app reaches them by an address from config and does not care whether they are local or cloud-hosted. Swapping one database for another means changing a variable, not code.
- 01ClientsWebsite, mobile app, admin panel, external systems sending webhooks
- 02API processRoutes, authentication, validation, business logic, responses and logs
- 03WorkerBackground jobs from the queue: reminders, reports, file processing
- 04Backing servicesDatabase, session and queue store, email and SMS, file storage
Stacks: Node.js, Java/Spring, Python — how they differ
Every responsibility in this lesson is the same in any stack; what changes is the language, the tooling and how much the framework does for you. MDN notes that the server side is almost never written without a framework: it takes care of routing, request parsing, sessions and database access. Frameworks range from batteries-included, like Django, to minimalist, like Express or Flask, where the missing pieces come from separate libraries.
JavaScript / TypeScript on Node.js
- Frameworks
- Express — minimal; NestJS — with a module structure
- Strengths
- Same language as the frontend, an async model for many concurrent requests
- Keep in mind
- Express dictates almost nothing: you choose structure, validation and database access yourself
Java / Kotlin
- Frameworks
- Spring Boot
- Strengths
- Strong typing, a mature ecosystem, built-in server, security, metrics and health checks
- Keep in mind
- More concepts and configuration up front; requires a JDK
Python
- Frameworks
- FastAPI for APIs; Django, batteries included with an ORM and admin
- Strengths
- Fast start; FastAPI builds validation and OpenAPI docs from type hints
- Keep in mind
- For heavy computation and high request volume, the execution model needs a deliberate choice
For a learning project, pick the stack you already know. If you write frontend in JavaScript, start with Node.js: there is no need to learn a second language alongside server concepts. If you are learning Python, FastAPI gets you a working, documented API in a few dozen lines. If you are aiming at large companies and banking, look at Java and Spring Boot. In our experience, moving between stacks is easy once the backend duties themselves are clear: route, validation, logic, storage, permissions.
Practice: a backend diagram for online booking, and what is next
Put it all together on one service. A salon needs a website where a client chooses a service, a stylist and a time; the admin sees the schedule; the client gets a reminder the day before the visit. Before writing code, draw the backend on paper — you will see which parts are needed and where each piece of state lives.
From here the direction moves from tools to architecture. First Node.js: modules, npm and a first HTTP server without a framework. Then Express: a CRUD API with validation and a single error format. Parallel tracks cover Java with Spring Boot and Python with FastAPI or Django. After that come authentication, authorization, background jobs, backend testing and backend application layers. For storage you will need the Databases direction.
- I can list the steps of handling one request: route, auth, validation, logic, storage, response, log
- I understand why client-side checks do not replace server-side checks
- I know which work to move to a queue and why a job must survive a retry
- I can explain why sessions are not kept in process memory
- I know what goes into logs and what must never go there
- I have picked a stack for a learning project and can explain why