Skip to content

noireveil/online-store-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Online Store Simulation (C++ OOP)

A simple terminal-based simulation program for an online store that manages transactions between buyers and sellers. This program uses C++17 and is built using Meson & Ninja.

Key Features

  • Registration & Login for Buyers and Sellers
  • Seller Management: Add and update items in their store
  • Buyer Shopping: Browse items and make purchases
  • Bank Transactions: Simulated balance transfers between bank accounts
  • Order Status Management: Track orders (Paid, Completed, Cancelled)
  • Admin Panels: Store and Bank admin menus with basic reporting
  • Data Persistence: All data (users, items, orders, bank accounts) is saved to data/simulation_data.txt on exit and loaded on startup

Prerequisites

Before you can compile and run this program, ensure you have:

  1. C++ Compiler: GCC (g++) or Clang with C++17 support
  2. Meson: Build system (meson)
  3. Ninja: Build tool (ninja)

Installation

Arch Linux:

sudo pacman -S base-devel meson ninja

Ubuntu/Debian:

sudo apt install build-essential meson ninja-build

Windows: Install Python, then:

pip install meson ninja

You'll also need a C++ compiler (Visual Studio or MinGW).

Building the Project

  1. Open terminal in the project root directory

  2. Setup Meson (first time only):

    meson setup builddir
  3. Compile the program:

    ninja -C builddir

    This creates an executable named online_store (Linux) or online_store.exe (Windows) in the builddir folder.

Running the Program

Method 1: Using Ninja Run Target

ninja -C builddir run

Method 2: Direct Execution

./builddir/online_store

Note: The program will automatically create the data/ folder and simulation_data.txt file if they don't exist. On subsequent runs, it will load previously saved data.

Optional: Clean Data

If you want to start fresh with no saved data:

rm -f data/simulation_data.txt

Project Structure

online-store-cpp/
├── meson.build              # Meson configuration file
├── main.cpp                 # Program entry point
├── include/                 # Header files (.h)
│   ├── Bank.h
│   ├── BankAccount.h
│   ├── BankTransaction.h
│   ├── Buyer.h
│   ├── Item.h
│   ├── Order.h
│   ├── Seller.h
│   ├── Store.h
│   └── Utils.h
├── src/                     # Implementation files (.cpp)
│   ├── Bank.cpp
│   ├── BankAccount.cpp
│   ├── BankTransaction.cpp
│   ├── Buyer.cpp
│   ├── Item.cpp
│   ├── Order.cpp
│   ├── Seller.cpp
│   ├── Store.cpp
│   └── Utils.cpp
├── data/                    # Data persistence folder
│   └── simulation_data.txt  # Auto-generated data file
├── builddir/                # Build output (created by Meson)
└── README.md                # This file

Usage Guide

Main Menu Options:

  1. Login - Login with existing credentials
  2. Register as Buyer - Create a new buyer account
  3. Register as Seller - Create a new seller account with a store
  4. Store Admin Menu - View store-wide reports
  5. Bank Admin Menu - View bank customer reports
  6. Exit & Save - Save all data and exit

Buyer Features:

  • Browse all available items
  • Purchase items (with bank balance)
  • View order history
  • Check daily spending
  • Manage bank account (deposit/withdraw)

Seller Features:

  • All buyer features (sellers can also buy)
  • Manage store items (add/update)
  • View incoming orders
  • Update order status
  • Discover top K popular items in their store
  • View loyal customers

Admin Features:

Store Admin:

  • View all transactions
  • List paid but not completed orders
  • View most frequent items
  • View most active buyers/sellers

Bank Admin:

  • List all bank customers
  • View dormant accounts
  • View top N most active users today
  • View customer transactions

Data Persistence

All data is automatically saved to data/simulation_data.txt when you select "Exit & Save" from the main menu. This includes:

  • User accounts (buyers and sellers)
  • Bank accounts and transaction history
  • All items in the store
  • All orders and their status

The data is automatically loaded when the program starts.

Troubleshooting

Program stuck at startup:

  • Press Enter to continue past any pause prompts
  • Check if data/ folder exists
  • Try deleting data/simulation_data.txt to start fresh

Compilation errors:

  • Ensure you have C++17 support: g++ --version (should be 7.0+)
  • Make sure Meson and Ninja are installed: meson --version, ninja --version

Menu not displaying properly:

  • Some terminals may have issues with screen clearing
  • Try running in a different terminal emulator

License

This project is for educational purposes.

Contributing

Feel free to fork and submit pull requests for improvements!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published