Skip to content

vijit101/HackathonRepo-RoboticInventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 

Repository files navigation

To add important links later - Demonstration link - https://youtu.be/8lnRnJb0RQY

Robotic Inventory System - Backend

πŸ“Œ Overview

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.

πŸš€ Features

  • 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)

πŸ›  Tech Stack

  • Backend: Node.js, Express.js
  • View Engine: EJS with express-ejs-layouts
  • Middleware: Express Session, Cookie Parser, Custom Auth Middleware
  • QR Code Generation: qrcode package
  • Validation: express-validator

πŸ“‚ Folder Structure

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

πŸ”§ Setup & Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/robotic-inventory-backend.git
    cd robotic-inventory-backend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm start

    The server runs on http://localhost:8080


πŸ“œ API Endpoints

πŸ”‘ Authentication Routes

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

πŸ“¦ Product Management

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

πŸ›  Middleware

  • 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.

πŸ“Œ Future Improvements

  • Implement role-based access control (RBAC)
  • Add RESTful API documentation with Swagger
  • Implement unit tests with Jest

πŸ’‘ Contributing

Feel free to fork this repository and submit pull requests with improvements or bug fixes.


πŸ“„ License

This project is licensed under the MIT License

About

A hackathon project by team banana tiger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published