Skip to content

Latest commit

ย 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›’ TechStore โ€” CodeAlpha E-Commerce Platform

A full-stack electronics e-commerce web application with JWT authentication, persistent cart management, and complete order processing.

CodeAlpha Internship โ€” Full Stack Web Development | Task 1

Frontend Build Tool Backend API Database Authentication License

๐Ÿ“ฆ GitHub Repository


๐Ÿ“– Overview

TechStore is a full-stack electronics e-commerce platform built with React + Vite on the frontend and Node.js + Express + SQLite on the backend.

The application delivers a complete shopping experience โ€” product browsing, authentication, persistent shopping carts, secure checkout, order history, responsive layouts, and light/dark theme support.

This project was developed as Task 1 of the CodeAlpha Full Stack Web Development Internship, with a focus on building, testing, and deploying a complete, production-ready full-stack web application.


โœจ Key Features

๐Ÿ›๏ธ Product Catalog

  • 25+ realistic consumer technology products
  • Multiple categories: Audio, Computer Accessories, Workspace, Mobile Accessories, Wearables, Gaming, and Networking
  • Category filtering chips with keyboard-accessible navigation
  • Horizontal scroll snapping for category navigation
  • Interactive product cards with whole-card navigation and dedicated CTA buttons

๐Ÿ“ฆ Product Details

  • High-resolution product images
  • Real-time stock indicators
  • Quantity selectors
  • Detailed product information and pricing
  • Warranty and free-shipping value propositions
  • Add-to-cart feedback banners with direct navigation to the cart

๐Ÿ” Authentication & Security

  • User registration and login
  • JSON Web Token (JWT) authentication
  • Password hashing with bcryptjs
  • Security-question setup during registration
  • Three-step password recovery flow (email verification โ†’ security-question verification โ†’ password reset)
  • Protected cart and order routes

๐Ÿ›’ Shopping Cart

  • Persistent shopping cart
  • Real-time stock validation preventing over-ordering
  • Quantity controls and individual line-item removal
  • Full cart clearing and total calculation
  • Empty-cart state with clear calls-to-action
  • Support for authenticated and guest shopping experiences

๐Ÿ’ณ Checkout & Order Processing

  • Shipping-address form with validation
  • Atomic order creation using SQLite transactions
  • Product prices captured at time of checkout
  • Automatic cart clearing after successful order creation
  • User-isolated order history with individual order receipt/detail views

๐ŸŽจ Design System & UX

  • Light and dark theme support, persisted via localStorage
  • Zero flash-of-unformatted-content (FOUC) during theme loading
  • Custom UI built with CSS Modules
  • Consistent design tokens with a 4px/8px spacing rhythm
  • Three-level elevation system
  • lucide-react iconography
  • Responsive layouts for mobile, tablet, and desktop

๐Ÿ› ๏ธ Tech Stack

Layer Technologies
Frontend React 19, Vite 8, React Router 7, Lucide React, CSS Modules
Backend Node.js, Express.js, CORS, Dotenv
Database SQLite via better-sqlite3 (WAL mode)
Authentication JSON Web Tokens (jsonwebtoken), bcryptjs
Version Control Git & GitHub
Frontend Deployment Vercel
Backend Deployment Render

๐Ÿ—๏ธ Architecture

                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚        USER          โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                            โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚   React + Vite       โ”‚
                 โ”‚      Frontend        โ”‚
                 โ”‚      (Vercel)        โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                      HTTP / REST API
                            โ”‚
                            โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚  Node.js + Express   โ”‚
                 โ”‚       Backend        โ”‚
                 โ”‚       (Render)       โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                            โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚       SQLite         โ”‚
                 โ”‚    better-sqlite3    โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Project Structure

CodeAlpha_Ecommerce/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ””โ”€โ”€ store.db              # Auto-generated SQLite database (gitignored)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/          # Auth, cart, order & product controllers
โ”‚   โ”‚   โ”œโ”€โ”€ database/             # Database initialization & seed data
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/           # JWT authentication middleware
โ”‚   โ”‚   โ”œโ”€โ”€ models/               # User, Product, Cart & Order data models
โ”‚   โ”‚   โ”œโ”€โ”€ routes/                # Express API route definitions
โ”‚   โ”‚   โ””โ”€โ”€ server.js             # API entry point & health check
โ”‚   โ”œโ”€โ”€ .env.example              # Backend environment template
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ public/                   # Static assets & favicons
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/           # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ context/               # Auth, Cart & Theme contexts
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                 # Product-related custom hooks
โ”‚   โ”‚   โ”œโ”€โ”€ pages/                 # Application pages
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx               # Application routing & layout
โ”‚   โ”‚   โ”œโ”€โ”€ index.css              # Global styles & design tokens
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx               # React DOM entry point
โ”‚   โ”œโ”€โ”€ .env.example              # Frontend environment template
โ”‚   โ”œโ”€โ”€ index.html                 # HTML shell & theme initialization
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ .gitignore                    # Git ignore rules
โ”œโ”€โ”€ README.md                     # Project documentation
โ””โ”€โ”€ LICENSE                       # MIT License

