ABCsteps lesson path

Frontend and Backend: The Full Picture

Map the browser, server, and database responsibilities before building a leaderboard system. Build one artifact, keep one review trail, and make the work easy to inspect later.

Lesson
12
Time
45 min
Access
public lesson

Learning objective

Separate browser, server, and storage responsibilities clearly.

Lab outcome

Draw and implement the first full-stack boundary.

Module milestone

Build a small full-stack leaderboard with persistent data.

Lesson proof workflow

Read, build, then review the evidence.

  1. Vue.js hero workflow iconStep 1ReadStart with Frontend backend split before touching tools.
  2. Node.js hero workflow iconStep 2BuildBuild toward: Draw and implement the first full-stack boundary.
  3. JSON hero workflow iconStep 3ReviewReview the evidence using API contracts.

Toolchain

Full-stack thinking separates browser, server, and storage jobs.

These are the practical surfaces used in this lesson. Learn the habit first, then connect it to the wider engineering ecosystem.

Vue.js iconVue.jsFrontend

Represent the browser-side layer clearly.

Node.js iconNode.jsBackend

Handle logic and API boundaries on the server side.

JSON iconJSONContracts

Keep frontend and backend data agreements explicit.

Proof of work

Leave one inspectable trail from this lesson.

The useful output is not a passive note. It is a small artifact another person can inspect: a working file, a command result, a commit, a screenshot, a README note, or a demo link.

Lesson lab: Draw and implement the first full-stack boundary.

Tool and platform logos are ecosystem references only: no affiliation, endorsement, interview access, hiring promise, salary promise, or placement guarantee.

Vue.js proof icon

Build

Produce the artifact

Complete the lab and keep the result visible: Draw and implement the first full-stack boundary.

Node.js proof icon

Record

Save review evidence

Capture what changed, what broke, and how Frontend backend split became clearer through the work.

JSON proof icon

Explain

Write the vocabulary

Use your own words for System boundaries and API contracts; this is what makes the lesson inspectable later.

Skills companies recognize

Translate the lesson into inspectable work language.

This lesson turns one small lab into the language a learner can use in a README, demo note, or technical conversation. The point is not to collect logos; the point is to explain work clearly enough that another engineer can inspect it.

Where this skill appears

Full-stack teams screen for boundary thinking because unclear responsibilities create fragile products.

Full-stack teamsProduct engineeringSolution engineering

Ecosystem references

AWS skill ecosystem logoGoogle Cloud skill ecosystem logoMicrosoft skill ecosystem logoGitHub skill ecosystem logoCloudflare skill ecosystem logoOpenAI skill ecosystem logoGoogle skill ecosystem logo

Platform and company logos are ecosystem references only: no affiliation, endorsement, interview access, hiring preference, salary outcome, or placement guarantee.

Vue.js skill proof icon

README line

Name the artifact

Lab proof: Draw and implement the first full-stack boundary. Connect it to Frontend backend split so the result reads like work, not a passive note.

Node.js skill proof icon

Review line

Explain the stack

Use Vue.js, Node.js, JSON to explain System boundaries and what changed between the first attempt and the inspected result.

JSON skill proof icon

Conversation line

Answer with evidence

If a team asks about API contracts, use this proof line: Show a diagram or README section that separates browser, server, data contract, and storage responsibilities.

Proof translation

Vue.js proof translation icon

Skill signal

Frontend backend split is the market word. The lesson makes it visible through a small working artifact.

Node.js proof translation icon

Proof artifact

The inspectable artifact is: Draw and implement the first full-stack boundary.

JSON proof translation icon

Interview answer

Use System boundaries and API contracts to explain what changed, what failed, and how you verified it.

Paid guidance

Read publicly. Upgrade when guidance will help you finish.

This lesson remains part of the public written syllabus. Paid help is online-only and human-led: video walkthroughs as they roll out, live class context, WhatsApp Q&A, and project review around the same work.

No account wall, automated checkout, or placement promise is introduced here. Enrollment stays human-led by WhatsApp or call, and the useful proof remains the learner's own artifact.

Vue.js paid guidance icon

Public

Written lesson stays open

