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).
- Overview
- Key Features
- Tech Stack
- System Architecture
- Data Structures Used
- Project Structure
- Prerequisites
- Getting Started
- Usage Walkthrough
- Input Validation Rules
- Known Limitations
- Possible Future Improvements
- Documentation
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.
- 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.
- 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.
- 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.
| 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) |
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::storesis declaredstatic, soClassOfAdmin,ClassOfSeller, andClassOfBuyerall 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 bothClassOfStoresand each role class inherit fromClassOfProducts. main.cppinstantiates one object of each role class and routes the top-level menu choice toAdmin->Menu(),Seller->Menu(), orBuyer->Menu().
| 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/ratingCountfields exist onStoreto support a future store-rating feature, but rating a store is not yet wired into any menu in the current build.
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
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).
Open Command Prompt, PowerShell, or Git Bash and run:
git clone https://github.com/abmdevx/inventory-cli.git
cd inventory-cliNo Git? Click Code → Download ZIP on the GitHub page instead, then extract it and open the extracted
inventory-clifolder.
Everything below assumes your terminal's current directory is the inventory-cli folder itself (the one containing main.cpp).
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.)
If you'd rather compile it yourself (recommended if you plan to edit the code):
- 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 - Compile with
g++(make sure MinGW'sbinfolder is on yourPATH):This pulls in all theg++ -std=c++17 main.cpp -o main.exe
.hfiles automatically via the#includestatements inmain.cpp— no need to compile them separately. - Run the freshly compiled program:
.\main.exe
Using Visual Studio instead?
- Open Visual Studio → Create a new project → Console App (C++).
- Instead of using the default
main.cppVS generates, delete it and add all the files from this repo (main.cppand every.hfile) via Project → Add Existing Item. - Set the C++ language standard to C++17 (Project Properties → C/C++ → Language → C++ Language Standard).
- Build and run with Ctrl+F5 (Start Without Debugging).
- Launch the app — an animated, color-cycling ASCII-art welcome screen appears; press any key to continue.
- Main Menu — choose your role:
1. Admin 2. Seller 3. Buyer 0. Exit - As Admin — log in with the built-in credentials (
admin/admin), then add/view/delete stores or send a message to a seller. - 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.
- 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().
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.
- 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.hfor keystroke capture, screen clearing, and console colors. - Single hardcoded admin account — admin credentials (
admin/admin) are hardcoded inClassOfAdmin.h, not configurable at runtime. - Store ratings not exposed — the
Storestruct trackstotalRatings/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.
- 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/ratingCountfields. - Cross-platform support by replacing
conio.h/windows.hcalls with a portable input/console library. - Password hashing and stronger authentication.
- Purchase history and order tracking per buyer.
Additional project documentation is available in the repo:
E-Commerce-Inventory-Management-System.pdf— full project report.E-Commerce-Inventory-Management-System.pptx— presentation slides.
Made with ❤️ and a lot of _getch() calls.