To add important links later - Demonstration link - https://youtu.be/8lnRnJb0RQY
The Robotic Inventory System is a Node.js and Express-based backend that provides inventory management capabilities, including product tracking, user authentication, and QR code integration. This system allows users to register, log in, and manage product stock levels efficiently.
- User Authentication (Register, Login, Logout with session-based auth)
- Product Management (CRUD operations for products)
- QR Code Generation (For tracking product stock and purchases)
- Session-Based Middleware (User sessions & last visit tracking)
- View Rendering with EJS (Dynamic UI for inventory management)
- Validation Middleware (Ensuring data integrity)
- Express Session Handling (User sessions stored securely)
- Backend: Node.js, Express.js
- View Engine: EJS with express-ejs-layouts
- Middleware: Express Session, Cookie Parser, Custom Auth Middleware
- QR Code Generation:
qrcodepackage - Validation:
express-validator
Backend/
βββ src/
β βββ controllers/ # Handles business logic
β β βββ product.controller.js
β β βββ user.controller.js
β βββ middlewares/ # Custom middleware for auth, validation, and session handling
β β βββ auth.middleware.js
β β βββ lastVisit.middleware.js
β β βββ validation.middleware.js
β βββ models/ # Data models (Currently using JSON storage)
β β βββ product.model.js
β β βββ user.model.js
β β βββ QRCode.utility.js
β βββ views/ # EJS templates for rendering UI
β β βββ layout.ejs
β β βββ login.ejs
β β βββ register.ejs
β β βββ new-product.ejs
β β βββ update-product.ejs
β β βββ products.ejs
βββ index.js # Entry point of the application
βββ package.json # Project dependencies and metadata
βββ package-lock.json # Package lock file
βββ .gitignore # Git ignore file
βββ README.md # Project documentation
-
Clone the repository:
git clone https://github.com/yourusername/robotic-inventory-backend.git cd robotic-inventory-backend -
Install dependencies:
npm install
-
Start the development server:
npm start
The server runs on
http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| GET | /register |
Render register page |
| POST | /register |
Register new user |
| GET | /login |
Render login page |
| POST | /login |
User login |
| GET | /logout |
Logout user |
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
View all products (requires auth) |
| GET | /api/products |
Get all products (JSON) |
| GET | /new |
Get add product form |
| POST | / |
Add new product (Form Submission) |
| POST | /api/addProducts |
Add new product (API) |
| GET | /update-product/:id |
Get update product form |
| POST | /update-product |
Update existing product |
| GET | /qrcode/:id |
Get product by QR Code |
| POST | /qrcode/:id |
Update stock on purchase |
| GET | /delete-product/:id |
Delete product |
- Authentication Middleware (
auth.middleware.js): Protects routes from unauthorized access. - Validation Middleware (
validation.middleware.js): Ensures valid product data is submitted. - Last Visit Middleware (
lastVisit.middleware.js): Tracks last visit time in cookies.
- Implement role-based access control (RBAC)
- Add RESTful API documentation with Swagger
- Implement unit tests with Jest
Feel free to fork this repository and submit pull requests with improvements or bug fixes.
This project is licensed under the MIT License