Skip to content

Repository files navigation

🛒 E-Commerce Inventory Management System

A console-based, multi-role E-Commerce Inventory Management System built in C++. The application simulates a simplified online marketplace where three types of users — Admin, Seller, and Buyer — interact with a shared in-memory data store to manage shops, products, inventory, sales, and buyer accounts, all from a colorful command-line interface (CLI).


📑 Table of Contents


📖 Overview

This project was built as an academic exercise to demonstrate practical use of object-oriented programming, STL containers, and class inheritance in C++. It models a simplified e-commerce backend where:

  • An Admin oversees the platform — registering/removing stores and messaging sellers.
  • A Seller owns and manages a Store — adding products, tracking stock, and viewing sales.
  • A Buyer shops across all registered stores — purchasing products and managing their wallet balance.

All data lives in memory for the duration of the program (there is no database or file persistence) — closing the program resets all stores, products, buyers, and messages.


✨ Key Features

👑 Admin Features

  • Secure Login — access gated behind a hardcoded admin username/password with masked password input.
  • Add Store — register a new store on behalf of a seller (name, owner, 9-digit CNIC, password).
  • View All Stores — tabular listing of every registered store with owner name, CNIC, and earnings.
  • Delete a Store — remove a single store (and its inventory) by CNIC.
  • Delete All Stores — wipe every store from the system in one action.
  • Message a Seller — view a store's product catalog and sales/earnings, then push a text message onto that store's message stack for the seller to read later.

🏪 Seller Features

  • Register a Store — create a new store with a unique 9-digit CNIC and an 8+ character password.
  • Login to Store — authenticate with CNIC + masked password.
  • Add Product — add a new item to the store's inventory (ID, name, category, price, quantity).
  • View Products — see all products currently in the store's inventory in a formatted table.
  • Delete a Product — remove stock either partially (reduce quantity) or entirely (delete the product).
  • View Earnings — see total revenue earned by the store.
  • View Messages from Admin — read admin messages in LIFO (Last-In, First-Out) order; each message is removed from the stack once viewed.

🛍️ Buyer Features

  • Register as Buyer — create an account with name, 9-digit CNIC, 8+ character password, and starting balance.
  • Login as Buyer — authenticate with CNIC + masked password.
  • Browse Stores & Products — view all stores, then drill into any store's product catalog.
  • Purchase Products — buy a chosen quantity of a product; the system validates stock availability and buyer balance, then updates the buyer's balance, the store's earnings, and the product's remaining/sold quantities.
  • Check Account Balance — view current balance; if it falls below $50, the buyer is prompted to top it up.

🧰 Tech Stack

Component Details
Language C++ (C++17, uses if constexpr)
Standard Library <unordered_map>, <stack>, <vector>, <iomanip>
Platform APIs <conio.h>, <windows.h> (Windows-only)
Interface Command-Line Interface (CLI) with ANSI color codes
Compiler MinGW g++ / MSVC (Windows)

🏗 System Architecture

The system uses class inheritance to share core data and behavior between the three user roles, all of which build on a shared ClassOfProducts base:

              ClassOfProducts (base)
              - stores (static, shared across ALL instances)
              - Product / Store structs
              - addProduct(), deleteProduct(), displayProducts()...
                     ▲              ▲              ▲
                     │              │              │
             ClassOfStores          │              │
      (RegisterStore, DisplayStores,│              │
       deleteStore, deleteAllStores)│              │
                     ▲              │              │
        ┌────────────┼──────────────┼──────────────┐
        │            │              │              │
  ClassOfAdmin   ClassOfSeller   ClassOfBuyer   (each: virtual/protected
  (Admin::Menu)  (Seller::Menu)  (Buyer::Menu)   inheritance of Products/Stores)
  • ClassOfProducts::stores is declared static, so ClassOfAdmin, ClassOfSeller, and ClassOfBuyer all read and write the same underlying store map — this is what lets a store registered by a Seller immediately show up for the Admin and Buyer.
  • Virtual inheritance (virtual protected ClassOfProducts) is used to avoid the diamond-inheritance problem, since both ClassOfStores and each role class inherit from ClassOfProducts.
  • main.cpp instantiates one object of each role class and routes the top-level menu choice to Admin->Menu(), Seller->Menu(), or Buyer->Menu().

🗃 Data Structures Used

Structure Purpose
unordered_map<string, Store> Stores every registered store, keyed by store CNIC, for O(1) average lookup.
unordered_map<int, Product> (per store) A store's inventory, keyed by Product ID.
unordered_map<string, Buyer> All buyer accounts, keyed by buyer CNIC.
stack<string> (per store) Admin → Seller messages, delivered in LIFO order.
vector<string> Welcome-screen ASCII art lines and ANSI color palette.

Key structs:

struct Product {
    int id;
    string name;
    string category;
    float price;
    int quantity;
    int sold;
};

struct Store {
    string storeName, ownerName, cnic, password;
    float earnings;
    unordered_map<int, Product> inventory;
    float totalRatings;
    int ratingCount;
    stack<string> messages;
};

struct Buyer {
    string name, cnic, password;
    float balance;
};

Note: totalRatings / ratingCount fields exist on Store to support a future store-rating feature, but rating a store is not yet wired into any menu in the current build.


📁 Project Structure

All source files live directly in the repository root — there's no nested subfolder:

