Post

TokoHP: Modern Full-Stack Smartphone E-Commerce

A robust full-stack e-commerce web application for selling smartphones, featuring JWT authentication, role-based access, and a complete shopping cart system built with React and Express/MySQL.

TokoHP: Modern Full-Stack Smartphone E-Commerce

πŸ“– Project Overview

TokoHP is a fast, responsive, and secure full-stack e-commerce web application tailored specifically for selling smartphones. Built entirely with the JavaScript ecosystem (PERN/SERN stack variant using MySQL instead of NoSQL), this platform provides a seamless shopping experience for customers and a powerful management dashboard for administrators.

β€œConnecting gadget lovers with their dream smartphones through a fast, secure, and modern digital storefront.”

🎯 Mission

To design and develop a scalable relational-database e-commerce solution that handles everything from product browsing and cart management to secure user authentication and order processing.


✨ Key Features

πŸ›οΈ Customer Experience

  • πŸ“± Dynamic Product Catalog - Browse a wide range of smartphones with search, filter, sort, and pagination capabilities.
  • πŸ›’ Smart Shopping Cart - Add, remove, and adjust product quantities with real-time calculations.
  • ⚑ Direct Checkout - β€œBuy Now” functionality for instant order processing.
  • πŸ” Secure Authentication - User registration and login using JWT (JSON Web Tokens) with Refresh Token mechanics.
  • πŸ“‹ Order Tracking - Customers can view their order history and track the current status of their deliveries.

βš™οΈ Admin & Management (Role-Based Access)

  • πŸ“Š Product Management (CRUD) - Admins can create, read, update, and delete product listings, complete with image uploads via Multer.
  • πŸ“¦ Order Management - View all customer orders and update shipping/delivery statuses in real-time.
  • πŸ›‘οΈ Advanced Security - Built-in backend protections including Helmet, CORS, Rate Limiting, and Input Validation via Joi.

πŸ› οΈ Technology Stack

CategoryTechnologyPurpose
FrontendReact, ViteFast, component-based interactive UI
StylingTailwind CSSUtility-first CSS for responsive design
HTTP ClientAxiosAPI communication between client and server
Backend FrameworkNode.js & ExpressServer-side routing and RESTful API creation
DatabaseMySQL 8.xRelational database for structured data
AuthenticationJWT & BcryptSecure sessions and password hashing
Validation/LoggingJoi & WinstonStrict input validation and system logging

πŸ—οΈ Architecture & API Endpoints

System Architecture

The project is structured as a clear separation of concerns between the client and server:

  • frontend/: Contains the React application powered by Vite, using React Router for navigation and React Hot Toast for notifications.
  • backend/: Houses the Express server, MySQL connection pools, authentication middleware, and RESTful API controllers.

Core REST API Routes

The backend exposes several structured endpoints, secured via Role-Based Access Control (RBAC):

  • Auth: POST /api/auth/login, POST /api/auth/register, POST /api/auth/refresh
  • Products: GET /api/products (Public), POST /api/products (Admin Only)
  • Cart: GET /api/cart, POST /api/cart (Customer Only)
  • Orders: POST /api/orders/checkout (Customer), PATCH /api/orders/:id/status (Admin)

πŸš€ Installation & Setup

Prerequisites

  • Node.js v20.19+ or v22+
  • MySQL 8.x (or XAMPP)
  • Git

Setup Instructions

1. Setup Database

1
2
3
4
# Open MySQL shell or phpMyAdmin
# Run the schema and seed files to create tables and dummy data
source backend/database/schema.sql;
source backend/database/seed.sql;

2. Setup Backend

1
2
3
4
cd backend
npm install
cp .env.example .env  # Edit with your MySQL database credentials
npm run dev

3. Setup Frontend

1
2
3
cd frontend
npm install
npm run dev

(Demo Accounts: Login as admin@tokoHP.com or budi@email.com to explore the different role perspectives!)


πŸ“Š Project Highlights

Status JavaScript Full Stack

Key Achievements

  • βœ… Relational Data Mastery - Shifted from typical NoSQL MERN stacks to use a robust MySQL relational database design, handling complex joins between users, carts, products, and orders.
  • βœ… Secure Authentication Flow - Implemented a highly secure token-based authentication system using both Access Tokens and Refresh Tokens.
  • βœ… Modern Tooling - Leveraged Vite for blazing-fast frontend builds and Tailwind CSS for rapid, responsive UI development.

πŸ’‘ Conclusion

Building the TokoHP app was a comprehensive exercise in modern full-stack development. By utilizing React alongside Express and MySQL, the project demonstrates how to structure a scalable, relational data-driven application. It perfectly simulates a real-world e-commerce workflow, from uploading product images as an admin to managing a secure checkout session as a customer.


Developed with ❀️ by aipunpratama


πŸ›’ Ready to shop? Don't forget to give the repository a star if you liked this project! ⭐
This post is licensed under CC BY 4.0 by the author.