← All posts

What Happens When a User Clicks Save: The Full-Stack Request Lifecycle

1 Browser click → JS handler → fetch('/api/items', {method:'POST'}) 2 DNS api.example.com → IP (browser, OS, resolver caches) 3 TCP + TLS handshake, certificate check, keys agreed 4 CDN / Load balancer TLS often ends here; picks a healthy server 5 Web server nginx/IIS → app server (gunicorn, node, Kestrel) 6 Application route → auth → validate → business logic 7 Database pooled connection → query → transaction commit 8 Back up the stack JSON → browser → state update → re-render

With a Vue 3 frontend and a Django REST API in place, there’s still everything in between: the whole path from a user’s click to a row in the database and back. Owning that path is what “full-stack” really means.

My web development work taught me that when something is slow or broken, the skill that matters isn’t knowing every framework — it’s knowing which hop to look at. The diagram above is that path; below is how each hop fails and how to catch it.

The eight steps of a request

Here is what happens when a user clicks “Save” on a form:

  1. Browser — a JavaScript click handler sends fetch('/api/items', {method: 'POST'}).
  2. DNS — the browser converts api.example.com to an IP address, checking the browser, OS and resolver caches.
  3. TCP and TLS — the connection is opened, the certificate is checked and encryption keys are agreed.
  4. CDN / load balancer — TLS often ends here, and a healthy backend server is chosen.
  5. Web server — nginx or IIS forwards the request to the application server (gunicorn, Node, Kestrel).
  6. Application — routing, authentication, validation and business logic run.
  7. Database — a connection from the pool runs the query and commits the transaction.
  8. Back up the stack — the JSON response returns to the browser, which updates the state and re-renders.

What breaks at each step

Every step has its typical problems. This is the table I wish I had when I started:

Step Typical problem Symptom First tool to use
1 Browser JS error, CORS block, double submit Nothing happens, red errors in the console DevTools → Console and Network tab
2 DNS Old record, wrong TTL after a migration Works for some users but not others nslookup api.example.com
3 TLS Expired certificate, missing intermediate Browser warning; mobile apps fail first openssl s_client -connect host:443 -servername host
4 Load balancer Unhealthy backend, no sticky sessions Random 502/503, users “logged out” Health probe logs
5 Web server Timeout too short, body size limit 413 or 504 on big uploads or slow calls Access and error logs
6 Application Unhandled exception, N+1 queries 500 errors, or slow only on big lists Application logs, query count per request
7 Database Missing index, locks, connection pool full Slow everywhere at peak times EXPLAIN ANALYZE, slow query log
8 Render Huge payload, re-rendering everything Fast API but slow page DevTools Performance tab

Fastest diagnosis: The Network tab in the browser DevTools tells you the step in seconds. Click the request and open “Timing”: a long DNS lookup means step 2, a long Initial connection / SSL means step 3, a long Waiting (TTFB) means the server side (steps 4–7), and a long Content download means the response is too big.

A simple full stack for a new project

For a new small-to-medium web app, this is what I would pick today, and why:

Layer Choice Why
Frontend Vue or React with Vite Component model, big ecosystem, fast dev server
API Django REST Framework or Express “Batteries included” vs. minimal — choose by team
Authentication Session cookies (same domain) or OAuth/OIDC with a provider Don’t build password storage yourself
Database PostgreSQL Relational integrity, JSON columns when needed
Cache / queue Redis Sessions, rate limiting, background jobs
Hosting PaaS, like Azure App Service No OS patching until you really need it
Observability Structured logs with request IDs One ID across all steps = one search to trace a request

Good habits at every layer

Frontend

  1. Disable the button after the first click — otherwise double clicks become duplicate rows.
  2. Validate in the browser for a good user experience, but validate again on the server for security. The browser is not under your control.

API

  1. Return errors in one consistent format, for example {"error": {"code": "VALIDATION", "fields": {...}}}, so the frontend can show all of them the same way.
  2. Make writes idempotent when possible (the client sends an idempotency key), so retries are safe.

Database

  1. Add an index for every column you filter or join on, and check with EXPLAIN before going live.
  2. Put multi-step writes in a transaction — a half-saved record is worse than a failed save.
  3. Use a connection pool; opening a new connection for every request fails under load.

Request IDs: one search to follow a request

The habit that helped me the most is adding a request ID at the first step and logging it everywhere. In Django, this is a small middleware:

import uuid, logging

class RequestIDMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        rid = request.headers.get("X-Request-ID", str(uuid.uuid4()))
        request.request_id = rid
        response = self.get_response(request)
        response["X-Request-ID"] = rid
        logging.getLogger("app").info("req %s %s %s", rid, request.path, response.status_code)
        return response

When a user reports “it failed”, ask for the ID shown in the error message. One search in the logs, and you can see the whole path of that request.

Find the hop, then the bug

Every bug lives at one of the hops between the click and the database. Find the hop first, then the bug: the Network tab, a request ID and EXPLAIN will locate most problems before you even open the editor. Chrome’s DevTools Network reference explains every timing field.