inventory-cli/
├── README.md
├── main.cpp                                       # Entry point / top-level menu
├── HeaderFilesUsed.h                               # Central #include hub (STL, conio, windows)
├── NewHeader.h                                     # ValidatePriceIdQuantity<T>() input helper
├── WelcomeScreen.h                                 # Animated ASCII-art welcome banner
├── ClassOfProducts.h                               # Base class: Product/Store structs, product CRUD
├── ClassOfStores.h                                 # Store registration, listing, deletion
├── ClassOfAdmin.h                                  # Admin login + menu + seller messaging
├── ClassOfSeller.h                                 # Seller login + store management menu
├── ClassOfBuyer.h                                  # Buyer registration/login + shopping menu
├── AllClassesUsed.h                                # Convenience header that pulls in every class
├── main.exe                                        # Prebuilt Windows executable
├── E-Commerce-Inventory-Management-System.pdf      # Project report / documentation
└── E-Commerce-Inventory-Management-System.pptx     # Project presentation slides

✅ Prerequisites

Because the project uses <conio.h> and <windows.h> (for _getch(), system("cls"), and console color handling), it must be compiled and run on Windows (natively, or in a Windows VM). It will not compile as-is on Linux/macOS without modification.

You'll need one of:

  • MinGW-w64 g++ (recommended, e.g. via MSYS2 or the standalone MinGW installer), or
  • Microsoft Visual Studio (Desktop development with C++ workload), or
  • Any C++17-capable Windows compiler.

You'll also need Git installed if you want to clone the repo (or you can just download the ZIP from GitHub instead — see below).


🚀 Getting Started

1. Clone the repository

Open Command Prompt, PowerShell, or Git Bash and run:

git clone https://github.com/abmdevx/inventory-cli.git
cd inventory-cli

No Git? Click Code → Download ZIP on the GitHub page instead, then extract it and open the extracted inventory-cli folder.

Everything below assumes your terminal's current directory is the inventory-cli folder itself (the one containing main.cpp).


2. Option A: Run the prebuilt executable (Windows only)

A compiled binary is already included in the repo, so you can run it immediately without installing a compiler:

.\main.exe

(Or just double-click main.exe in File Explorer.)


2. Option B: Build from source

If you'd rather compile it yourself (recommended if you plan to edit the code):

  1. Confirm you're in the repo root (same folder as main.cpp):
    dir main.cpp   # should list the file — confirms you're in the right folder
  2. Compile with g++ (make sure MinGW's bin folder is on your PATH):
    g++ -std=c++17 main.cpp -o main.exe
    This pulls in all the .h files automatically via the #include statements in main.cpp — no need to compile them separately.
  3. Run the freshly compiled program:
    .\main.exe

Using Visual Studio instead?

  1. Open Visual Studio → Create a new project → Console App (C++).
  2. Instead of using the default main.cpp VS generates, delete it and add all the files from this repo (main.cpp and every .h file) via Project → Add Existing Item.
  3. Set the C++ language standard to C++17 (Project Properties → C/C++ → Language → C++ Language Standard).
  4. Build and run with Ctrl+F5 (Start Without Debugging).

🖥 Usage Walkthrough

  1. Launch the app — an animated, color-cycling ASCII-art welcome screen appears; press any key to continue.
  2. Main Menu — choose your role:
    1. Admin
    2. Seller
    3. Buyer
    0. Exit
    
  3. As Admin — log in with the built-in credentials (admin / admin), then add/view/delete stores or send a message to a seller.
  4. As Seller — register a new store (unique 9-digit CNIC + 8+ character password) or log in to an existing one, then manage products, view earnings, or read admin messages.
  5. As Buyer — register an account or log in, then browse stores, purchase products, and check/top-up your balance.

All numeric menu choices are entered as a single keystroke (no Enter needed), thanks to _getch().


🔒 Input Validation Rules

The system enforces the following rules at input time, re-prompting on failure:

Field Rule
Store / Buyer CNIC Exactly 9 digits, numeric only, must be unique
Store / Buyer Password 8 or more characters
Product ID / Price / Quantity Numeric only, up to 9 characters, must be greater than 0
Purchase Quantity Must be > 0 and ≤ available stock
Balance Top-up Must be > 0 and ≥ current balance

Passwords are entered with masked input (* characters) using _getch(), and CNIC/ID fields reject alphabetic or special characters as they're typed.


⚠️ Known Limitations

  • No persistence — all data (stores, products, buyers, messages) is stored in memory and is lost when the program exits; there is no file or database storage.
  • Windows-only — relies on conio.h / windows.h for keystroke capture, screen clearing, and console colors.
  • Single hardcoded admin account — admin credentials (admin / admin) are hardcoded in ClassOfAdmin.h, not configurable at runtime.
  • Store ratings not exposed — the Store struct tracks totalRatings / ratingCount, but no menu option currently lets a buyer submit a rating.
  • No password hashing — passwords are stored and compared as plain text in memory.

🔮 Possible Future Improvements

  • Add file/database persistence (e.g. write stores/buyers/products to disk on exit and reload on startup).
  • Implement the buyer store-rating feature using the existing totalRatings/ratingCount fields.
  • Cross-platform support by replacing conio.h/windows.h calls with a portable input/console library.
  • Password hashing and stronger authentication.
  • Purchase history and order tracking per buyer.

📄 Documentation

Additional project documentation is available in the repo:


Made with ❤️ and a lot of _getch() calls.

About

A console-based, multi-role E-Commerce Inventory Management System in C++. Simulates a marketplace with Admin, Seller, and Buyer roles — manage stores, products, inventory, and sales using unordered_maps and stacks. Built with OOP, class inheritance, and STL containers. Windows CLI app (conio.h/windows.h).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages