Skip to content

prathaaaaaaam/Grocery-Store-Management

Repository files navigation

πŸ›’ Grocery Store Management System

A full-stack web application for managing a grocery store β€” handling inventory, orders, suppliers, sales reports, and real-time metrics through a secure admin dashboard.

Made by Pratham Sorte


πŸ“Œ Table of Contents


πŸ“– About

Grocery Store Management System is a complete web-based solution for managing the day-to-day operations of a grocery store. It features a secure admin dashboard where store managers can track inventory, manage suppliers, monitor orders, view sales analytics, and get low-stock alerts β€” all from a clean, browser-based interface.

The backend is a Flask REST API connected to a MySQL database, secured with JWT authentication and bcrypt password hashing. The frontend is built with vanilla HTML, CSS, and JavaScript pages that consume the REST API.


✨ Features

  • πŸ” JWT Authentication β€” Secure login, signup, and logout with token-based sessions
  • πŸ“¦ Inventory Management β€” Add, update, delete, and view all products with stock levels
  • ⚠️ Low Stock Alerts β€” Auto-detects products below restock threshold
  • πŸ”„ Restock Trigger β€” One-click restock via stored procedure
  • 🏭 Supplier Management β€” Full CRUD for suppliers with product count tracking
  • 🧾 Order Management β€” View, update status, and delete orders with product breakdown
  • πŸ“Š Sales Reports β€” Revenue and units sold per product; top performers ranked
  • πŸ“ˆ Admin Dashboard Metrics β€” Daily sales, total products, low stock count, 7-day sales chart
  • πŸ›‘οΈ Protected Routes β€” All sensitive endpoints require a valid JWT token
  • 🌐 CORS Enabled β€” Frontend and backend can run on different ports

πŸ› οΈ Tech Stack

Layer Technology
Backend Python, Flask, Flask-CORS
Database MySQL (mysql-connector-python)
Auth JWT (PyJWT), bcrypt
Frontend HTML5, CSS3, Vanilla JavaScript
API Style RESTful

Language breakdown: JavaScript 38% Β· Python 24% Β· HTML 24% Β· CSS 14%


πŸ“ Project Structure

Grocery-Store-Management/
β”‚
β”œβ”€β”€ app.py                    # Flask REST API (640 lines) β€” all routes & logic
β”œβ”€β”€ grocery_inventory.sql     # MySQL database schema & seed data
β”‚
β”œβ”€β”€ Landing.html              # Public landing / home page
β”œβ”€β”€ login.html                # Login page
β”œβ”€β”€ signup.html               # Registration page
β”œβ”€β”€ about.html                # About page
β”‚
β”œβ”€β”€ admin_dashboard.html      # Admin dashboard with metrics & charts
β”œβ”€β”€ inventory.html            # Inventory management page
β”œβ”€β”€ orders.html               # Orders management page
β”œβ”€β”€ suppliers.html            # Supplier management page
β”œβ”€β”€ reports.html              # Sales reports page
β”‚
β”œβ”€β”€ admin.js                  # Admin dashboard JS logic
β”œβ”€β”€ login.js                  # Login form handling & JWT storage
β”œβ”€β”€ signup.js                 # Registration form handling
β”œβ”€β”€ logout.js                 # Token clearing & session logout
β”‚
β”œβ”€β”€ styles.css                # Global stylesheet
β”œβ”€β”€ logo.png                  # Store logo
β”œβ”€β”€ landing.jpg               # Landing page hero image
β”‚
β”œβ”€β”€ Mini Project              # Project documentation / report
└── README.md

πŸ—„οΈ Database Schema

The MySQL database (grocery_inventory) contains the following core tables:

Table Description
users Admin accounts with hashed passwords
product Product catalogue with name, category, price, supplier
inventory Stock levels and restock thresholds per product
supplier Supplier details (name, contact, address)
customer Customer information linked to orders
orders Order header β€” date, customer, total, status
order_details Line items per order β€” product, quantity, subtotal

Stored Procedure: RestockProducts β€” called via /api/restock to automatically top up low-stock items.

To set up the database:

mysql -u root -p < grocery_inventory.sql

πŸ”Œ API Reference

