This is a medium-complexity project designed to build an e-commerce product management system using the Express.js framework. The project integrates MongoDB as the database and implements essential features like authentication, product categorization, and file handling for product images.
- Overview
- Features
- Project Objectives
- Implementation Details
- Folder Structure
- Installation and Setup
- Usage
- API Routes
- Environment Variables
- Future Enhancements
- License
The e-commerce product management system provides the foundational functionality for an online store, including:
- Product creation and categorization.
- Secure user authentication.
- Image uploads for products.
- Dynamic rendering of pages using EJS templating engine.
This application is designed with scalability and extensibility in mind, allowing easy integration of advanced features in the future.
-
User Authentication: Secure user registration and login using JWT tokens for session management.
-
Product Management: CRUD operations for products with efficient categorization using nested document structures in MongoDB.
-
Image Uploads: Product images are uploaded and stored using Multer with server-side validation.
-
Search Functionality: Ability to search for products using advanced querying and filtering.
-
Responsive Views: User-friendly interfaces built with the EJS templating engine.
- Build a scalable e-commerce product management system.
- Utilize MongoDB for entity storage and advanced querying.
- Secure user data using bcrypt for password hashing and JWT for authentication.
- Handle file uploads for product images securely.
- Implement an intuitive UI with EJS views.
- Templating Engine: EJS is used for creating dynamic views.
- UI Pages:
- Authentication (Login, Signup, Forgot Password).
- Product management (Create, List, Detail).
- Category management.
- Layouts and Partials: Reusable components like header, footer, and layout templates.
- Database: MongoDB.
- ODM: Mongoose for schema definitions and data validation.
- Features:
- Nested documents for categories.
- Advanced querying and filtering for products.
- Document relationships for users, products, and categories.
-
User Registration and Login:
- JWT for token-based authentication.
- Bcrypt for hashing passwords.
-
Session Security: Middleware to protect routes and handle token verification.
- File Uploads:
- Multer for handling multipart/form-data.
- Server-side validation for images (e.g., size and format).
- Directory Structure: Uploaded files are stored in structured directories for easy retrieval.
-
Categorization:
- Products are categorized using a nested document model.
-
Search and Filters:
- Implemented advanced querying for efficient product search.
-
CRUD Operations:
- Fully functional Create, Read, Update, and Delete features for products and categories.
.
├── public # Static assets (images, icons, etc.)
├── src # Application source code
│ ├── controllers # Business logic for routes
│ ├── models # Mongoose schemas
│ ├── routes # API routes
│ ├── utils # Utilities and middleware
│ └── views # EJS templates for UI
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation- Node.js (v18+)
- MongoDB (local or cloud instance)
-
Clone the repository:
git clone https://github.com/julius-amt/PMS.git cd PMS/ -
Install dependencies:
npm install
-
Create a
.envfile and configure the required environment variables (see Environment Variables). -
Start the development server:
npm start
-
Access the application at
http://localhost:3000.
- Navigate to
/signupto register a new user. - Log in via
/loginand access the dashboard. - Add products via the product management page.
- Categorize products to organize the inventory.
- View, edit, or delete products through the product listing page.
| Route | Method | Description | Auth Required |
|---|---|---|---|
/api/auth/signup |
POST | Register a new user | No |
/api/auth/login |
POST | Log in a user | No |
/api/products |
GET | Fetch all products | Yes |
/api/products/:id |
GET | Fetch a specific product | Yes |
/api/products |
POST | Create a new product | Yes |
/api/categories |
GET | Fetch all categories | Yes |
Create a .env file in the project root and add the following:
MONGO_URI=<your_mongo_database_uri>
JWT_SECRET=<your_jwt_secret_key>
EMAIL_HOST=<your_email
EMAIL_PORT=####
EMAIL_SECURE=<boolean>
EMAIL_USER=<your_email>
EMAIL_PASS=<your_password>
BASE_URL=<your_base_url>- Implement payment gateway integration.
- Add support for multiple user roles (e.g., admin, customer).
- Develop a RESTful API for third-party integrations.
- Introduce advanced search capabilities using text indexing.
This project is licensed under the MIT License.
Feel free to contribute and report issues in the repository!