Skip to main content

Lesson 4 of 4 18 min read

How frontend, backend and database work together

Trace one user action through every layer of a full-stack application, including authentication and error handling.

In this lesson you will

  • Describe the architecture of a typical full-stack application
  • Trace a request from a click to the database and back
  • Explain where validation, authentication and error handling happen

The architecture at a glance

  1. Browser (React UI)
  2. HTTPS + JSON
  3. Backend API (Spring Boot or Node.js)
  4. SQL
  5. Database (PostgreSQL)
5-step diagram
  • The browser renders the user interface and sends HTTP requests.
  • The backend API applies business rules, checks who the user is and what they may do, and reads or writes data.
  • The database stores the data permanently.

In production there are usually a few more pieces: a CDN that serves static files quickly from servers near the user, a reverse proxy or load balancer that spreads traffic across several backend servers, and services for email, payments or file storage.

Tracing one action: marking a lesson complete

A learner clicks Mark as completed on a lesson. Here is what happens:

  1. Browser: a click handler sends PUT /api/me/lessons/42/complete. The session cookie travels with the request automatically.
  2. Backend, authentication: the server reads the session cookie and identifies the learner. If the session has expired it replies 401 Unauthorized.
  3. Backend, validation: it checks that lesson 42 exists and is published. If not, it replies 404 Not Found.
  4. Backend, database: it runs a query that records the completion. Using a unique key on (learner, lesson) means clicking twice does not create a duplicate.
  5. Backend, response: it replies 200 OK with the learner's updated progress as JSON.
  6. Browser: the interface shows a tick and updates the progress bar.
Marking lesson 42 complete

Browser sends to Backend: PUT /api/me/lessons/42/complete + session cookie. Backend sends to Backend: check the session and the lesson. Backend sends to Database: save the completion (learner, lesson). Database replies to Backend: saved. Backend replies to Browser: 200 OK + progress JSON

Where each concern lives

ConcernFrontendBackendDatabase
Show a friendly message✔
Validate input✔ (fast feedback)✔ (enforced)✔ (constraints)
Who is the user?Displays itVerifies the sessionStores accounts
Business rules✔
Data integrity✔✔ (keys, transactions)

Handling failure gracefully

Networks drop, servers restart and users double-click. Good full-stack applications plan for it:

  • Show a loading state while waiting, and a clear error message with a Try again option when a request fails.
  • Disable a submit button while its request is in progress to avoid duplicate submissions.
  • Make important operations idempotent, so repeating the same request produces the same result.
  • Log errors on the server with enough detail to investigate, without logging passwords or personal data.

What a full-stack developer does day to day

A typical feature, such as "learners can bookmark lessons", touches every layer: a database table for bookmarks, API endpoints to add, remove and list them, and frontend components for the bookmark button and a list page. Being able to design and connect all of these pieces is what makes full-stack skills valuable.

Hands-on exercise

Choose a feature such as "post a comment on a lesson". Write the full journey as numbered steps, like the walkthrough above: the user action, the HTTP method and URL, the checks the backend performs, the database change, the response status and what the interface shows. Add one step describing what should happen if the network fails halfway.

Knowledge check

3 questions • 70% to pass • Practice only, no certificate

  1. 1.Which component balances traffic across several backend servers?
  2. 2.A learner's session has expired and they click Mark as completed. What should the API return?
  3. 3.What does it mean for an operation to be idempotent?
0 of 3 answered

Key concepts

  • A full-stack application is a browser UI, a backend API and a database connected over HTTP and SQL.
  • Each request is authenticated, validated, processed against the database and answered with a status and JSON.
  • Validation happens in every layer, but only the backend and database can enforce it.
  • Robust apps show loading and error states, prevent duplicate submissions and make operations idempotent.

Optional next step: DevCrest Academy

Full-Stack JavaScript (MERN + Next.js)

Want to build every layer yourself? The academy course covers MongoDB, Express, React, Node.js and Next.js through hands-on projects from the first screen to deployment.

  • Beginner
  • 16 weeks • 130 hours
  • Online Live
  • From ₹7,500 per student

Fees and batch dates are sample data pending confirmation

Or keep learning for free with Programming Fundamentals.