Skip to content

anandteertha/Inventory-management-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏭 Inventory Management System

Python MySQL MariaDB License

A comprehensive inventory management system for prepared/frozen meals manufacturers

Features β€’ Installation β€’ Usage β€’ Demo


πŸ“‹ Table of Contents


🎯 About

This project implements a production-ready inventory management system for a prepared/frozen meals manufacturer. The system provides comprehensive functionality for managing products, ingredients, suppliers, manufacturers, batches, and production workflows with robust database constraints and business logic enforcement.

Status Version Database


πŸ‘₯ Team Members

Member Name Unity ID
Pranav V pvareny
Christopher Dillon Michels Cdmichel
Anandteertha Ramesh Rao arrao6
Edward Feng sfeng9

✨ Features

πŸ” Role-Based Access Control

Manufacturer Supplier Viewer

πŸ‘¨β€πŸ­ Manufacturer Features

  • βœ… Create and manage product types with categories
  • βœ… Versioned recipe plans (BOM) management
  • βœ… Record ingredient receipts with validation
  • βœ… Create product batches with ingredient consumption
  • βœ… FEFO (First Expired First Out) lot selection πŸŽ“
  • βœ… Inventory reports (on-hand, nearly out of stock, almost expired)
  • βœ… Batch cost calculation and summaries
  • βœ… Recall & traceability system πŸŽ“

πŸͺ Supplier Features

  • βœ… Manage ingredients supplied
  • βœ… Create/update ingredient definitions (atomic or compound)
  • βœ… Maintain ingredient formulations with versioning
  • βœ… Do-not-combine list management πŸŽ“
  • βœ… Receive ingredient batches with automatic lot numbering

πŸ‘οΈ General Viewer Features

  • βœ… Browse available products by category
  • βœ… Generate flattened ingredient lists for products
  • βœ… Compare products for incompatibilities πŸŽ“

πŸ“Š Query System

  • βœ… 5 pre-defined analytical queries
  • βœ… Supplier spending analysis
  • βœ… Product cost analysis
  • βœ… Ingredient conflict detection

πŸŽ“ Graduate Features

Grad

  • FEFO (First Expired First Out): Automatic lot selection prioritizing earliest expiring batches
  • Recall & Traceability: Track affected product batches for ingredient recalls
  • Incompatibility Checking: Real-time conflict detection during recipe creation
  • Product Comparison: Compare products for ingredient incompatibilities

πŸ› οΈ Tech Stack

Python MySQL MariaDB

  • Backend: Python 3.7+
  • Database: MySQL/MariaDB
  • Database Driver: mysql-connector-python
  • Environment Management: python-dotenv
  • Interface: Menu-driven CLI

πŸ“¦ Installation

Prerequisites

Requirements

  • Python 3.7 or higher
  • MySQL/MariaDB database server (8.0+)
  • MySQL command-line client (for database setup)

Step 1: Clone Repository

git clone <repository-url>
cd database-management-system

Step 2: Install Dependencies

pip install -r requirements.txt

Or install manually:

pip install mysql-connector-python python-dotenv

Step 3: Database Setup

Option A: Using the Application (Recommended)

  1. Run the application:

    python main.py
  2. Select option 5. Database Setup (Drop & Recreate)

  3. Type YES to confirm

The script will automatically:

  • Drop existing database (if any)
  • Create fresh database
  • Load all schema, triggers, and procedures
  • Insert sample data

Option B: Manual Setup

# Create database
mysql -u root -p -e "CREATE DATABASE inventory_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

# Load schema and data
mysql -u root -p inventory_management < inventory-management.sql
mysql -u root -p inventory_management < triggers.sql
mysql -u root -p inventory_management < stored_procedures.sql
mysql -u root -p inventory_management < sample-data.sql

βš™οΈ Configuration

Environment Variables

Create a .env file in the project root:

DB_HOST=localhost
DB_NAME=inventory_management
DB_USER=root
DB_PASSWORD=your_password
DB_PORT=3306

⚠️ Note: The .env file is gitignored. Never commit database credentials!

Security


πŸš€ Usage

Running the Application

python main.py

Main Menu Options

  1. Manufacturer - Product and batch management
  2. Supplier - Ingredient and formulation management
  3. General (Viewer) - Browse products and view ingredient lists
  4. View Queries - Execute pre-defined analytical queries
  5. Database Setup - Drop and recreate database (⚠️ destructive)

Example Workflow

# 1. Start application
python main.py

# 2. Select role (e.g., Manufacturer)
# 3. Enter user ID (e.g., MFG001)
# 4. Navigate through menu options

πŸ—„οΈ Database Schema

Core Tables

Table Description
UserDetails User accounts with role-based access
Product Product definitions with categories
Ingredient Atomic and compound ingredients
IngredientFormulation Supplier-specific ingredient formulations
ProductBOM Bill of materials for products
RecipePlan Versioned recipe plans
IngredientBatch Ingredient inventory batches
ProductBatch Production batches
IngredientConsumption Ingredient consumption tracking
IngredientIncompatibility Ingredient conflict rules

Stored Procedures