๐Ÿš€ Getting Started

Prerequisites

  • Node.js v18.0.0 or higher
  • npm v9.0.0 or higher
  • Git

Verify your installation:

node --version
npm --version
git --version

1. Clone the Repository

git clone YOUR_GITHUB_REPOSITORY_URL
cd CodeAlpha_Ecommerce

2. Backend Setup

Navigate to the backend directory:

cd backend

Install dependencies:

npm install

Create the environment file:

macOS / Linux:

cp .env.example .env

Windows PowerShell:

Copy-Item .env.example .env

Configure .env:

PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRES=7d

Start the backend:

npm run dev

Backend API: http://localhost:5000 Health check: http://localhost:5000/api/health

3. Frontend Setup

Open a new terminal and navigate to the frontend directory:

cd frontend

Install dependencies:

npm install

Create the environment file:

macOS / Linux:

cp .env.example .env

Windows PowerShell:

Copy-Item .env.example .env

Configure the frontend environment according to the backend API URL.

Start the frontend:

npm run dev

The application will normally be available at: http://localhost:5173


๐Ÿ’พ Database Setup & Auto-Seeding

TechStore uses an embedded SQLite database through better-sqlite3. No external database server is required for local development.

When the backend starts for the first time:

  1. The SQLite database is automatically created.
  2. The database schema is initialized.
  3. Required tables are created.
  4. Seed data is inserted when the product catalog is empty.

The database includes the following tables:

  • products
  • users
  • cart_items
  • orders
  • order_items

The generated database is stored at backend/data/store.db and is excluded from Git version control via .gitignore.


๐Ÿ“ก API Reference

Health Check

Method Endpoint Description Authentication
GET /api/health Returns server status and environment information โŒ

Products

Method Endpoint Description Authentication
GET /api/products Retrieve all products โŒ
GET /api/products/:id Retrieve a specific product โŒ

Authentication

Method Endpoint Description Authentication
POST /api/auth/register Register a new user โŒ
POST /api/auth/login Authenticate user and receive JWT โŒ
POST /api/auth/security-question Retrieve security question โŒ
POST /api/auth/verify-security-answer Verify security answer โŒ
POST /api/auth/reset-password Reset password using reset token โŒ

Shopping Cart

Method Endpoint Description Authentication
GET /api/cart Retrieve current user's cart ๐Ÿ”’ JWT
POST /api/cart Add product to cart ๐Ÿ”’ JWT
PUT /api/cart/:productId Update cart item quantity ๐Ÿ”’ JWT
DELETE /api/cart/:productId Remove an item from cart ๐Ÿ”’ JWT
DELETE /api/cart Clear the current user's cart ๐Ÿ”’ JWT

Orders & Checkout

Method Endpoint Description Authentication
POST /api/orders Create order from current cart ๐Ÿ”’ JWT
GET /api/orders Retrieve authenticated user's orders ๐Ÿ”’ JWT
GET /api/orders/:id Retrieve individual order details ๐Ÿ”’ JWT

๐Ÿ”’ Security Best Practices

  • Zero Hardcoded Secrets โ€” sensitive configuration is managed through environment variables
  • Password Hashing โ€” passwords and security answers are hashed using bcryptjs
  • JWT Authentication โ€” protected API requests require a valid JWT token
  • Route Protection โ€” cart and order endpoints are protected by authentication middleware
  • Git Protection โ€” .env, SQLite database files, node_modules, and build artifacts are excluded from version control

๐ŸŒ Deployment

The application uses a separate frontend and backend deployment architecture:

                       GitHub
                          โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚                         โ”‚
             โ–ผ                         โ–ผ
          Vercel                    Render
             โ”‚                         โ”‚
             โ–ผ                         โ–ผ
     React Frontend             Express Backend
             โ”‚                         โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
                          API

