The Full-Stack Picture Book
DATABASE · remembers BACKEND · thinks FRONTEND · shows SERVER 🔒 = icing of security
PLATE 0 — Every website is a three-layer cake on a plate.
A picture book for grown-ups

How Websites Work

Nine spreads. One picture each. By the last page you can explain, in an interview or a meeting, how a click on a button turns into a row in a database and back into pixels.

Say it like a pro

"It's a three-tier app: a React frontend, a REST API on Node, Postgres underneath, all containerized and deployed behind a reverse proxy with TLS."

Every word in that sentence gets its own page. Use the tabs above or the arrow keys.

Browser DNS shop.com → 93.184.x.x 1. where is it? Internet TCP + TLS 2. HTTPS Server DB 3. query 4. response: HTML / JSON
PLATE 1 — The round trip. Memorize these four arrows.
Chapter 1 · The map

What actually happens when you type a URL

  1. DNS lookup. The browser asks "where is shop.com?" and gets back an IP address.
  2. Connection. It opens a TCP connection, then a TLS handshake makes it HTTPS (encrypted).
  3. Request. It sends GET /products HTTP/1.1 with headers and cookies.
  4. Server work. The backend runs code, maybe asks the database, builds a response.
  5. Response. Status code (200, 404, 500) plus HTML or JSON.
  6. Render. The browser parses HTML, applies CSS, runs JavaScript, paints pixels.
client
whatever asks (the browser, a phone app)
server
whatever answers
HTTP verbs
GET read · POST create · PUT/PATCH update · DELETE remove
HTML the frame CSS paint + layout JavaScript wiring: clicks, data, life
PLATE 2 — Structure, style, behavior. Never mix them up in conversation.
Chapter 2 · Frontend (client side)

The part people see and touch

The frontend runs inside the user's browser. Its job: show data and collect input. It never holds secrets.

<form id="signup">
  <input name="email" type="email" required>
  <button>Join</button>
</form>
<script>
signup.onsubmit = async (e) => {
  e.preventDefault();
  await fetch("/api/users", {
    method: "POST",
    headers: {"Content-Type": "application/json"},
    body: JSON.stringify({ email: e.target.email.value })
  });
};
</script>

How to build it

  1. Sketch screens (wireframes), then write semantic HTML.
  2. Style with CSS: Flexbox and Grid for layout, media queries for phones.
  3. Add JS that calls your API with fetch and updates the page.
  4. Grow into a framework (React, Vue, Svelte) when state gets messy.
Say it like a pro

"It's a responsive SPA; components fetch from the API and we keep accessibility in mind with semantic markup."

Order POST /orders Router which dish? Middleware auth · logging Controller business logic Pantry/DB Response 201 Created {"id":42} THE KITCHEN · nobody sees inside
PLATE 3 — Ticket in, router, guards, cook, plate out.
Chapter 3 · Backend (server side)

The kitchen behind the counter

The backend runs on your machine, not the user's. It validates input, enforces rules, talks to the database, and holds the secrets (API keys, DB passwords).

// Node + Express
import express from "express";
const app = express();
app.use(express.json());           // middleware

app.post("/api/users", async (req, res) => {
  const { email } = req.body;
  if (!email?.includes("@"))
    return res.status(400).json({ error: "bad email" });
  const user = await db.user.create({ data: { email } });
  res.status(201).json(user);
});

app.listen(3000);

