HTML (HyperText Markup Language) is the language of the web. Browsers parse HTML to build the document tree (DOM) that you style with CSS and script with JavaScript.
Tip: Use View Source on any real page to see how authors structure markup in practice.
Document structure
Every HTML5 document should declare a doctype, wrap content in <html>, split metadata (<head>) from visible content (<body>), and specify a language on the root element for accessibility.
Headings (h1–h6) form an outline. Paragraphs use <p>. Lists use <ul>/<ol> with <li>. Links use <a href="...">. Images use <img src="..." alt="..."> — always include meaningful alt text.
Try it
Edit the snippet (or reset) and click Run to preview in a sandboxed frame. No network requests are made.
Live preview
HTML Forms
Forms collect user input. The <form> element wraps controls, action and method define where and how data is sent (GET or POST).
Input types
type="text", email, tel, number, date, checkbox, radio, file, and submit are common. Use <label for="id"> tied to input id for accessibility.
HTML5 introduces elements that describe meaning: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>. They help screen readers and SEO without changing default styling much.
When to use section vs article
Use article for self-contained content (a blog post, a card). Use section for thematic grouping inside a document. A page can have multiple articles; each article can contain sections.
CSS Tutorial
CSS (Cascading Style Sheets) sets presentation: colours, layout, typography, and animations. Rules apply selectors to declaration blocks.
Selectors
Element (p), class (.btn), ID (#app), attribute ([type="checkbox"]), and combinators (nav a, .card > h2) target nodes in the DOM.
Specificity: inline styles > IDs > classes > elements. Equal rules — last one wins unless !important (avoid when possible).
Box model
Every box has content, padding, border, and margin. box-sizing: border-box is widely used so width includes padding and border.
CSS Flexbox
Flexbox lays out one-dimensional rows or columns. Set display: flex on a container, then use justify-content and align-items to distribute space.
JavaScript runs in the browser and on Node.js. It is dynamically typed, supports first-class functions, and uses prototypes (or classes) for object-oriented patterns.
Variables
let and const are block-scoped; prefer const unless reassignment is needed. var is function-scoped and largely obsolete in new code.
DOM
document.querySelector returns the first match; querySelectorAll returns a static NodeList. Listen for events with addEventListener.
JSON
JSON (JavaScript Object Notation) is a text format for data exchange. In JS, JSON.parse(str) parses a string; JSON.stringify(obj) serialises an object.
const data = JSON.parse('{"ok":true,"x":42}');
console.log(data.x);
Fetch & AJAX
The Fetch API returns Promises. Use async/await or .then() to handle responses. Check response.ok before parsing JSON.
async function load() {
const r = await fetch('/api/data');
if (!r.ok) throw new Error(r.status);
return r.json();
}
SQL Tutorial
SQL queries relational databases. SELECT reads rows; INSERT, UPDATE, DELETE change data. Use WHERE to filter and JOIN to combine tables.
Parameterised queries (prepared statements) prevent SQL injection — never concatenate raw user input into SQL strings.
SELECT u.name, COUNT(o.id) AS orders
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id;
Node.js intro
Node.js runs JavaScript on the server with the V8 engine. It uses a non-blocking event loop and npm for packages. Common patterns: HTTP servers with http or frameworks like Express; fs for files; path for paths.
Run these terminal commands in order to get the project running.
Create the project folders: mkdir backend then mkdir frontend
Create the frontend with React: cd frontend then npx create-react-app . (or manually create package.json and run npm install)
Install backend dependencies: cd backend then npm install
Create the route folder: mkdir routes (inside backend)
Create all the files listed above and paste the code from each section below
Seed the database: cd backend then node seed.js
Start the backend: node server.js (runs on port 5000)
Start the frontend: cd frontend then npm start (runs on port 3000)
Demo login after seeding: john@email.com / password123
Backend: package.json
Dependencies: Express for the server, cors for cross-origin requests, sql.js for SQLite, bcryptjs for password hashing.
backend/package.json
Backend: database.js
Sets up the SQLite database using sql.js. Creates a Statement wrapper class so we can use .prepare().all(), .get() and .run() methods. Also creates all 6 tables: users, products, deals, orders, order_items, and rewards.
backend/database.js
Backend: server.js
Main entry point. Initializes the database asynchronously, then sets up Express with CORS and JSON middleware, mounts the API routes, and starts listening on port 5000.
backend/server.js
Backend: seed.js
Run with node seed.js to populate the database with sample products (37 items across 8 categories), deals, demo users, and order history.
backend/seed.js
Backend: routes/products.js
REST API routes for products. Supports filtering by category, searching by name, fetching categories, getting active deals (with a JOIN to the products table), and fetching a single product by ID.
backend/routes/products.js
Backend: routes/orders.js
Handles fetching a user's order history (with a JOIN to get item details) and creating new orders. When an order is placed, it calculates the total, inserts order items, and awards loyalty reward points (1 point per pound spent).
backend/routes/orders.js
Backend: routes/users.js
User authentication routes (register and login with bcrypt password hashing), plus reward points endpoints for viewing history and redeeming points.
backend/routes/users.js
Frontend: package.json
React app dependencies. Uses react-router-dom for page navigation and react-scripts for the dev server and build tooling.
frontend/package.json
Frontend: public/index.html
The HTML shell. React mounts into the div with id "root".
frontend/public/index.html
Frontend: src/index.js
Entry point. Wraps the App in BrowserRouter (for routing), UserProvider and CartProvider (for global state).
frontend/src/index.js
Frontend: src/index.css
Global CSS reset. Removes default margins, sets the base font, and resets link/button/input styles.
frontend/src/index.css
Frontend: src/App.js
Root component. Renders the Navbar, defines all Routes using React Router, and includes a footer.
frontend/src/App.js
Frontend: src/App.css
All the styles for the entire application — navbar, slide-out basket, footer, hero, product grid, cards, forms, checkout layout, auth pages, and responsive breakpoints. This is the longest file.
frontend/src/App.css
State Management: CartContext.js
React Context for the checkout basket. Provides addToCart, removeFromCart, updateQuantity, clearCart, plus computed cartTotal and cartCount values to all components.
frontend/src/context/CartContext.js
State Management: UserContext.js
React Context for the logged-in user. Persists user data to localStorage so the session survives page refreshes.
frontend/src/context/UserContext.js
Component: Navbar.js
Navigation bar with logo, page links, basket button with item count badge, and login/logout. Includes a slide-out panel with quantity controls and checkout links for delivery or collection.
frontend/src/components/Navbar.js
Component: ProductCard.js
Reusable product card used on the Home, Products, and Deals pages. Shows the image (emoji), name, description, price (with deal price if applicable), and an add button with a brief confirmation state.
frontend/src/components/ProductCard.js
Page: Home.js
Landing page with a hero banner, category grid linking to filtered listings, a preview of current promotions, and featured items from the first category (Electronics).
frontend/src/pages/Home.js
Page: Products.js
Browse all products with a sidebar category filter and search bar. Uses useSearchParams to read/write the category from the URL query string. Fetches deals to show discount badges on matching products.
frontend/src/pages/Products.js
Page: Deals.js
Shows all active deals with a red banner and product cards displaying discount percentages and original/deal prices.
frontend/src/pages/Deals.js
Page: OrderHistory.js
Displays the logged-in user's past orders. Each order card shows the order number, date, status badge, item list, delivery/collection info, and total. Requires authentication.
frontend/src/pages/OrderHistory.js
Page: Rewards.js
Shows the user's loyalty points balance, points value in pounds, a redeem button (when 100+ points), and a full history of earned/redeemed points.
frontend/src/pages/Rewards.js
Page: Collection.js
Pickup checkout page. User selects a branch from a dropdown, picks a date and time slot, reviews the order summary, and submits. Success screen shows confirmation and loyalty points.
frontend/src/pages/Collection.js
Page: Delivery.js
Home delivery checkout page. User enters their address, postcode, selects a date and time slot. Includes a delivery fee (£3.99, free over £40). Order summary with running total. Success screen on completion.
frontend/src/pages/Delivery.js
Page: Login.js
Combined login and registration page. Toggles between login and register forms. Sends credentials to the backend API and stores the returned user data in UserContext on success.