Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Commerce Application (MERN Stack)

This is a modern full-stack E-Commerce application built using the MERN stack (MongoDB, Express, React, Node.js). It includes authentication with JSON Web Tokens (JWT), role-based authorization (Admin & User access control), password hashing, and concurrent client-server execution.


🚀 Features

  • User Authentication: Secure registration, login, and forgot password flows.
  • Security: Password hashing using bcrypt and token-based authentication via jsonwebtoken.
  • Role-based Access Control: Route protections for standard Users and Admin users.
  • Concurrent Development: Run both the Express backend and React frontend with a single command.

📸 Screenshots

Home Page

Home Page

Product Demo / View

Demo Page


📁 Project Structure

.
├── client/                 # React frontend application
│   ├── public/             # Static public assets
│   ├── src/                # React source code (components, pages, styles)
│   ├── package.json        # Frontend dependencies & scripts
│   └── README.md           # Frontend-specific documentation
├── config/                 # Database and configuration files
│   └── db.js               # MongoDB connection setup
├── controllers/            # Request handlers / Controller layer
│   └── authController.js   # User registration, login, & password management
├── helpers/                # Helper utilities (e.g., password hashing)
├── middlewares/            # Custom Express middlewares (e.g., authentication & role validation)
├── models/                 # Mongoose schemas/models
│   └── userModel.js        # User database schema
├── routes/                 # Express API routes
│   └── authrRoute.js       # Auth endpoints
├── .env                    # Environment variables (Ignored in git)
├── package.json            # Root configuration & scripts
└── server.js               # Main entry point for the backend server

🛠️ Installation & Setup

Prerequisites

Make sure you have Node.js and MongoDB installed on your system.

1. Clone the repository

git clone <repository-url>
cd ecommerce

2. Install Dependencies

Install dependencies for both the root (backend) and client (frontend):

Root Backend:

npm install

Client Frontend:

cd client
npm install
cd ..

3. Environment Variables Configuration

Create a .env file in the root directory (alongside server.js) with the following variables:

PORT=8080
MONGO_URL=your_mongodb_connection_uri
JWT_SECRET=your_jwt_secret_key

🚦 Running the Application

In the root directory, you can run the following scripts:

  • Run Client & Server concurrently (Recommended)
    npm run dev
  • Run Backend only (with Nodemon)
    npm run server
  • Run Frontend only
    npm run client
  • Production Start (Backend)
    npm start

📡 API Endpoints

All backend routes are prefixed with /api/v1.

Authentication Routes (/api/v1/auth)

Method Endpoint Description Auth Required
POST /register Register a new user No
POST /login Login user and retrieve JWT token No
POST /forgot-password Reset password request No
GET /test Test route for auth verification Yes (Admin only)
GET /user-auth Verify token for standard User routing Yes
GET /admin-auth Verify token for Admin routing Yes (Admin only)

🛠️ Built With

  • Backend: Node.js, Express, MongoDB (Mongoose), JSON Web Tokens (JWT), Bcrypt
  • Frontend: React, React Router, Bootstrap, Axios

About

Developed an AR-based e-commerce web application using React.js, Node.js, MongoDB, and <model-viewer>, enabling users to preview 3D product models in real-world environments through mobile cameras for an immersive and interactive shopping experience.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages