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.
- Overview
- Features
- Tech Stack
- Project Structure
- Database Models
- API Routes
- Environment Variables
- Getting Started
- Deployment
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 |
- 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
- 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
| 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 |
| 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-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)
| 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 |
| 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) |
| 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 |
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_passwordNote: Never commit your
.envfile. It is already listed in.gitignore.
- Node.js >= 18.x
- A MongoDB Atlas cluster (or local MongoDB)
- A Cloudinary account
- A Gmail account with App Password enabled
# 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 startThe application will be available at: http://localhost:3010
| Section | URL |
|---|---|
| Client storefront | http://localhost:3010/ |
| Admin dashboard | http://localhost:3010/admin |
This project includes a vercel.json configuration for deployment on Vercel.
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodMake sure to add all environment variables in your Vercel project dashboard under Settings β Environment Variables.
This project is licensed under the ISC License.