Lesson 1 Β· The big picture

πŸŒ‰ Full-Stack Architecture

Building a frontend and a backend separately is only half the job. Full-stack work is about how the two sides fit together: who owns which piece of state, and how a change on one side ripples to the other.

πŸŒ‰ The client-server split

The client (browser or mobile app) renders UI and reacts to the user; the server owns the real data and the rules for changing it. A client should never be trusted to enforce a business rule on its own β€” it can be bypassed entirely by anyone calling the API directly.

Client: "Hide the Delete button unless the user is an admin" β€” a UI convenience Server: "Reject the delete request unless the user is actually an admin" β€” the real rule Without the server-side check, anyone can call DELETE /posts/5 directly and bypass the hidden button.
Common mistake. Enforcing a permission or validation rule only in the frontend. Treat every client-side check as a convenience, and repeat the real check on the server.

🖼️ See it

Client vs server responsibilityπŸ–₯️Client: UI, UX,convenience checksπŸ—„οΈServer: real data,real rules, sourceof truth

🖼️ See it

Server state vs UI stateServer stateLives in the databaseThe source of truthCan go stale in a client cacheUI stateModal open/closed, form inputLives only in the frontendNever needs to reach the server

πŸ—οΈ Where state actually lives

Full-stack apps juggle several kinds of state: server state (the database β€” the source of truth), client cache (a local copy of server data, which can go stale), and UI state (a modal being open, a form's current input) that belongs only in the frontend.

Keep UI state out of the backend. "Is this dropdown open" never needs to reach the server β€” mixing it with real data state makes both harder to reason about.

πŸ“ One repo or two?

A monorepo keeps frontend and backend code together, making shared types and coordinated changes easier; separate repos keep teams and deploy cycles more independent. Neither is strictly correct β€” the right choice depends on team size and how tightly the two sides change together.

Monorepo: /frontend, /backend, /shared-types (one PR can change all three) Separate: frontend-repo, backend-repo (each deploys and versions independently)

πŸͺœ Step by step: deciding where state lives

Put each piece of state where it must be trusted or shared: the server for truth, the client for UI-only details.

Problem: A shop app has: cart contents, product prices, whether the menu is open, and the logged-in user’s role. Decide where each lives.

  1. Product prices. Must be trusted.
    server (database)
  2. User role. Must be trusted.
    server; client only gets a copy for display
  3. Cart contents. Should survive device changes.
    server, cached on the client
  4. Menu open/closed.
    client only (UI state)
  5. Rule of thumb. If a wrong value could cost money or access, the server decides.

Answer: prices, role and cart on the server; menu state on the client.

Common mistake: trusting a price or role sent from the browser. Users can change anything on the client.
✏️ Quick check · 1 of 8
Trust boundary

Hiding a "Delete" button for non-admins in the UI, with no server-side check, means:

What stops someone from calling the API directly, skipping the button?
✏️ Quick check · 2 of 8
Trust boundary

The safest place to enforce a real business rule (like "only admins can delete posts") is:

Which side can a malicious client never route around?
✏️ Quick check · 3 of 8
State

"A modal dialog is currently open" is an example of:

Does the server need to know or care whether a modal is open?
✏️ Quick check · 4 of 8
State

A list of products shown in the UI, originally loaded from the server and then not re-fetched for an hour, is:

What can happen to the real data on the server during that hour?
✏️ Quick check · 5 of 8
Architecture

The main benefit of a monorepo containing both frontend and backend code is:

What becomes easier when frontend and backend code sit in the same repo?
✏️ Quick check · 6 of 8
Architecture

Separate frontend and backend repositories mainly help with:

What becomes easier when the two sides are decoupled into separate repos?
✍️ Type your answer · 7 of 8

An API has 12 endpoints. A security review finds that 3 of them only validate permissions on the client side.

How many endpoints correctly enforce permissions on the server?

Enter a whole number.
Subtract the client-only-validated endpoints from the total.
✍️ Type your answer · 8 of 8

A product list is cached on the client and refreshed every 5 minutes. A user keeps the page open for 37 minutes.

How many times does the cache refresh during that time (not counting the initial load)?

Enter a whole number.
Divide the total time by the refresh interval, rounding down.
📝 Lesson quiz · 5 questions
0 / 5
Re-read the lesson, then give it another go.
Question 1 of 5

A business rule enforced only on the client is:

Question 2 of 5

"Is this dropdown open" is an example of:

Question 3 of 5

A client-side cache of server data can become:

Question 4 of 5

A monorepo mainly helps with:

Question 5 of 5

The server, compared to the client, should be treated as: