Skip to content

Latest commit

Β 

History

75 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Project Management β€” E-Commerce & Real-Time Chat Platform

A full-stack web application built with Node.js, Express, MongoDB, and Socket.IO β€” featuring a complete e-commerce storefront, a real-time chat system, and a powerful admin dashboard.


πŸ“‘ Table of Contents


🌐 Overview

This project is a multi-role web platform with two distinct sides:

Side URL Prefix Description
Client / Storefront for end users β€” browsing, cart, checkout, chat
Admin /admin Dashboard for administrators β€” manage products, orders, accounts, roles

✨ Features

πŸ›οΈ Client Side

  • Home page with featured products
  • Product listing & detail pages with search and filtering
  • Shopping cart with persistent cookie-based session
  • Checkout & order management
  • User authentication β€” register, login, logout, forgot password (via email OTP)
  • Real-time 1-on-1 chat between registered users
  • Friend system β€” send/accept friend requests, manage friend list
  • User profile management with avatar upload

πŸ”§ Admin Dashboard

  • Dashboard overview
  • Product management β€” create, edit, soft-delete, restore, change status, set position, upload thumbnail via Cloudinary, rich text description with TinyMCE
  • Product category management β€” hierarchical tree structure
  • Role & permission management β€” define roles with granular permissions
  • Account management β€” create/edit admin accounts, assign roles
  • My Account β€” admin self-profile editing
  • General settings β€” website name, logo, etc.
  • Auth β€” login / logout with cookie-based token

🧰 Tech Stack

Category Technology
Runtime Node.js
Framework Express.js v4
Database MongoDB (via Mongoose v8)
Template Engine Pug v3
Real-time Socket.IO v4
Image Storage Cloudinary + Multer + Streamifier
Email Nodemailer
Rich Text Editor TinyMCE v7
Auth Cookie-parser + Express-session + MD5
Dev Tool Nodemon
Utilities Moment.js, Method-override, Express-flash, mongoose-slug-updater

πŸ“ Project Structure

project-management/
β”œβ”€β”€ index.js                   # App entry point β€” setup Express, Socket.IO, routes
β”œβ”€β”€ vercel.json                # Vercel deployment config
β”œβ”€β”€ package.json
β”œβ”€β”€ .env                       # Environment variables (not committed)
β”‚
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ database.js            # MongoDB connection helper
β”‚   └── system.js              # Global config (admin prefix path)
β”‚
β”œβ”€β”€ models/                    # Mongoose schemas
β”‚   β”œβ”€β”€ account.model.js       # Admin accounts
β”‚   β”œβ”€β”€ cart.model.js          # Shopping cart
β”‚   β”œβ”€β”€ chat.model.js          # Chat messages
β”‚   β”œβ”€β”€ forgot-password.model.js
β”‚   β”œβ”€β”€ order.model.js
β”‚   β”œβ”€β”€ product.model.js
β”‚   β”œβ”€β”€ product-category.model.js
β”‚   β”œβ”€β”€ role.model.js
β”‚   β”œβ”€β”€ room-chat.model.js     # Chat rooms between users
β”‚   β”œβ”€β”€ settings-general.model.js
β”‚   └── user.model.js          # Client users
β”‚
β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ admin/                 # Admin controllers
β”‚   β”‚   β”œβ”€β”€ auth.controller.js
β”‚   β”‚   β”œβ”€β”€ dasboard.controller.js
β”‚   β”‚   β”œβ”€β”€ account.controller.js
β”‚   β”‚   β”œβ”€β”€ product.controller.js
β”‚   β”‚   β”œβ”€β”€ product-category.controller.js
β”‚   β”‚   β”œβ”€β”€ role.controller.js
β”‚   β”‚   β”œβ”€β”€ my-account.controller.js
β”‚   β”‚   └── setting.controller.js
β”‚   └── client/                # Client controllers
β”‚       β”œβ”€β”€ home.controller.js
β”‚       β”œβ”€β”€ product.controller.js
β”‚       β”œβ”€β”€ cart.controller.js
β”‚       β”œβ”€β”€ checkout.controller.js
β”‚       β”œβ”€β”€ user.controller.js
β”‚       β”œβ”€β”€ users.controller.js
β”‚       β”œβ”€β”€ chat.controller.js
β”‚       β”œβ”€β”€ rooms-chat.controller.js
β”‚       └── search.controller.js
β”‚
β”œβ”€β”€ routers/
β”‚   β”œβ”€β”€ admin/                 # Admin route definitions
β”‚   β”‚   β”œβ”€β”€ index.route.js
β”‚   β”‚   β”œβ”€β”€ auth.route.js
β”‚   β”‚   β”œβ”€β”€ dasboard.route.js
β”‚   β”‚   β”œβ”€β”€ product.route.js
β”‚   β”‚   β”œβ”€β”€ products-category.route.js
β”‚   β”‚   β”œβ”€β”€ role.route.js
β”‚   β”‚   β”œβ”€β”€ accounts.route.js
β”‚   β”‚   β”œβ”€β”€ my-account.route.js
β”‚   β”‚   └── setting.route.js
β”‚   └── client/                # Client route definitions
β”‚       β”œβ”€β”€ index.route.js
β”‚       β”œβ”€β”€ home.route.js
β”‚       β”œβ”€β”€ product.route.js
β”‚       β”œβ”€β”€ cart.route.js
β”‚       β”œβ”€β”€ checkout.route.js
β”‚       β”œβ”€β”€ user.route.js
β”‚       β”œβ”€β”€ users.route.js
β”‚       β”œβ”€β”€ chat.route.js
β”‚       β”œβ”€β”€ rooms-chat.route.js
β”‚       └── search.route.js
β”‚
β”œβ”€β”€ middlewares/
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”œβ”€β”€ auth.middleware.js         # Admin auth guard (token check)
β”‚   β”‚   └── uploadCloud.middlewares.js # Cloudinary image upload
β”‚   └── client/
β”‚       β”œβ”€β”€ auth.middlerware.js        # Client auth guard
β”‚       β”œβ”€β”€ cart.middlerware.js        # Cart ID injection
β”‚       β”œβ”€β”€ category.middlerware.js    # Category data injection
β”‚       β”œβ”€β”€ setting.middlerware.js     # General settings injection
β”‚       β”œβ”€β”€ user.middlerware.js        # Logged-in user info injection
β”‚       └── chat.middlerware.js        # Chat room data
β”‚
β”œβ”€β”€ sockets/
β”‚   └── client/
β”‚       β”œβ”€β”€ chat.socket.js    # Real-time message events
β”‚       └── users.socket.js   # Online status, friend requests
β”‚
β”œβ”€β”€ helpers/                   # Utility/helper modules
β”‚   β”œβ”€β”€ create-tree.js         # Build hierarchical category tree
β”‚   β”œβ”€β”€ filterStatus.js        # Product status filter helper
β”‚   β”œβ”€β”€ generate.js            # Random string / OTP generation
β”‚   β”œβ”€β”€ pagination.js          # Pagination logic
β”‚   β”œβ”€β”€ product.js             # Product query helpers
β”‚   β”œβ”€β”€ products-category.js   # Category query helpers
β”‚   β”œβ”€β”€ search.js              # Search keyword helper
β”‚   β”œβ”€β”€ sendMail.js            # Nodemailer email sender
β”‚   └── storageMulter.js       # Multer memory storage config
β”‚
β”œβ”€β”€ validates/                 # Input validation
β”‚   β”œβ”€β”€ admin/
β”‚   └── client/
β”‚
β”œβ”€β”€ views/                     # Pug templates
β”‚   β”œβ”€β”€ admin/
β”‚   └── client/
β”‚
└── public/                    # Static assets (CSS, JS, images)

