# loganihrishi/healthcare-management-system architecture

> Architecture diagram of the GitHub repository loganihrishi/healthcare-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/loganihrishi/healthcare-management-system
- Repository: https://github.com/loganihrishi/healthcare-management-system

## Overview

##### Project Overview & Main Components
- Project Type & Purpose: This is a healthcare management system designed to track patient information and manage appointment scheduling. It offers both a GUI and a TUI interface to allow healthcare staff to add, modify, cancel, and search appointments, as well as persist and load data from files.
- Main components identified from the file tree and README include:
a. User Interface (UI) Layer:
- GUI components (located in src/main/ui/gui – e.g., AppDetailsGUI, CancelAppGUI, PatientDetailsGUI, Main)
- TUI components (located in src/main/ui/tui – e.g., Main, StartApplication)
b. Model / Domain Layer:
- Core domain objects (in src/main/model – Appointment, Patient, Disease, Event, EventLog, and AppointmentList)
c. Persistence Layer:
- File handling logic (in src/main/persistence – AppointmentFileHandler, PatientFileHandler, WriteToFile) that interacts with the JSON data files stored in the "data" directory.
d. Testing Layer:
- Tests for both the model and persistence layers (located under src/test) that ensure proper functioning of the system.
e. Support Libraries & External Dependencies:
- External JARs for JSON processing, JUnit-based testing, and additional utilities (found in the lib directory)

##### Relationships and Interactions between Components
- The Model/Domain Layer contains business logic and encapsulates state (e.g., Appointment, Patient). This layer interacts with the Persistence Layer to persist data (using classes such as AppointmentFileHandler and PatientFileHandler) into the JSON files.
- The Persistence Layer acts as the intermediary between the domain model and the stored data. It manages reading from and writing to the files in the data directory.
- An Event Logging component (via the Event and EventLog classes) logs actions and events such as appointment cancellations and retrieval attempts, which may be optionally included as a subordinate process within the Model.
- The Testing Layer, although not part of the runtime architecture, verifies the interactions between these components and should be mentioned as part of the development and quality assurance process.

##### Architectural Patterns and Design Principles
- The project follows a separation of concerns:
- The UI layer is separated into different modules (GUI and TUI) which both interact with the same underlying model.
- The domain model is decoupled from the persistence mechanism, which hints at a layered or MVC-like pattern even if a formal controller isn’t explicitly defined.
- File-based persistence (using JSON files) rather than a traditional database, with file handlers abstracting data I/O operations.
- The design also supports event logging to track key actions and errors.

##### Final Advice
- Every component is clearly labeled.
- Incorporate annotations (if possible) to note any major functions or responsibilities of each component.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Main Layers as Subgraphs
    subgraph "User Interface Layer"
        GUI["GUI (src/main/ui/gui)"]:::ui
        TUI["Text-based UI (src/main/ui/tui)"]:::ui
    end

    subgraph "Domain/Model Layer"
        DOMAIN["Business Logic/Domain (src/main/model)"]:::domain
    end

    subgraph "Persistence Layer"
        PERSIST["Persistence (src/main/persistence)"]:::persistence
    end

    DATA["Data Files (data)"]:::data
    TEST["Testing (src/test)"]:::testing
    EXT["External Dependencies (lib)"]:::external

    %% Data Flow Connections
    GUI -->|"triggers"| DOMAIN
    TUI -->|"triggers"| DOMAIN
    DOMAIN -->|"persists_to"| PERSIST
    PERSIST -->|"reads/writes"| DATA

    %% External Dependencies and Testing Influence
    EXT -->|"supports"| DOMAIN
    EXT -->|"supports"| PERSIST
    TEST ---|"verifies"| DOMAIN
    TEST ---|"verifies"| PERSIST

    %% Click Events
    click GUI "https://github.com/loganihrishi/healthcare-management-system/tree/main/src/main/ui/gui"
    click TUI "https://github.com/loganihrishi/healthcare-management-system/tree/main/src/main/ui/tui"
    click DOMAIN "https://github.com/loganihrishi/healthcare-management-system/tree/main/src/main/model"
    click PERSIST "https://github.com/loganihrishi/healthcare-management-system/tree/main/src/main/persistence"
    click DATA "https://github.com/loganihrishi/healthcare-management-system/tree/main/data"
    click TEST "https://github.com/loganihrishi/healthcare-management-system/tree/main/src/test"
    click EXT "https://github.com/loganihrishi/healthcare-management-system/tree/main/lib"

    %% Styles
    classDef ui fill:#f7c1c0,stroke:#b30000,stroke-width:2px;
    classDef domain fill:#c1f7c0,stroke:#006600,stroke-width:2px;
    classDef persistence fill:#c1d4f7,stroke:#003399,stroke-width:2px;
    classDef data fill:#f7f0c1,stroke:#999900,stroke-width:2px;
    classDef testing fill:#e1c1f7,stroke:#660099,stroke-width:2px;
    classDef external fill:#d4c1f7,stroke:#4b0082,stroke-width:2px;
```
