# datpham0412/cgpa-calculator architecture

> Architecture diagram of the GitHub repository datpham0412/cgpa-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datpham0412/cgpa-calculator
- Repository: https://github.com/datpham0412/cgpa-calculator

## Overview

##### Project Type and Purpose
- This is a terminal-based CGPA Calculator written in C++.
- It uses SQLite (via the external SQLiteCpp library) to manage database interactions.
- The application is designed using object-oriented principles, and its functionality centers on managing student details, courses, and grade calculations.
- The inclusion of unit tests (using Google Test) indicates that testing is also a critical part of the system.

##### File Structure
- Top-level items include configuration files (e.g., CMakeLists.txt, .gitignore, .gitmodules) and essential documentation (README.md, LICENSE).
- The “include” directory contains header files (Course, Database, Menu, Student, StudentOperations) that define the core interfaces/classes.
- The “src” directory contains the corresponding implementation (.cpp) files including main.cpp, which acts as the entry point.
- The “external” directory holds the SQLiteCpp third-party library, a key component for database management.
- The “test” directory contains unit tests for validating various pieces of functionality (e.g., tests for Course, Student, and the main functionality).

##### Main Components and Their Relationships
a. Application Entry Point:
- The main function (in main.cpp) initializes the system and orchestrates the flow.
b. User Interface (UI):
- The Menu component provides the terminal-based interface for user interaction.
c. Domain/Business Logic:
- Student, Course, and StudentOperations represent the core entities and operations.
- The application logic calculates GPA/CGPA and manages student/course records.
d. Data Persistence:
- The Database component handles all interactions with the SQLite database using the SQLiteCpp library.
e. External Libraries and Dependencies:
- SQLiteCpp (under “external”) is used to encapsulate the database operations.
f. Testing:
- Separate unit test components (under “test”) ensure the integrity of core logic.

##### Diagramming the System Architecture
- “Student”, “Course”, and “StudentOperations” which contain the core business logic.
- Optionally, include a separate section or note that points to “Google Test” for unit testing, indicating that tests are performed on key components.

##### Architectural Patterns and Technologies
- Separation of concerns: The UI (Menu) is distinct from the core business logic (Student, Course, StudentOperations) and the data access layer (Database).
- That object-oriented programming principles are prevalent; each domain element (student, course, etc.) encapsulates its behavior.
- That CMake is being used for managing builds, and although not directly part of the runtime architecture, it is critical for setting up the development environment.
- That the project is designed for cross-platform terminal operations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Entry Point
    subgraph "Entry Point"
        MAIN["CGPA Calculator Main"]:::entry
    end

    %% User Interface Layer
    subgraph "User Interface"
        MENU["User Interface (Menu)"]:::ui
    end

    %% Domain/Business Logic Layer
    subgraph "Domain/Business Logic"
        STUDENT["Student (Domain)"]:::business
        COURSE["Course (Domain)"]:::business
        STUDENTOPS["StudentOperations (Business Logic)"]:::business
    end

    %% Data Persistence Layer
    subgraph "Data Persistence"
        DATABASE["Database (Data Persistence)"]:::persistence
        SQLITE["SQLiteCpp Library (External)"]:::external
    end

    %% Testing Component
    subgraph "Testing"
        GTEST["Google Test (Unit Tests)"]:::testing
    end

    %% Connections
    MAIN -->|"initiates"| MENU
    MENU -->|"calls"| STUDENT
    MENU -->|"calls"| COURSE
    MENU -->|"calls"| STUDENTOPS
    STUDENTOPS -->|"accesses"| DATABASE
    DATABASE -->|"uses"| SQLITE
    GTEST --- STUDENT
    GTEST --- COURSE
    GTEST --- STUDENTOPS

    %% Click Events
    click MAIN "https://github.com/datpham0412/cgpa-calculator/blob/main/src/main.cpp"
    click MENU "https://github.com/datpham0412/cgpa-calculator/blob/main/include/Menu.h"
    click MENU "https://github.com/datpham0412/cgpa-calculator/blob/main/src/Menu.cpp"
    click STUDENT "https://github.com/datpham0412/cgpa-calculator/blob/main/include/Student.h"
    click STUDENT "https://github.com/datpham0412/cgpa-calculator/blob/main/src/Student.cpp"
    click COURSE "https://github.com/datpham0412/cgpa-calculator/blob/main/include/Course.h"
    click COURSE "https://github.com/datpham0412/cgpa-calculator/blob/main/src/Course.cpp"
    click STUDENTOPS "https://github.com/datpham0412/cgpa-calculator/blob/main/include/StudentOperations.h"
    click STUDENTOPS "https://github.com/datpham0412/cgpa-calculator/blob/main/src/StudentOperations.cpp"
    click DATABASE "https://github.com/datpham0412/cgpa-calculator/blob/main/include/Database.h"
    click DATABASE "https://github.com/datpham0412/cgpa-calculator/blob/main/src/Database.cpp"
    click SQLITE "https://github.com/datpham0412/cgpa-calculator/tree/main/external/SQLiteCpp"
    click GTEST "https://github.com/datpham0412/cgpa-calculator/blob/main/test/TestCourse.cpp"
    click GTEST "https://github.com/datpham0412/cgpa-calculator/blob/main/test/TestMain.cpp"
    click GTEST "https://github.com/datpham0412/cgpa-calculator/blob/main/test/TestStudent.cpp"

    %% Styles
    classDef entry fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef ui fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef business fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef persistence fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef testing fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
