Skip to content

A comprehensive backend API for managing grocery store operations including products, inventory, orders, and units of measurement. Built with Python Flask and MySQL.

Notifications You must be signed in to change notification settings

amalvj7/GroceryFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 Grocery Store Management System

A comprehensive backend API for managing grocery store operations including products, inventory, orders, and units of measurement. Built with Python Flask and MySQL.

🚀 Features

  • 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

📁 Project Structure

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

🛠️ Setup Instructions

Prerequisites

  • Python 3.7+
  • MySQL Server
  • pip (Python package manager)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd GROCERY_APP_PYTHON
  2. Set up virtual environment

    python -m venv myenv
    # On Windows:
    myenv\Scripts\activate
    # On macOS/Linux:
    source myenv/bin/activate
  3. Install dependencies

    pip install flask mysql-connector-python
  4. Database Setup

    • Start your MySQL server
    • Create database: CREATE DATABASE grocery_app_database;
    • Update sql_connection.py with your MySQL credentials
  5. 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
    );
  6. Run the server

    cd backend
    python server.py

    Server will start at: http://localhost:5000

📡 API Endpoints

Products

  • GET /getProducts - Retrieve all products with UOM details
  • PUT /insertProduct - Add a new product
  • POST /deleteProduct - Delete a product by ID

Units of Measurement

  • GET /getUOM - Get all available units of measurement

Orders

  • GET /getAllOrders - Retrieve all orders
  • POST /InsertOrder - Create a new order

📝 API Usage Examples

Get All Products

curl -X GET http://localhost:5000/getProducts

Add New Product

curl -X PUT http://localhost:5000/insertProduct \
  -F 'data={"product_name": "Organic Apples", "uom_id": 1, "price_per_unit": 3.50}'

Delete Product

curl -X POST http://localhost:5000/deleteProduct \
  -F 'product_id=5'

🔧 Configuration

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

🚦 Running Tests

# Test individual modules
python products_dao.py
python uom_dao.py

🤝 Contributing

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

📜 License

This project is open source and available under the MIT License.

👨‍💻 Author

🔮 Future Enhancements

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

About

A comprehensive backend API for managing grocery store operations including products, inventory, orders, and units of measurement. Built with Python Flask and MySQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published