How to build it

  1. Pick a language + framework (Node/Express, Python/FastAPI, Go, C#/.NET).
  2. Design your API: resources and routes (/users, /orders/:id).
  3. Validate every input. Return correct status codes.
  4. Keep config in environment variables, never in code.
Say it like a pro

"The API is stateless and RESTful; auth is a middleware, and controllers stay thin with logic in a service layer."

SQL · tables users idemail 1ana@x.io 2bo@y.com orders iduser_idtotal 7149.00 foreign key → NoSQL · documents { "_id": 1, "email": "ana@x.io", "orders": [ { "total": 49 } ] } stored on disk, survives restarts
PLATE 4 — Strict cabinet or flexible folders. Know when to use each.
Chapter 4 · Database

The memory that outlives the page

Servers restart; data must not vanish. The database is the permanent store. Only the backend talks to it.

CREATE TABLE users (
  id         SERIAL PRIMARY KEY,
  email      TEXT UNIQUE NOT NULL,
  pw_hash    TEXT NOT NULL,
  created_at TIMESTAMPTZ DEFAULT now()
);
SELECT u.email, SUM(o.total)
FROM users u JOIN orders o ON o.user_id = u.id
GROUP BY u.email;

How to build it

  1. Model your nouns (users, products, orders) and how they relate.
  2. Default to relational (PostgreSQL). Reach for MongoDB when shapes really vary, Redis for cache.
  3. Use migrations so schema changes are versioned like code.
  4. Index columns you search on. Back up daily, and test the restore.
ORM
code library that maps tables to objects (Prisma, SQLAlchemy)
ACID
transactions are all-or-nothing and safe
CRUD
Create, Read, Update, Delete
moat: HTTPS / TLS AuthN who are you? AuthZ may you? vault: bcrypt hashes ' OR 1=1 -- blocked by validation ! rate limit + logs DEFENSE IN DEPTH
PLATE 5 — No single wall. Layers, so one failure isn't the end.
Chapter 5 · Security

Lock every door, not just the front one

Rule zero: never trust the client. Anything from the browser can be faked. Re-check it all on the server.

  1. HTTPS everywhere. Free certs from Let's Encrypt; redirect all HTTP.
  2. Hash passwords with bcrypt or Argon2. Never store or log plain text.
  3. Authentication (who you are): sessions in HttpOnly; Secure; SameSite cookies, or JWTs, or OAuth "Sign in with Google".
  4. Authorization (what you may do): check ownership on every request. "User 2 can't read order 7."
  5. Stop injection: parameterized queries, never string-built SQL.
  6. Stop XSS: escape output, set a Content-Security-Policy.
  7. Stop CSRF: SameSite cookies or CSRF tokens on forms.
  8. Secrets in env vars / a vault, rate-limit logins, update dependencies, log and monitor.
// ✗ injectable
db.query(`SELECT * FROM users WHERE email='${email}'`)
// ✓ parameterized
db.query("SELECT * FROM users WHERE email=$1", [email])
Say it like a pro

"We follow the OWASP Top 10: parameterized queries, hashed creds, least privilege, CSP headers, and secrets out of the repo."

FRONTEND drawer React · Vue · Svelte · Angular + Tailwind for styling · Vite to bundle BACKEND drawer Express/Nest (JS) · Django/FastAPI (Py) Spring (Java) · ASP.NET (C#) · Laravel (PHP) FULL-STACK drawer Next.js · Nuxt · SvelteKit · Remix · Rails
PLATE 6 — Frameworks are pre-built drawers of tools. Pick one per drawer.
Chapter 6 · Frameworks & stacks

Don't build the hammer. Use the toolbox.

A framework hands you routing, structure, and conventions so you write only the parts unique to your app. A stack is the combo you pick.

MERN
MongoDB · Express · React · Node
PERN
same with PostgreSQL
LAMP
Linux · Apache · MySQL · PHP (the classic)
T3 / Next
Next.js + TypeScript + Prisma + Postgres
Django
Python, "batteries included": admin, ORM, auth built in

How to choose

  1. Use the language you or your team already know.
  2. One person, shipping fast? A full-stack framework (Next.js, Django, Rails).
  3. Separate mobile + web clients? A standalone API backend plus a frontend framework.
  4. Check community size and docs. Boring and popular beats new and shiny.
Say it like a pro

"We went with Next.js for SSR and SEO, Prisma as the ORM, Postgres on a managed host. It keeps the team in TypeScript end to end."

git push CI/CDtest · build Docker image CDN static files Users Load balancerNginx · TLS app #1 app #2 app #3 Managed DB scale out = add boxes
PLATE 7 — From your laptop to the world, automatically, every push.
Chapter 7 · Servers, hosting & deployment

Getting it off your laptop

A server is just a computer that's always on and reachable. You rent one; you don't buy one.

Static host
Netlify, Vercel, GitHub Pages, S3+CloudFront: plain HTML/CSS/JS
PaaS
Render, Railway, Heroku, Fly.io: push code, they run it
VPS / IaaS
DigitalOcean, AWS EC2, Azure VM: a Linux box, you manage it
Serverless
AWS Lambda, Cloudflare Workers: functions billed per call
Containers
Docker packages app + deps; Kubernetes runs many of them
# Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

How to deploy (VPS route)

  1. Buy a domain; point an A record at your server's IP.
  2. SSH in, install Docker, harden SSH (keys only, firewall ports 22/80/443).
  3. Run your container; put Nginx in front as a reverse proxy.
  4. Get HTTPS with Certbot. Set up CI (GitHub Actions) to redeploy on push.
  5. Add monitoring, logs, and uptime alerts.
Say it like a pro

"CI builds a Docker image on merge to main, pushes to a registry, and we roll it out behind a load balancer with zero-downtime deploys."

Browser CDN API Postgres ① GET /login ② HTML, CSS, JS ③ POST /api/login {email,pw} ④ SELECT ⑤ row ⑥ bcrypt.compare ✓ make session ⑦ 200 + Set-Cookie ⑧ GET /api/me (cookie) → React renders "Hi, Ana"
PLATE 8 — A login, end to end. Every chapter shows up once.
Chapter 8 · How it all comes together

One login, every layer

  1. DNS + CDN serve the frontend bundle fast from a nearby edge.
  2. Frontend renders the form and POSTs JSON over HTTPS.
  3. Load balancer / Nginx terminates TLS, forwards to one app container.
  4. Backend middleware rate-limits and validates; the controller runs.
  5. Database is queried with a parameterized statement.
  6. Security: bcrypt compares the hash; a session cookie is issued.
  7. Response flows back; the frontend updates state and shows the dashboard.
  8. CI/CD + monitoring made sure this exact code was tested and is being watched.

Project folder, for real

my-app/
├─ frontend/      React (Vite) → built to static files
├─ backend/       Express API, routes/, services/
│  └─ prisma/     schema + migrations
├─ docker-compose.yml   api + postgres locally
├─ .env.example   DATABASE_URL, SESSION_SECRET
└─ .github/workflows/deploy.yml
1plan + wireframe 2static frontend 3API + routes 4database 5auth + security 6tests + Docker 7CI/CD deploy 8launch + monitor
PLATE 9 — The order real teams follow. Ship small, then layer up.
Chapter 9 · Your build order

The road from idea to live site

  1. Plan. Write user stories ("as a shopper I can…"), sketch screens, list your data nouns.
  2. Static frontend. HTML/CSS pages with fake data. Deploy it to a static host on day one.
  3. API. Stand up the backend with one route returning JSON. Wire fetch to it.
  4. Database. Add Postgres via Docker Compose, define the schema, run migrations.
  5. Auth + security. Signup/login, hashed passwords, ownership checks, HTTPS.
  6. Tests + container. Unit and API tests; a Dockerfile so it runs the same everywhere.
  7. CI/CD. GitHub Actions: test → build → deploy on every merge to main.
  8. Launch + watch. Domain, TLS, logging, error tracking (Sentry), backups, uptime alerts.
The cheat sentence

"Frontend shows, backend thinks, database remembers, security guards, servers host, frameworks speed it up, and CI/CD ships it."