A comprehensive backend API for managing grocery store operations including products, inventory, orders, and units of measurement. Built with Python Flask and MySQL.
- Product Management: Add, view, update, and delete products
- Unit of Measurement (UOM): Manage different units (kg, liter, piece, etc.)
- Order Management: Create and track customer orders
- RESTful API: Clean endpoints for frontend integration
- Database Integration: MySQL with proper relationships
- CORS Support: Ready for web frontend integration
GROCERY_APP_PYTHON/
├── backend/
│ ├── products_dao.py # Product data access operations
│ ├── uom_dao.py # Unit of Measurement operations
│ ├── order_dao.py # Order management operations
│ ├── sql_connection.py # Database connection setup
│ └── server.py # Flask API server
├── ui/ # Frontend (if applicable)
├── myenv/ # Virtual environment
├── README.md
└── .gitignore
- Python 3.7+
- MySQL Server
- pip (Python package manager)
-
Clone the repository
git clone <repository-url> cd GROCERY_APP_PYTHON
-
Set up virtual environment
python -m venv myenv # On Windows: myenv\Scripts\activate # On macOS/Linux: source myenv/bin/activate
-
Install dependencies
pip install flask mysql-connector-python
-
Database Setup
- Start your MySQL server
- Create database:
CREATE DATABASE grocery_app_database; - Update
sql_connection.pywith your MySQL credentials
-
Create Database Tables
-- UOM Table CREATE TABLE uom ( uom_id INT AUTO_INCREMENT PRIMARY KEY, uom_name VARCHAR(45) NOT NULL ); -- Products Table CREATE TABLE products ( product_id INT AUTO_INCREMENT PRIMARY KEY, product_name VARCHAR(100) NOT NULL, uom_id INT, price_per_unit DECIMAL(10,2), FOREIGN KEY (uom_id) REFERENCES uom(uom_id) ); -- Orders Table (example structure) CREATE TABLE orders ( order_id INT AUTO_INCREMENT PRIMARY KEY, customer_name VARCHAR(100), total DECIMAL(10,2), datetime DATETIME );
-
Run the server
cd backend python server.pyServer will start at:
http://localhost:5000
- GET
/getProducts- Retrieve all products with UOM details - PUT
/insertProduct- Add a new product - POST
/deleteProduct- Delete a product by ID
- GET
/getUOM- Get all available units of measurement
- GET
/getAllOrders- Retrieve all orders - POST
/InsertOrder- Create a new order
curl -X GET http://localhost:5000/getProductscurl -X PUT http://localhost:5000/insertProduct \
-F 'data={"product_name": "Organic Apples", "uom_id": 1, "price_per_unit": 3.50}'curl -X POST http://localhost:5000/deleteProduct \
-F 'product_id=5'Update sql_connection.py with your database credentials:
import mysql.connector
def get_sql_connection():
return mysql.connector.connect(
host='localhost',
user='your_username',
password='your_password',
database='grocery_app_database'
)# Test individual modules
python products_dao.py
python uom_dao.py- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
- Your Name - Your GitHub
- User authentication and authorization
- Inventory tracking with low stock alerts
- Sales analytics and reporting
- Barcode scanning integration
- Customer management system
- Payment processing integration
- Mobile app support
⭐ If you found this project helpful, please give it a star!