Back to Projects
🤖

Robotics E-Commerce Application

Full-stack e-commerce platform with admin and database integration

JavaScriptNode.jsExpress.jsMySQLJWTbcryptjsHTMLCSSREST APIs
69/16/13%
JS / CSS / HTML
JWT
Auth Method
MySQL
Database
15+
API Endpoints

Project Overview

Built a complete full-stack e-commerce web application for robotics products using Node.js, Express, and MySQL. The application implements JWT-based customer authentication, bcryptjs password hashing, product catalog with browsing and reviews, shopping cart and order workflow, and an admin interface for stock management protected by an environment-variable admin password.

The Problem

Demonstrating full-stack e-commerce development requires integrating a frontend UI, backend API, MySQL schema, secure JWT authentication, and an admin layer into a coherent, working application.

The Solution

Built a multi-tier web application with HTML/CSS/JS frontend, a Node.js/Express REST API backend, and a MySQL relational database — implementing the complete customer and admin journeys from product discovery to order completion.

Key Highlights

  • Node.js + Express backend with MySQL persistence (db:init and db:seed scripts)
  • JWT-based customer authentication for secure session management
  • bcryptjs password hashing for secure credential storage
  • Product catalog with browsing, filtering, and persistent customer reviews
  • Shopping cart with quantity management and order tracking
  • Admin stock updates protected by ADMIN_PASSWORD environment variable
  • Environment-variable configuration (.env) for all sensitive credentials
  • Start/stop PowerShell scripts for local development workflow

System Architecture

01.Frontend: HTML, CSS, JavaScript (68.9% JS / 16.4% CSS / 12.6% HTML)
02.Backend: Node.js + Express REST API under /server directory
03.Database: MySQL with normalized schema (users, products, orders, order_items, reviews)
04.Authentication: JWT tokens for customers; ADMIN_PASSWORD env var for admin routes
05.Security: bcryptjs for password hashing, JWT_SECRET for token signing
06.Dev tooling: npm run db:init, db:seed, start; start-local.ps1 / stop-local.ps1

Code Spotlight

Real snippets from the codebase demonstrating key engineering decisions.

auth.middleware.js
javascript
1const jwt    = require('jsonwebtoken');
2const bcrypt = require('bcryptjs');
3
4// JWT authentication middleware
5function authenticateToken(req, res, next) {
6  const token = req.headers['authorization']?.split(' ')[1];
7  if (!token) return res.status(401).json({ error: 'Access denied' });
8
9  jwt.verify(token, process.env.JWT_SECRET, (err, user) => {
10    if (err) return res.status(403).json({ error: 'Invalid token' });
11    req.user = user;
12    next();
13  });
14}
15
16// Secure login — constant-time compare via bcrypt
17async function login(req, res) {
18  const { email, password } = req.body;
19  const [user] = await db.query(
20    'SELECT * FROM users WHERE email = ?', [email]  // parameterized
21  );
22  if (!user || !(await bcrypt.compare(password, user.password_hash)))
23    return res.status(401).json({ error: 'Invalid credentials' });
24
25  const token = jwt.sign({ id: user.id, email }, process.env.JWT_SECRET, { expiresIn: '7d' });
26  res.json({ token });
27}

Challenges & How I Solved Them

1

Designing JWT token lifecycle management for customer sessions

2

Implementing role separation between customer and admin routes without a full RBAC system

3

Building a checkout flow that atomically deducts inventory and records orders

4

Managing database schema initialization and seeding reproducibly across environments

Results

  • Fully functional e-commerce application with customer and admin workflows
  • Secure JWT authentication and bcryptjs-hashed credentials
  • MySQL-backed schema covering users, products, orders, order items, and reviews
  • Reproducible setup via db:init and db:seed npm scripts

Future Improvements

Add Stripe sandbox for payment processingImplement product rating aggregation and review moderationAdd inventory low-stock alertsDeploy to cloud hosting with CI/CD pipeline