All protected routes require the header:

Authorization: Bearer <your_jwt_token>

Auth

Method Endpoint Auth Description
POST /api/register ❌ Register a new admin user
POST /api/login ❌ Login and receive JWT token
POST /api/logout βœ… Logout (invalidate session)
GET /api/check-auth βœ… Validate token
GET /api/user βœ… Get logged-in user's name

Inventory

Method Endpoint Auth Description
GET /api/inventory βœ… List all products with stock info
POST /api/inventory/add βœ… Add a new product
GET /api/inventory/<id> βœ… Get a single product
PUT /api/inventory/<id> βœ… Update a product
DELETE /api/inventory/<id> βœ… Delete a product

Suppliers

Method Endpoint Auth Description
GET /api/suppliers βœ… List all suppliers with product count
POST /api/suppliers/add βœ… Add a new supplier
GET /api/suppliers/<id> βœ… Get a single supplier
PUT /api/suppliers/<id> βœ… Update a supplier
DELETE /api/suppliers/<id> βœ… Delete supplier (blocks if has products)

Orders

Method Endpoint Auth Description
GET /api/orders βœ… List all orders with product names
PUT /api/orders/<id> βœ… Update order status
DELETE /api/orders/<id> βœ… Delete an order
GET /api/orders/count βœ… Get total order count

Metrics & Reports

Method Endpoint Auth Description
GET /api/metrics βœ… Dashboard metrics (sales, stock, chart data)
GET /api/sales-report?period=7|30|365 βœ… Sales data over a period
GET /api/reports βœ… Top products by revenue & units sold
GET /api/low-stock ❌ Products below restock threshold
GET /api/daily-sales ❌ Today's total sales
GET /api/total-products ❌ Total product count
POST /api/restock ❌ Trigger restock stored procedure

βš™οΈ Installation & Setup

Prerequisites

  • Python 3.8+
  • MySQL Server running locally
  • A MySQL user with access to create databases

1. Clone the repository

git clone https://github.com/prathaaaaaaam/Grocery-Store-Management.git
cd Grocery-Store-Management

2. Install Python dependencies

pip install flask flask-cors mysql-connector-python bcrypt PyJWT

3. Set up the database

mysql -u root -p < grocery_inventory.sql

4. Configure database credentials

Open app.py and update the DB_CONFIG block with your MySQL credentials:

DB_CONFIG = {
    "host": "localhost",
    "user": "your_mysql_user",
    "password": "your_mysql_password",
    "database": "grocery_inventory"
}

⚠️ Never commit real passwords. Consider using environment variables or a .env file for production.

5. Run the Flask server

python app.py

The API will be available at http://localhost:5000

6. Open the frontend

Simply open Landing.html in your browser, or serve the files with a local server:

# Using Python's built-in server
python -m http.server 8080

Then visit http://localhost:8080/Landing.html


πŸ–₯️ Pages & Screens

Page File Description
Landing Landing.html Public home page with store intro
Login login.html Admin login with JWT token handling
Signup signup.html New admin registration
About about.html About the store/project
Dashboard admin_dashboard.html Metrics overview, daily sales, low stock count, chart
Inventory inventory.html Full product CRUD with stock & threshold
Orders orders.html View, update, and delete customer orders
Suppliers suppliers.html Supplier CRUD with associated product count
Reports reports.html Sales report with period filter, top products table

🀝 Contributing

Pull requests are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Make your changes
  4. Commit (git commit -m 'Add your feature')
  5. Push (git push origin feature/your-feature)
  6. Open a Pull Request

πŸ‘¨β€πŸ’» Author

Pratham Sorte


πŸ“„ License

This project is open source. Feel free to use, modify, and distribute it.


πŸ™Œ Acknowledgements

  • Flask β€” Python web framework
  • MySQL β€” Relational database
  • PyJWT β€” JWT implementation for Python
  • bcrypt β€” Password hashing
  • Flask-CORS β€” Cross-origin resource sharing

About

Full-stack grocery store management system with admin dashboard, inventory tracking, order & supplier management, sales reports, low-stock alerts, and JWT-secured REST API built with Flask and MySQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors