Skip to content

BraedonKlock/Inventory_Management_System

Repository files navigation

Inventory Management System (CST8219 – C++ Programming)

GUI-based Inventory Management System built with C++20 and Qt6 Widgets.
Manage Products, Suppliers, and Inventory Transactions, track stock levels, compute inventory value, run analytics, and save/load data from files (.txt).


Project Structure

CPP-Project-Inventory-Management-System/
│
├── CMakeLists.txt                          # Build configuration (CMake + Qt6 + GoogleTest)
├── README.md                               # This file
├── BUILD.md                                # Detailed build/setup instructions
├── GIT_WORKFLOW.md                         # Git branching and contribution guidelines
├── WORK_ASSIGNMENTS.md                     # Team member task assignments
│
├── src/                                    # All .cpp implementation files
│   ├── main.cpp                            # Entry point — creates QApplication and MainWindow
│   ├── MainWindow.cpp                      # Top-level window; hosts all pages via QTabWidget
│   │
│   ├── Product/
│   │   └── Product.cpp                     # Product data class (ID, name, category, price)
│   │
│   ├── Supplier/
│   │   └── Supplier.cpp                    # Supplier data class (ID, name, phone, email)
│   │
│   ├── Inventory/
│   │   ├── InventoryItem.cpp               # Abstract base class — shared item fields
│   │   ├── StandardItem.cpp                # Derived: value = quantity × unitPrice
│   │   ├── BulkItem.cpp                    # Derived: value accounts for bulk discount
│   │   └── RecordItem.cpp                  # Transaction record (Stock In / Stock Out)
│   │
│   ├── Managers/
│   │   ├── InventoryManager.cpp            # Central logic — manages all data collections
│   │   └── DataManager.cpp                 # Static file I/O — saves/loads all data to .txt
│   │
│   └── Pages/
│       ├── ProductsPage.cpp                # Qt page: add/edit/delete/search products
│       ├── SuppliersPage.cpp               # Qt page: add/edit/delete/search suppliers
│       ├── InventoryPage.cpp               # Qt page: add items, stock in/out, search/filter
│       ├── RecordsPage.cpp                 # Qt page: full transaction log view
│       └── AnalyticsPage.cpp               # Qt page: total value, low stock, averages, categories
│
├── include/                                # All .h header files (mirrors src/ layout)
│   ├── MainWindow.h
│   ├── RecordsPage.h
│   │
│   ├── Product/
│   │   └── Product.h
│   │
│   ├── Supplier/
│   │   └── Supplier.h
│   │
│   ├── Inventory/
│   │   ├── InventoryItem.h                 # Pure virtual computeValue() — forces override
│   │   ├── StandardItem.h
│   │   ├── BulkItem.h
│   │   └── RecordItem.h
│   │
│   ├── Managers/
│   │   ├── InventoryManager.h
│   │   └── DataManager.h
│   │
│   ├── Analytics/
│   │   └── AnalyticsEngine.h               # Template class — header-only (no .cpp needed)
│   │
│   └── Pages/
│       ├── AnalyticsPage.h
│       ├── InventoryPage.h
│       ├── ProductsPage.h
│       └── SuppliersPage.h
│
├── ui/                                     # Qt Designer .ui files (XML layout definitions)
│   ├── mainwindow.ui                       # Main window layout
│   ├── analyticshomepage.ui
│   ├── inventorypage.ui
│   ├── productspage.ui
│   ├── supplierspage.ui
│   └── recordspage.ui
│
├── data/                                   # Persistent data files (plain text, auto-loaded)
│   ├── products.txt                        # Saved product catalogue
│   ├── supplier.txt                        # Saved supplier list
│   ├── inventory.txt                       # Saved inventory items (type + fields per line)
│   └── recorded.txt                        # Saved transaction records
│
├── resources/
│   ├── resources.qrc                       # Qt resource manifest (bundles styles at compile time)
│   └── styles.qss                          # Global Qt stylesheet
│
├── Tests/
│   └── InventoryManagerTests.cpp           # GoogleTest unit tests for InventoryManager logic
│
├── run_app.sh                              # Shell script to build and launch the application
└── run_tests.sh                            # Shell script to build and run the unit tests

How the Files Relate to Each Other

Entry Point → UI Layer

src/main.cpp creates the QApplication and instantiates MainWindow.
MainWindow (src/MainWindow.cpp / include/MainWindow.h) owns a single InventoryManager instance and passes a reference to each of the five page classes. It also calls DataManager to load all saved data on startup and save on exit.

Page Layer → Manager Layer

Each page class (ProductsPage, SuppliersPage, InventoryPage, RecordsPage, AnalyticsPage) holds a reference to the shared InventoryManager. Pages read from the manager to populate tables and write to it when the user adds, edits, deletes, or performs stock transactions. No page talks to another page directly.

Manager Layer → Data Layer

InventoryManager (src/Managers/InventoryManager.cpp) is the single source of truth for all runtime data. It owns:

  • std::unordered_map<std::string, Product> — the product catalogue
  • std::unordered_map<std::string, Supplier> — the supplier list
  • std::vector<std::unique_ptr<InventoryItem>> — polymorphic inventory items
  • std::vector<RecordedItem> — transaction records

DataManager (src/Managers/DataManager.cpp) provides static methods (loadProducts, saveProducts, etc.) that read from and write to the .txt files in data/. It receives and returns data via the containers owned by InventoryManager. No data is stored inside DataManager itself.

Inheritance Hierarchy

InventoryItem  (abstract base — include/Inventory/InventoryItem.h)
├── StandardItem   — computeValue() = quantity × unitPrice
└── BulkItem       — computeValue() = quantity × unitPrice × (1 − bulkDiscountRate) / qtyPerBulkUnit

Template Class

AnalyticsEngine<T> (include/Analytics/AnalyticsEngine.h) is a header-only template class that accepts any inventory item type. It computes total value, average value, low-stock lists, and category groupings. AnalyticsPage instantiates it for both StandardItem and BulkItem and merges the results.

Unit Tests

Tests/InventoryManagerTests.cpp uses GoogleTest (fetched automatically by CMake via FetchContent). The test executable links against the same .cpp sources as the main app (excluding Qt UI files) so business logic is tested in isolation without the GUI.


Features

Products

  • Add / Edit / Delete products
  • Fields: numeric ID, name, user-defined category, price
  • Search by name or ID, filter by category (dropdown)
  • Product catalogue is the source for creating inventory items

Suppliers

  • Add / Edit / Delete suppliers
  • Fields: ID, name, phone number, email
  • Search suppliers by name or ID

Inventory

  • Two item types: StandardItem and BulkItem
    • StandardItem: value = quantity × unitPrice
    • BulkItem: supports a bulk discount rate (0.0–1.0) and quantity per bulk unit; value accounts for discount
  • Record transactions: Stock In / Stock Out
  • Stock-out blocked if quantity requested exceeds available stock
  • Search by name and filter by category; table sorted by ID

Records

  • Full transaction log of all Stock In / Stock Out events
  • Shows: item ID, item name, transaction type, quantity changed
  • Persisted to file alongside inventory data

Analytics (Template Class)

  • Powered by AnalyticsEngine<T> — a generic template class
  • Total inventory value across all items
  • Low-stock list with a configurable threshold (default: 10 units)
  • Average item value
  • Items grouped by category (count per category)

Persistence (File I/O)

  • DataManager uses static methods — no instance needed
  • Saves/loads: products, suppliers, inventory items, and transaction records (.txt)
  • Data loaded automatically on startup
  • File paths configurable at runtime via the menu bar
  • Corrupted or missing files handled with QMessageBox error dialogs

C++ Features Demonstrated

Feature Where Used
Abstract base class with pure virtual InventoryItem::computeValue()
Polymorphism std::unique_ptr<InventoryItem> storing StandardItem / BulkItem
Template class AnalyticsEngine<T> (header-only)
Smart pointers std::unique_ptr<InventoryItem> in InventoryManager
STL containers std::vector, std::unordered_map, std::map throughout
Operator overloading operator<< on Product and TransactionType
Friend function operator<< declared friend in Product
Non-copyable / non-movable class InventoryManager (deleted copy/move constructors)
Static methods DataManager — all methods are static
Const-correct overloaded getters InventoryManager provides const and non-const versions of all getters

Tech & Requirements

  • C++20
  • Qt6 Widgets (GUI)
  • CMake 3.16+ (build system)
  • GoogleTest (unit testing — fetched automatically)

How to Build and Run

Full instructions are in BUILD.md. Quick start:

# 1. Configure
cmake -B build -S .

# 2. Build
cmake --build build

# 3. Run the application
./build/InventoryManagementApp

# 4. Run unit tests
cd build && ctest --output-on-failure

Alternatively, use the provided scripts:

./run_app.sh      # Build and launch the application
./run_tests.sh    # Build and run unit tests

About

A C++20 and Qt6 Widgets inventory management application for managing products, suppliers, stock transactions, inventory analytics, and persistent file-based data through a desktop GUI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors