← Back to Projects

Exam project — Full-stack e-commerce

Noroff EP E-Commerce

A REST API and admin dashboard for an online store. Built with Node, Express, Sequelize and MySQL — with JWT authentication, raw SQL search, automatic membership discounts, and full Swagger documentation.

Node.js Express MySQL Sequelize JWT EJS Bootstrap Swagger Jest + Supertest

Backend API and admin dashboard, kept separate

The backend serves JSON to anyone — a customer app, Postman, or Swagger. The admin dashboard is a separate Express + EJS app that talks to the backend over HTTP, the same way any other client would.

localhost:3000

Backend API

Express, Sequelize and MySQL. Handles auth, products, carts, orders and membership logic.

  • JWT auth — register, login, 2 hour tokens
  • Products, brands, categories with soft delete
  • Cart, checkout and order history
  • Raw SQL for product search and listing
  • Swagger UI at /doc

localhost:3001

Admin dashboard

Express + EJS + Bootstrap. Admin-only login, talks to the API via axios.

  • Manage products, brands and categories
  • Search products by name, brand or category
  • View orders and update status
  • Promote users to admin
  • Edit membership discount percentages

Membership tiers, calculated automatically

Every checkout adds to a customer's lifetime item count. Once they cross a threshold, their membership upgrades and the new discount applies from their next order.

Bronze0–14 items purchased
0%
Silver15–29 items purchased
15%
Gold30+ items purchased
30%

The membership and discount used at checkout are stored on the order itself — discount and MembershipId — so each order keeps an accurate record even after the customer's tier changes later.

A consistent, predictable response shape

Every endpoint returns { status, statuscode, data } — success and error responses follow the same structure throughout.

POST
/auth/register Validates input, hashes password with bcrypt
POST
/auth/login Login with username or email, returns a JWT
GET
/products Raw SQL join — returns brand and category names inline
POST
/search Raw SQL — matches product name, brand or category
POST
/cart Adds an item, checks stock before adding
POST
/cart/checkout/now Creates the order, applies discount, updates membership
PUT
/orders/:id/status Admin updates order status — in progress, ordered, completed
PUT
/users/:id/role Admin promotes a registered user to admin

How the pieces talk to each other

Admin dashboard

Express + EJS

REST API

Express + JWT

Swagger / Postman

API clients

REST API

Express + JWT

Database

MySQL + Sequelize

Tools and libraries

Runtime

Node.js

Framework

Express

Database

MySQL

ORM

Sequelize

Auth

JWT + bcrypt

Views

EJS

Styling

Bootstrap

Docs

Swagger

Testing

Jest + Supertest

HTTP client

Axios