Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 E-commerce Backend API

A RESTful backend API for a full-stack e-commerce application built with Node.js, Express.js, MongoDB, and Mongoose.

The API handles authentication, users, products, categories, cart, wishlist, orders, image management, and administrative operations.

✨ Features

  • 🔐 User authentication and authorization
  • 🔑 JWT access and refresh tokens
  • 🍪 HTTP-only cookies for authentication
  • 👤 User management
  • 👑 Role-based authorization and admin access
  • 🛍️ Product management
  • 📂 Category management
  • 🛒 Shopping cart
  • ❤️ Wishlist
  • 📦 Order creation and management
  • 📊 Dashboard data and statistics
  • 🖼️ Image management with Cloudinary
  • 🔒 Password hashing with bcrypt
  • 🌐 RESTful API architecture
  • 🛡️ CORS and cookie handling

🧰 Tech Stack

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT
  • bcrypt
  • Cookie Parser
  • CORS

Image Management

  • Cloudinary

🏗️ Project Structure

ecomerce-backend/
│
├── config/
│   └── ...
│
├── controllers/
│   └── ...
│
├── middleware/
│   └── ...
│
├── models/
│   ├── User.js
│   ├── Product.js
│   ├── Category.js
│   ├── Cart.js
│   ├── Order.js
│   └── Wishlist.js
│
├── routes/
│   ├── auth.routes.js
│   ├── users.routes.js
│   ├── products.routes.js
│   ├── categories.routes.js
│   ├── cart.routes.js
│   ├── wishlist.routes.js
│   ├── orders.routes.js
│   ├── admin.routes.js
│   └── dashboard.routes.js
│
├── server.js
├── package.json
└── ...

🔐 Authentication & Authorization

The API uses JWT-based authentication with access and refresh tokens.

Authentication includes:

  • Access tokens
  • Refresh tokens
  • HTTP-only cookies
  • Password hashing with bcrypt
  • Protected routes
  • Role-based authorization
  • Admin access control

Administrative routes are protected and accessible only to authorized users.

📡 API Modules

The backend provides REST API endpoints for:

Module Description
Authentication User registration, login, logout and token handling
Users User account and profile management
Products Product management
Categories Category management
Cart Shopping cart operations
Wishlist Wishlist operations
Orders Order creation and management
Admin Administrative operations
Dashboard Dashboard statistics and data

🖼️ Image Management

Product images are managed using Cloudinary.

Cloudinary provides cloud-based storage and management for product images used by the e-commerce application.

🗄️ Database

The application uses MongoDB as its database with Mongoose for data modeling and database operations.

Main models include:

  • User
  • Product
  • Category
  • Cart
  • Order
  • Wishlist

🚀 Getting Started

1. Clone the repository

git clone https://github.com/SedjaiRadja/ecomerce-backend.git

2. Navigate to the project

cd ecomerce-backend

3. Install dependencies

npm install

4. Configure environment variables

Create a .env file in the root directory.

Add the required environment variables used by the application, including your MongoDB, JWT, and Cloudinary configuration.

Example:

PORT=5000

MONGO_URI=your_mongodb_connection_string

JWT_SECRET=your_jwt_secret
JWT_REFRESH_SECRET=your_refresh_token_secret

CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret

⚠️ Never commit your .env file or expose your secret keys publicly.

5. Start the development server

npm run dev

The API will be available at:

http://localhost:5000

🔗 Related Repositories

This backend is part of a complete full-stack e-commerce application.

  • Frontend: Next.js customer-facing application
  • Backend: Node.js / Express REST API
  • Dashboard: Next.js administration dashboard

📌 Project Status

Completed

The backend provides the core API and business logic required by the e-commerce frontend and administration dashboard.

👩‍💻 Author

Radja Sedjai

Frontend / Full-Stack Developer

GitHub: @SedjaiRadja


⭐ If you find this project interesting, feel free to explore the repository.

About

REST API backend for a full-stack e-commerce application built with Node.js, Express, MongoDB, and Mongoose. Handles authentication, users, products, categories, cart, orders, and admin operations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages