A comprehensive web-based order management system for phone parts wholesalers. This system enables market retailers/shopkeepers to place delivery orders for phone parts, while admins and superadmins can efficiently manage and track these orders.
- Simple login/registration with name, shop name, and phone number
- Notepad-style order entry interface
- View order history with status tracking
- Real-time order status updates
- Secure password-based authentication
- View all orders from shopkeepers
- Process and mark orders as delivered
- Real-time notifications for new orders
- Order statistics dashboard
- Filter orders by status
- Complete system oversight
- Admin account management (create, activate, deactivate, delete)
- Final order confirmation after admin delivery
- Monitor all system activities
- Real-time notifications for all order events
- Comprehensive statistics dashboard
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens)
- Real-time Communication: Socket.IO
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Security: bcryptjs for password hashing
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn package manager
cd d:\raj.shopnpm installCreate a .env file in the root directory by copying .env.example:
copy .env.example .envEdit the .env file with your configuration:
# Server Configuration
PORT=3000
NODE_ENV=development
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/rajshop
# JWT Secret (Generate a strong random string)
JWT_SECRET=your_jwt_secret_key_change_this_in_production
# Session
SESSION_TIMEOUT=24h
# Superadmin Initial Credentials
SUPERADMIN_USERNAME=superadmin
SUPERADMIN_PASSWORD=SuperAdmin@123
SUPERADMIN_NAME=Super AdministratorImportant: Change the JWT_SECRET and superadmin credentials in production!
Ensure MongoDB is running on your system:
# Windows
net start MongoDB
# Or if using MongoDB installed locally
mongod# Development mode with auto-reload
npm run dev
# Production mode
npm startThe server will start on http://localhost:3000
-
Access the Application: Open your browser and navigate to
http://localhost:3000 -
Superadmin Login:
- Click "Superadmin Login"
- Use the default credentials from your
.envfile - Default: Username:
superadmin, Password:SuperAdmin@123 β οΈ Change these credentials immediately after first login
-
Create Admin Accounts:
- Go to the "Manage Admins" tab
- Create admin accounts for your staff
- Each admin will need these credentials to log in
- Navigate to
http://localhost:3000 - Click "Shopkeeper Login"
- Enter your details (name, shop name, phone number)
- Type your order in the notepad-style text area
- Submit your order
- Track order status in real-time
- Navigate to
http://localhost:3000 - Click "Admin Login"
- Enter your username and password (provided by superadmin)
- View all pending orders
- Process orders and mark them as delivered
- Receive real-time notifications for new orders
- Navigate to
http://localhost:3000 - Click "Superadmin Login"
- Enter your credentials
- Orders Tab: Monitor all orders and confirm deliveries
- Manage Admins Tab: Create, activate, deactivate, or delete admin accounts
- Receive notifications for all system events
Shopkeeper β Places Order (Pending)
β
Admin β Receives Notification
β
Admin β Marks as Delivered
β
Superadmin β Receives Notification
β
Superadmin β Confirms as Completed
- JWT Authentication: Secure token-based authentication
- Role-Based Access Control: Separate permissions for each user type
- Password Hashing: bcryptjs with salt for password security
- Session Management: Configurable session timeout
- Active Status: Admins can be deactivated without deletion
- Real-time notifications using Socket.IO
- Admins receive notifications for:
- New orders from shopkeepers
- Superadmin receives notifications for:
- New orders from shopkeepers
- Orders delivered by admins
- Visual notification badges
- Notification history panel
POST /api/auth/shopkeeper/login- Shopkeeper login/registrationPOST /api/auth/admin/login- Admin loginPOST /api/auth/superadmin/login- Superadmin login
GET /api/orders- Get orders (filtered by role)POST /api/orders- Create new order (Shopkeeper)GET /api/orders/:id- Get single orderPUT /api/orders/:id/deliver- Mark as delivered (Admin)PUT /api/orders/:id/complete- Mark as completed (Superadmin)GET /api/orders/stats/dashboard- Get order statistics
GET /api/admin/list- Get all admins (Superadmin)POST /api/admin/create- Create new admin (Superadmin)PUT /api/admin/:id/activate- Activate admin (Superadmin)PUT /api/admin/:id/deactivate- Deactivate admin (Superadmin)DELETE /api/admin/:id- Delete admin (Superadmin)
GET /api/notifications- Get notificationsPUT /api/notifications/:id/read- Mark as readPUT /api/notifications/read-all- Mark all as read
raj.shop/
βββ config/
β βββ database.js # MongoDB connection
β βββ constants.js # Application constants
βββ middleware/
β βββ auth.js # Authentication middleware
β βββ errorHandler.js # Error handling
βββ models/
β βββ User.js # User model (Shopkeeper/Admin/Superadmin)
β βββ Order.js # Order model
β βββ Notification.js # Notification model
βββ routes/
β βββ auth.js # Authentication routes
β βββ orders.js # Order management routes
β βββ admin.js # Admin management routes
β βββ notifications.js # Notification routes
βββ public/
β βββ css/
β β βββ style.css # Stylesheet
β βββ js/
β β βββ config.js # Frontend configuration
β βββ index.html # Landing page
β βββ shopkeeper-login.html
β βββ shopkeeper-dashboard.html
β βββ admin-login.html
β βββ admin-dashboard.html
β βββ superadmin-login.html
β βββ superadmin-dashboard.html
βββ server.js # Main server file
βββ package.json
βββ .env.example
βββ README.md
- Ensure MongoDB service is running
- Check the
MONGODB_URIin your.envfile - Verify MongoDB is installed correctly
- Change the
PORTin your.envfile - Or stop the application using that port
- Clear browser localStorage
- Check if JWT_SECRET is properly set in
.env - Verify user credentials
- Ensure the server is running
- Check browser console for connection errors
- Verify SOCKET_URL in
public/js/config.js
npm run devThis uses nodemon for auto-reloading on file changes.
If you need to reset the database:
# Connect to MongoDB
mongo
# Switch to database
use rajshop
# Drop database
db.dropDatabase()The superadmin account will be recreated on next server start.
Superadmin (after first run):
- Username:
superadmin - Password:
SuperAdmin@123
- β Simple notepad-style order entry
- β Real-time notifications
- β Role-based access control
- β Order status tracking
- β Admin management
- β Responsive design
- β Session management
- β Audit trail (who delivered, who completed)
- β Statistics dashboard
- β Order filtering
For issues or questions:
- Check the troubleshooting section
- Review the API endpoints documentation
- Check server logs for error messages
ISC
1.0.0
Built with β€οΈ for Raj Shop