πŸ—„οΈ Database Models

Model Collection Description
Account accounts Admin users with role assignment and token-based auth
User users Client users with friend list, online status, and chat rooms
Product products Products with slug, stock, discount, soft-delete, and audit trail
ProductCategory product-categories Hierarchical product categories
Cart carts Shopping cart linked by cookie
Order orders Placed orders
Role roles Admin role definitions with permissions
RoomChat room-chats Private chat rooms between two users
Chat chats Individual chat messages
ForgotPassword forgot-passwords OTP tokens for password reset
SettingsGeneral settings-generals Website-wide settings

πŸ”€ API Routes

Client Routes (/)

Method Path Description
GET / Home page
GET /products Product listing
GET /products/:slug Product detail
GET /search Search products
GET/POST /cart View / add to cart
GET/POST /checkout Checkout
GET/POST /user/register User registration
GET/POST /user/login User login
GET /user/logout User logout
GET/POST /user/forgot-password Forgot password
GET/PATCH /user/info View / update profile
GET /users User list (auth required)
GET /chat Chat page (auth required)
GET /rooms-chat Chat rooms (auth required)

Admin Routes (/admin)

Method Path Description
GET/POST /admin/ Admin login
GET/POST /admin/auth/logout Admin logout
GET /admin/dasboard Dashboard
GET/POST /admin/products Product list / create
PATCH/DELETE /admin/products/:id Update / soft-delete product
GET/POST /admin/products-category Category list / create
GET/POST /admin/roles Role list / create
GET/POST /admin/accounts Account list / create
GET/PATCH /admin/my-account View / update own profile
GET/PATCH /admin/settings General settings

βš™οΈ Environment Variables

Create a .env file in the root directory with the following keys:

# Server
PORT=3010

# MongoDB
MONGO_URL=mongodb+srv://<username>:<password>@cluster0.xxx.mongodb.net/project-management

# Cloudinary (Image Upload)
CLOUD_NAME=your_cloud_name
CLOUD_KEY=your_api_key
CLOUD_SECRET=your_api_secret

# Email (Nodemailer β€” Gmail App Password)
SEND_MAIL_EMAIL=your_email@gmail.com
SEND_MAIL_PASSWORD=your_app_password

Note: Never commit your .env file. It is already listed in .gitignore.


πŸš€ Getting Started

Prerequisites

Installation

# 1. Clone the repository
git clone https://github.com/your-username/project-management.git
cd project-management

# 2. Install dependencies
npm install

# 3. Configure environment variables
cp .env.example .env
# Fill in your actual values in .env

# 4. Start the development server
npm start

The application will be available at: http://localhost:3010

Section URL
Client storefront http://localhost:3010/
Admin dashboard http://localhost:3010/admin

☁️ Deployment

This project includes a vercel.json configuration for deployment on Vercel.

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

Make sure to add all environment variables in your Vercel project dashboard under Settings β†’ Environment Variables.


πŸ“„ License

This project is licensed under the ISC License.

Releases

Packages

Used by

Contributors

Languages