-
User Authentication & Authorization
- Secure user registration and login with JWT tokens
- Role-based access control (USER, ADMIN, EMPLOYEE, MANAGER)
- Password encryption using bcryptjs
- Protected routes with middleware authentication
-
Employee Profiles
- Complete employee information management
- Registration number tracking
- Department and position assignment
- Employee status management (Active/Inactive)
-
Leave Request Processing
- Multiple leave categories (Sick, Casual, Annual, Unpaid, Emergency, Others)
- Comprehensive leave status tracking
- Approval workflow with manager/admin oversight
- Leave modification and change requests
- Detailed leave history and reporting
-
Advanced Leave Features
- Search and filter functionality
- Pagination for large datasets
- Date range filtering
- Employee search by registration number
- Automated leave calculations
-
Product Management
- Product catalog with categories (Clothing, Electronics, Books, Other)
- Image upload support with Multer
- Stock management
- Price tracking
- Product search and filtering
-
Shopping Cart System
- Add/remove items from cart
- Quantity management
- Wishlist functionality
- Cart persistence per user
- Automatic total calculation
-
Order Processing
- Complete order management
- Multiple payment methods (COD, Credit Card, Debit Card, UPI, Net Banking, Wallet)
- Order status tracking (Pending, Confirmed, Processing, Shipped, Delivered, Cancelled)
- Shipping address management
- Order history and tracking
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- bcryptjs - Password hashing
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- React Hooks - State management (
useCart.js) - CSS - Styling (
CartItems.css) - JavaScript - Client-side logic
server/
├── db/
│ ├── index.js # Database connection
│ └── models/
│ ├── user_schema.js # User/Employee model
│ ├── employee_schema.js # Employee details model
│ ├── leave_schema.js # Leave request model
│ ├── product_schema.js # Product catalog model
│ ├── cart-schema.js # Shopping cart model
│ └── order-schema.js # Order management model
├── routes/
│ ├── index.js # Main router configuration
│ ├── user_routes.js # Authentication routes
│ ├── leave_routes_clean.js # Leave management routes
│ ├── product_routes.js # Product management routes
│ ├── cart_routes.js # Shopping cart routes
│ └── order_routes.js # Order processing routes
├── middleware/
│ ├── auth.js # JWT authentication middleware
│ └── check-token.js # Token validation middleware
├── hooks/
│ └── useCart.js # React cart hook
├── public/
│ └── uploads/ # File upload directory
├── server.js # Main server file
└── package.json # Dependencies and scripts
-
Clone the repository
git clone <repository-url> cd server
-
Install dependencies
npm install
-
Environment Configuration Create a
.envfile in the root directory:PORT=3000 JWT_SECRET=your_jwt_secret_key MONGODB_URI=your_mongodb_connection_string
-
Start the development server
npm run dev
POST /api/auth/register- User registrationPOST /api/auth/login- User login
GET /api/leave/search-employee- Search employees by registration numberGET /api/leave/leavespopulated- Get all leave requests with filters
POST /api/leave/- Create leave requestGET /api/leave/all-leaves- Get all leave requestsPUT /api/leave/:id/status- Update leave statusGET /api/leave/:id- Get single leave request
POST /api/products/- Create productGET /api/products/- Get all products with filtersGET /api/products/:id- Get single productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete product
POST /api/cart/add- Add item to cartGET /api/cart/- Get user's cartPUT /api/cart/update- Update cart item quantityDELETE /api/cart/remove- Remove item from cart
POST /api/orders/- Create orderGET /api/orders/- Get user's ordersGET /api/orders/:id- Get single orderPUT /api/orders/:id/status- Update order status
- JWT-based authentication
- Password hashing with bcryptjs
- Role-based access control
- Protected API endpoints
- Input validation and sanitization
- CORS configuration
The backend is designed to work seamlessly with React frontend components:
CartItems.js- Shopping cart interfaceCartPage.js- Cart management pageViewLevRequest.js- Leave request viewer- Custom React hooks for state management
The application is ready for deployment on platforms like:
- Heroku
- AWS
- DigitalOcean
- Vercel
- Railway
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the ISC License.
Built with ❤️ for efficient employee and e-commerce management.
Note: This system provides a complete solution for organizations that need both employee management and e-commerce capabilities in a single integrated platform.