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
- About
- Features
- Tech Stack
- Project Structure
- Database Schema
- API Reference
- Installation & Setup
- Pages & Screens
- Contributing
- Author
- License
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.
- π 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
| 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%
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
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.sqlAll protected routes require the header:
Authorization: Bearer <your_jwt_token>
| 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 |
| 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 |
| 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) |
| 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 |
| 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 |
- Python 3.8+
- MySQL Server running locally
- A MySQL user with access to create databases
git clone https://github.com/prathaaaaaaam/Grocery-Store-Management.git
cd Grocery-Store-Managementpip install flask flask-cors mysql-connector-python bcrypt PyJWTmysql -u root -p < grocery_inventory.sqlOpen 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.envfile for production.
python app.pyThe API will be available at http://localhost:5000
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 8080Then visit http://localhost:8080/Landing.html
| 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 |
Pull requests are welcome! To contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Make your changes
- Commit (
git commit -m 'Add your feature') - Push (
git push origin feature/your-feature) - Open a Pull Request
Pratham Sorte
- GitHub: @prathaaaaaaam
This project is open source. Feel free to use, modify, and distribute it.
- Flask β Python web framework
- MySQL β Relational database
- PyJWT β JWT implementation for Python
- bcrypt β Password hashing
- Flask-CORS β Cross-origin resource sharing