Frontend โ€” Vercel

The React + Vite frontend is deployed on Vercel. ๐ŸŒ Live Application: Open TechStore

Backend โ€” Render

The Node.js + Express backend is deployed on Render. The production frontend communicates with the deployed backend through the configured API URL.


๐Ÿ“ธ Screenshots

Store screenshots inside a screenshots/ folder in the repository so the images below render correctly on GitHub.

๐Ÿ  Home / Product Catalog

TechStore Home

๐Ÿ“ฆ Product Details

Product Details

๐Ÿ›’ Shopping Cart

Shopping Cart

๐Ÿ” Authentication

Authentication

๐Ÿ’ณ Checkout

Checkout


๐Ÿงช Testing

The application was tested across the major user workflows.

Functional Testing

  • User registration
  • User login
  • Password recovery
  • Product loading
  • Product browsing
  • Category filtering
  • Product details
  • Add to cart
  • Update cart quantity
  • Remove cart items
  • Clear cart
  • Checkout
  • Order creation
  • Order history
  • Order details
  • Frontend/backend communication
  • Production API communication

Responsive Testing

  • ๐Ÿ“ฑ Mobile
  • ๐Ÿ“Ÿ Tablet
  • ๐Ÿ’ป Desktop

Deployment Testing

  • Frontend availability
  • Backend availability
  • API communication
  • Product loading
  • Authentication flow
  • Cart functionality
  • Checkout functionality

๐Ÿง‘โ€๐Ÿ’ป Development Workflow

Local Development
       โ”‚
       โ–ผ
Feature Development
       โ”‚
       โ–ผ
Local Testing
       โ”‚
       โ–ผ
Git Commit
       โ”‚
       โ–ผ
GitHub
       โ”‚
       โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Vercel โ”€โ”€โ–บ Frontend Deploy
       โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Render โ”€โ”€โ–บ Backend Deploy

This workflow keeps the project version-controlled while supporting deployment of both the frontend and backend.


๐ŸŽฏ Learning Outcomes

This project provided practical, hands-on experience with:

  • Full-stack web development and component-based architecture
  • React 19, Vite configuration, React Router, and the Context API
  • Custom React hooks
  • REST API development with Express.js
  • SQLite integration and database transactions
  • JWT authentication, password hashing, and middleware
  • CORS and environment variable management
  • Git and GitHub workflows
  • Responsive web design and production debugging
  • Vercel and Render deployment
  • Frontend/backend integration

๐Ÿ”ฎ Future Improvements

The following are potential enhancements and are not yet implemented:

  • ๐Ÿ’ณ Online payment gateway integration
  • โค๏ธ Wishlist functionality
  • ๐Ÿ”Ž Advanced product search
  • ๐Ÿท๏ธ Advanced filtering and sorting
  • โญ Product reviews and ratings
  • ๐Ÿ‘ค User profile management
  • ๐Ÿ“Š Admin dashboard
  • ๐Ÿ“ˆ Sales analytics
  • ๐Ÿ“ฆ Advanced order tracking
  • ๐Ÿ“ง Email notifications
  • ๐Ÿ”” Order-status notifications
  • ๐Ÿ–ผ๏ธ Advanced product image management
  • ๐ŸŒ Internationalization and multiple currencies
  • โ™ฟ Further accessibility improvements

๐Ÿค Contributing

Contributions and suggestions are welcome.

  1. Fork the repository
  2. Create a feature branch:
   git checkout -b feature/your-feature
  1. Make your changes
  2. Commit your changes:
   git commit -m "feat: add your feature"
  1. Push your branch:
   git push origin feature/your-feature
  1. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License. You are free to use, modify, and distribute this project according to the terms of the license.

See the LICENSE file for the complete license text.


๐Ÿ‘จโ€๐Ÿ’ป Author

YOUR NAME B.E. Information Technology Student


๐Ÿ† CodeAlpha Internship

CodeAlpha Internship Program โ€” Task 1: Full Stack E-Commerce Website

This project demonstrates the development, testing, and deployment of a complete full-stack e-commerce application using modern JavaScript technologies.


โญ Support

If you found this project useful or interesting, consider giving the repository a โญ on GitHub.

Built with โค๏ธ using React, Node.js, Express, SQLite and modern web technologies.

CodeAlpha Internship โ€ข Task 1 โ€ข Full Stack Web Development

About

Full-stack electronics e-commerce platform with JWT authentication, shopping cart, checkout, order processing, and responsive UI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages