BiTree
  • Search For Lessons
  • Curriculum
  • Pricing
  • For Educators
  • Become a Tutor
  • About
  • Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
BiTree

Live coding lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Search For Lessons
  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Become a Tutor
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 BiTree. All rights reserved.
Curriculum/Web Development/Introduction to Backend Concepts
50 minIntermediate

Introduction to Backend Concepts

After this lesson, you will be able to: Understand how a backend server works and build a simple HTTP API in Node.js using Express that responds to requests.

Up to now, everything you've built runs in the browser. The backend is the other half: code that runs on a server, talks to a database, and serves data to your frontend. This lesson covers what a backend is, why it exists, and walks through a tiny Node.js + Express API you can run in your editor.

Prerequisites:Your First Full Website Project

Why we need a backend

Anything that has to be private, shared between users, or hidden from view has to live on a server, not in the browser. Examples: storing user accounts, talking to a payment API with secret keys, or making sure two users see the same up-to-date data. A backend is just a program that listens for HTTP requests and returns responses. JSON data, HTML, or files.

Diagram coming soon!

Three-tier diagram. Browser (frontend) ↔ Backend Server (Node + Express) ↔ Database (PostgreSQL), with arrows labeled Request, Response, SQL

Node.js. JavaScript outside the browser

Node.js is a runtime that lets you run JavaScript on a server. It comes with npm, the package manager you'll use to install thousands of open-source libraries. Everything you've learned about JavaScript still applies, but on the server, you also get access to the file system, the network, and (with libraries) databases.

Hello World with Express

Express is the most common Node.js framework for building APIs. It takes about 10 lines to get a server running.

tsx
// server.js
const express = require("express");
const app = express();
app.use(express.json());
app.get("/", (req, res) => {
res.send("Hello from the backend!");
});
app.get("/api/greet", (req, res) => {
const name = req.query.name || "friend";
res.json({ message: `Hello, ${name}!` });
});
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});

Handling POST requests

POST routes accept data in the request body. Combined with express.json(), you can build full APIs.

tsx
const messages = [];
app.get("/api/messages", (req, res) => {
res.json(messages);
});
app.post("/api/messages", (req, res) => {
const { text } = req.body;
if (!text) return res.status(400).json({ error: "text required" });
messages.push({ text, createdAt: Date.now() });
res.status(201).json({ ok: true });
});

ℹ️ Tip. REST conventions

By convention: GET /things lists, GET /things/:id reads one, POST /things creates, PATCH /things/:id updates, DELETE /things/:id removes. Following these makes your API instantly understandable.

Try it: spin up your first Express API

Use the in-browser editor, no local setup required.

  1. 1

    Create a new "Node.js" repl in your editor

  2. 2

    In the Shell tab, run npm install express

  3. 3

    Paste the Hello World code into index.js (or server.js)

  4. 4

    Click Run. your editor will show a URL where your server is reachable

  5. 5

    Visit /api/greet?name=Alex in your browser, you should see JSON

Quick Check

Why can't we put a Stripe secret key in our frontend JavaScript?

Hint: think about what "secret" means.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←Your First Full Website Project
Back to Web Development
Databases and Data Storage→