Procedures

  • RecordProductionBatch - Creates product batch with validation
  • RecordIngredientIntake - Records ingredient batch intake
  • ConsumeIngredientLot - Consumes ingredient lots into product batches
  • RecalculateBatchCost - Recalculates batch costs

Triggers

Triggers

  • Auto-generate ingredient lot numbers
  • Enforce 90-day expiration rule
  • Prevent expired consumption
  • Maintain inventory on-hand quantities
  • Role validation for manufacturers and suppliers

🎬 Demo Instructions

Test Users

Role User ID Name
Manufacturer MFG001 Manufacturer One
Manufacturer MFG002 Manufacturer Two
Supplier 20 SupplierA Inc.
Supplier 21 SupplierB Co.

Demo Scenarios

1. Manufacturer Demo (MFG001)

1. Login as Manufacturer β†’ Enter ID: MFG001
2. Products β†’ Create/Update
3. Products β†’ Recipe Plans
4. Production β†’ Create Product Batch
5. Reports β†’ View all reports
6. (Grad) Recall & Traceability

2. Supplier Demo (20)

1. Login as Supplier β†’ Enter ID: 20
2. Manage Ingredients Supplied
3. Ingredients β†’ Create/Update
4. Ingredients β†’ Do-Not-Combine
5. Inventory β†’ Receive Ingredient Batch

3. General Viewer Demo

1. Login as General Viewer
2. Browse Products
3. Product β†’ Ingredient List
4. (Grad) Compare Products

4. Queries Demo

1. Select "View Queries"
2. Execute all 5 required queries:
   - Query 1: Last batch ingredients
   - Query 2: Supplier spending analysis
   - Query 3: Unit cost lookup
   - Query 4: Conflict detection
   - Query 5: Supplier coverage analysis

πŸ“ Project Structure

database-management-system/
β”œβ”€β”€ πŸ“„ main.py                    # Main entry point
β”œβ”€β”€ πŸ“„ database.py                # Database connection & operations
β”œβ”€β”€ πŸ“„ database_setup.py          # Database setup script
β”œβ”€β”€ πŸ“„ manufacturer.py             # Manufacturer role functionality
β”œβ”€β”€ πŸ“„ supplier.py                # Supplier role functionality
β”œβ”€β”€ πŸ“„ general_viewer.py          # General viewer functionality
β”œβ”€β”€ πŸ“„ queries.py                 # Required queries
β”œβ”€β”€ πŸ“„ enums.py                   # Enumerations
β”œβ”€β”€ πŸ“„ requirements.txt           # Python dependencies
β”œβ”€β”€ πŸ“„ .env                       # Environment variables (gitignored)
β”œβ”€β”€ πŸ“„ .gitignore                 # Git ignore rules
β”œβ”€β”€ πŸ“„ README.md                  # This file
β”‚
β”œβ”€β”€ πŸ—„οΈ inventory-management.sql   # Database schema
β”œβ”€β”€ πŸ—„οΈ triggers.sql               # Database triggers
β”œβ”€β”€ πŸ—„οΈ stored_procedures.sql      # Stored procedures
└── πŸ—„οΈ sample-data.sql            # Sample data

πŸ” Required Queries

Queries

  1. Last Batch Ingredients: List ingredients and lot numbers of last batch of Steak Dinner (100) by MFG001
  2. Supplier Spending: For MFG002, list all suppliers and total amount spent
  3. Unit Cost: Find unit cost for product lot 100-MFG001-B0901
  4. Conflict Detection: Find conflicting ingredients for product lot 100-MFG001-B0901
  5. Supplier Coverage: Which manufacturers has supplier James Miller (21) NOT supplied to?

πŸ› Troubleshooting

Database Connection Error

Error

  • βœ… Check .env file configuration
  • βœ… Verify database server is running
  • βœ… Ensure database exists and user has proper permissions
  • βœ… Test connection: mysql -u root -p -h localhost

Import Errors

Error

  • βœ… Install dependencies: pip install -r requirements.txt
  • βœ… Verify Python version: python --version (should be 3.7+)
  • βœ… Check virtual environment activation

SQL Errors

Error

  • βœ… Verify all SQL files executed in order
  • βœ… Check database setup completed successfully
  • βœ… Verify sample data loaded correctly
  • βœ… Use Database Setup option (option 5) to recreate

Tables Not Created

Error

  • βœ… Run Database Setup from main menu (option 5)
  • βœ… Check MySQL command-line client is installed
  • βœ… Verify SQL files are in project directory
  • βœ… Check file permissions

πŸ“ Notes

  • πŸ–₯️ Interface: Menu-driven CLI (no GUI)
  • πŸ”’ Constraints: Enforced via triggers and stored procedures
  • πŸŽ“ Grad Features: FEFO, recall/traceability, incompatibility checking
  • πŸ”„ Composition: Supports one-level compound ingredient composition
  • βœ… Validation: All business rules enforced at database level

πŸ“„ License

License

This project is for educational purposes (CSC540 - Project 1).


πŸ™ Acknowledgments

  • Course: CSC540 - Database Management Systems
  • Institution: North Carolina State University
  • Project: Inventory Management for Prepared/Frozen Meals Manufacturer

Made with ❀️ by Team CSC540

Status Version

About

A project for inventory management using relational database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages