# brianalong/cplusplus-program architecture

> Architecture diagram of the GitHub repository brianalong/cplusplus-program, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brianalong/cplusplus-program
- Repository: https://github.com/brianalong/cplusplus-program

## Overview

##### Project type and purpose
- This is a multi‐application C++ repository (CS210 course assignments) containing four standalone console apps:
- Clock App
- Calculator App
- Banking App
- Inventory App
- Each app is a command‐line program that presents a text‐menu UI, performs computations or data operations, and (where applicable) persists data (e.g., inventory or banking records) to disk.

##### File structure
- Top‐level directory holds four ZIP archives, each packaging one app’s source files, plus README.md.
- main.cpp (entry point, menu loop)
- one or more .cpp/.h pairs for core functionality (e.g., Calculator.cpp/h, InventoryManager.cpp/h)
- possibly a simple file‐I/O utility or data model (e.g., Record.h)
- No web servers, no databases—just console I/O and file storage.

##### README for additional insights
- Describes the apps’ purpose (client utilities for Chada Tech).
- Indicates opportunities for refactoring (extract common code into shared modules, improve menu duplication).

a. Main components (per app)
- User (Console)
- Presentation Layer (Menu & CLI parsing)
- Business Logic Layer (App‐specific services: clock calculations, arithmetic engine, account operations, inventory CRUD)
- Data Access Layer (File I/O modules for persistence)
- Shared Common Module (proposed refactoring target for menu logic)
b. Relationships & Interactions
- User → Presentation Layer: selects menu options
- Presentation Layer → Business Logic: invokes service functions
- Business Logic → Data Access: reads/writes persistent records
- Business Logic → Presentation Layer: returns results/status for display
- All apps → (optional) Shared Common Module: use common menu routines
c. Architectural patterns & design principles
- Layered Architecture: clearly separate CLI, core logic, and file I/O
- DRY Principle: identify and extract repeated menu code into a common library
- Single Responsibility: each class/module handles one concern (e.g., Calculator vs. MenuHandler)
d. Technologies & libraries
- C++17 (or newer) standard library (iostream, fstream, chrono)
- Build tools (Makefile, if any) or manual compile commands
- Third‐party references (none in current state, but consider a small argument parser or JSON lib if extending)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    User["User (Console)"]:::user

    %% Shared Module
    Shared["CommonMenuLib"]:::shared

    %% Clock App Subsystem
    subgraph "Clock App"
        direction TB
        CA_App["Clock App"]:::system
        CA_App --> CA_Pres
        CA_Pres["MenuHandler"]:::presentation
        CA_Pres -->|invokes| CA_Logic
        CA_Logic["ClockEngine"]:::logic
        CA_Logic -->|reads/writes| CA_Persist
        CA_Persist["ClockFileHandler"]:::persistence
        CA_Pres -->|uses| Shared
    end

    %% Calculator App Subsystem
    subgraph "Calculator App"
        direction TB
        Cal_App["Calculator App"]:::system
        Cal_App --> Cal_Pres
        Cal_Pres["MenuHandler"]:::presentation
        Cal_Pres -->|invokes| Cal_Logic
        Cal_Logic["CalculatorEngine"]:::logic
        Cal_Logic -->|reads/writes| Cal_Persist
        Cal_Persist["CalcFileHandler"]:::persistence
        Cal_Pres -->|uses| Shared
    end

    %% Banking App Subsystem
    subgraph "Banking App"
        direction TB
        BA_App["Banking App"]:::system
        BA_App --> BA_Pres
        BA_Pres["MenuHandler"]:::presentation
        BA_Pres -->|invokes| BA_Logic
        BA_Logic["AccountService"]:::logic
        BA_Logic -->|reads/writes| BA_Persist
        BA_Persist["BankFileHandler"]:::persistence
        BA_Pres -->|uses| Shared
    end

    %% Inventory App Subsystem
    subgraph "Inventory App"
        direction TB
        IA_App["Inventory App"]:::system
        IA_App --> IA_Pres
        IA_Pres["MenuHandler"]:::presentation
        IA_Pres -->|invokes| IA_Logic
        IA_Logic["InventoryManager"]:::logic
        IA_Logic -->|reads/writes| IA_Persist
        IA_Persist["InventoryFileHandler"]:::persistence
        IA_Pres -->|uses| Shared
    end

    %% Connections from User to Presentation Layers
    User --> CA_Pres
    User --> Cal_Pres
    User --> BA_Pres
    User --> IA_Pres

    %% README
    README["Project Overview (README.md)"]:::shared

    %% Click events
    click CA_App "https://github.com/brianalong/cplusplus-program/blob/main/CS210 C++.zip"
    click Cal_App "https://github.com/brianalong/cplusplus-program/blob/main/CS210 Calc app.zip"
    click BA_App "https://github.com/brianalong/cplusplus-program/blob/main/CS210 Project 2 Banking APP.zip"
    click IA_App "https://github.com/brianalong/cplusplus-program/blob/main/CS210 Project 3 Inventory.zip"
    click README "https://github.com/brianalong/cplusplus-program/blob/main/README.md"

    %% Styles
    classDef user fill:#f9f,stroke:#333,stroke-width:1px
    classDef presentation fill:#8fd3f4,stroke:#333,stroke-width:1px
    classDef logic fill:#f4a582,stroke:#333,stroke-width:1px
    classDef persistence fill:#92c5de,stroke:#333,stroke-width:1px
    classDef shared fill:#b3de69,stroke:#333,stroke-width:1px
    classDef system fill:#fee090,stroke:#333,stroke-width:1px
```