Read the prepare and review material for lesson 12 on the public site before buying anything.

Node.js paid guidance icon

Recorded

Recorded and live guidance clarify the work

Paid guidance can add founder-led video walkthroughs as they roll out and live online class context; the teaching explains the work, but does not replace the written lesson.

JSON paid guidance icon

Human

Questions use real context

When stuck, useful guidance starts from the route, error, screenshot, repo fragment, and the lab artifact: Draw and implement the first full-stack boundary.

Phase 1 · Briefing

Lesson briefing

Before You Study (5 mins)

Lesson focus: Every web application — Instagram, your bank, Netflix, the small e-commerce shop your cousin runs — is a system with three roles split across at least two physical machines: a frontend that runs in the user's browser or app, a backend that runs on a server you control, and (in Lesson 14) a database that persists data. Today we cleanly separate these roles. By the end, you will have built a Node.js + Express backend running alongside your Snake game frontend, and you will be able to articulate, with no fuzziness, why certain code lives on the server and certain code lives in the browser.

What you should have ready:

  • Node.js installed (node --version should print 18 or higher)
  • Your Snake game (the frontend you've been building)
  • Lesson 11's ai.js from yesterday — we'll reuse the LLM call from a backend route
  • About 60 minutes
  • An npm init -y ready to run in a fresh backend/ directory

The Concept

A web application's code lives in at least two places, and the boundary between them is one of the most important architectural distinctions you will learn:

text
  ┌────────────────────────┐                          ┌────────────────────────┐
  │      FRONTEND          │   HTTP requests (JSON)   │       BACKEND          │
  │  (browser / mobile)    │  ◀─────────────────────▶ │   (your server)        │
  │                        │                          │                        │
  │  • HTML / CSS / JS     │                          │  • Node.js + Express   │
  │  • What user sees      │                          │  • Business logic      │
  │  • User input handling │                          │  • Auth & sessions     │
  │  • Visual rendering    │                          │  • Talks to DB         │
  │  • Lives on the user's │                          │  • Calls 3rd-party APIs│
  │    device              │                          │  • Lives on a server   │
  │                        │                          │    you control         │
  └────────────────────────┘                          └────────────────────────┘
       Public — anyone can                                  Private — only you
       view source code                                     and your team see it

The reason this split exists is simple: anything you put in the frontend is visible to every user. If you write your LLM API key into a <script> tag, someone can open DevTools, copy your key, and burn through your provider quota by tomorrow morning. If you compute a "10% off" discount in JavaScript, anyone can change it to 100%. If you check if (user.role === "admin") in the browser, the user can edit user.role in DevTools and become an admin.

The inverse is also true: the backend cannot run on the user's screen. It has no DOM, no clicks, no visual rendering. The server's job is to execute logic, talk to other servers, and return data. The frontend's job is to render that data and capture user intent.

Three categories of code, and where each one belongs:

CategoryLives onWhy
Rendering UIFrontendOnly the browser has a screen and a DOM
User input handlingFrontendThe user clicks/types in the browser
Business logic / rulesBackendThe user can't tamper with code on a server they can't see
Database queriesBackendThe DB credentials and connection live on the server
Calling 3rd-party APIs with secretsBackendAPI keys must never leave the server
Auth checks (real ones)BackendThe frontend can lie; the backend cannot
Form validation (UX)BothFrontend for instant feedback; backend for the actual rule

The two halves communicate over HTTP, almost always with JSON bodies. The frontend sends a request (POST /api/scores with { "name": "Divyanshu", "score": 100 }), the backend processes it (validates, stores in DB, computes a response), and sends back JSON ({ "rank": 4, "topScores": [...] }). This is the same request-response cycle from Lesson 09 — but now you control both ends.

The third role — database — is the persistence layer. The backend talks to it; the frontend never does directly. We add this in Lesson 14.

The most common architectural mistake in early full-stack work is putting backend code in the frontend (exposing API keys, computing prices in JavaScript, checking auth in the browser) or putting frontend code in the backend (returning HTML strings instead of JSON). The boundary is the contract; respect it and the system stays clean.

Quick Concepts

TermSimple Meaning
FrontendCode that runs in the browser; the user can see it
BackendCode that runs on a server you control; users can only call it via HTTP
ServerA computer that listens on a network port for incoming requests
ClientThe party making the request — usually a browser, sometimes another server
Express.jsThe most popular Node.js framework for building HTTP servers
EndpointA specific path on your server (/api/scores, /api/login)

What We Will Build

By the end of this lesson, you will have done these specific things:

  1. Created a backend/ directory alongside your Snake game's frontend, ran cd backend && npm init -y to initialize a Node.js project. Inspected the resulting package.json.
  2. Installed Express: npm install express and npm install --save-dev nodemon. Read the package.json dependencies field — recognize that this is JSON (Lesson 08's lesson paying back).
  3. Wrote your first server in backend/server.js:
    javascript
    import express from 'express'
    const app = express()
    app.use(express.json())                       // parse JSON bodies
    
    app.get('/', (req, res) => {
      res.json({ message: 'Hello from your backend!' })
    })
    
    app.get('/api/health', (req, res) => {
      res.json({ status: 'ok', uptime: process.uptime() })
    })
    
    const PORT = 3001
    app.listen(PORT, () => console.log(`Backend running on http://localhost:${PORT}`))
    
    (Note: in package.json add "type": "module" so the import syntax works.)
  4. Ran the server with node server.js. Visited http://localhost:3001 in your browser. Saw the JSON response. Used curl http://localhost:3001/api/health to confirm from the terminal.
  5. Set up nodemon for hot reload: in package.json, add "dev": "nodemon server.js" to the scripts, then run npm run dev. Edit a string in your route handler. Watch the server auto-restart.
  6. Added your first cross-origin call from the frontend. In your Snake game's HTML, add a button "Test backend" that calls fetch('http://localhost:3001/api/health') and displays the result. Discovered the CORS error in the browser console (Cross-Origin Resource Sharing — the browser blocks frontend-on-port-3000 from calling backend-on-port-3001 by default).
  7. Solved CORS by installing cors and adding two lines to your server:
    javascript
    import cors from 'cors'
    app.use(cors())
    
    Reloaded the page. Watched the call succeed. Noted that this is the precise moment most full-stack newcomers get stuck — and now you've solved it deliberately.
  8. Moved the LLM call from Lesson 11 into a backend route: created POST /api/ai-tip that takes { prompt: "..." }, calls the Gemini API server-side (with the API key safely on the server, not exposed to the browser), and returns the response. Added a "Get AI tip" button on the game's loading screen that calls this endpoint.

Step 8 is the architectural moment. The browser sends a prompt to your backend. Your backend uses your secret key to call the model. The browser never sees the key. This is the shape of every production AI app.

Think About

Before studying, consider:

  1. If your Snake game's leaderboard saved scores in localStorage (the browser's local storage), every player sees only their own scores — there is no shared leaderboard. What would have to be true for two players on different devices to see each other's scores? (A shared place where both browsers can write. That place is the backend talking to a database. Module C lessons 13-15 build it.)
  2. Imagine your backend is on a different continent — Tokyo, while your user is in Mumbai. The HTTP round trip is ~150ms. How does that change what kind of work you'd want on the backend vs. inline in the browser? (Hint: things that don't need to feel instant — like saving a score — are fine on the backend; things that need to feel instant — like rendering the snake's next position — must be in the frontend.)

By the End

After this lesson, you'll:

  • ✅ Have a Node.js + Express backend running on port 3001
  • ✅ Have a frontend (your game on port 3000) successfully calling that backend
  • ✅ Have solved your first CORS error deliberately
  • ✅ Be able to articulate which code belongs in the frontend vs. backend
  • ✅ Have moved your LLM call to the backend so your API key is server-side
  • ✅ Understand what req and res are in an Express handler
  • ✅ Be ready for Lesson 13 — making your backend into a real REST API

Two halves, one application. The boundary is the contract. 🧠

Next lesson · 13

Create Your Own API

Build an Express.js server to receive and return data so the app can do more than display a static screen.

Node.js next lesson iconJavaScript next lesson iconJSON next lesson icon