# mezea11/health-care-system architecture

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

- Interactive diagram: https://gitdiagram.com/mezea11/health-care-system
- Repository: https://github.com/mezea11/health-care-system

## Overview

##### Project type and purpose
- This is a C#/.NET 9 console application implementing a layered, in-memory-plus-CSV “healthcare management” system with a strong focus on security/privacy and fine-grained role-based access control (RBAC).

##### Main architectural layers and components
- Presentation Layer (Console UI)
- Program.cs – application entry point
- NotificationService.cs – console notifications/alerts
- Models/PersonnelUI.cs – role-specific menus and prompts
- Business Logic Layer (Services & Domain Entities)
- Services/JournalService.cs – journal-reading/writing workflows
- Services/ScheduleService.cs – appointment scheduling workflows
- Models/*.cs – domain entities: User, Appointment, Location, Schedule, WorkShift
- Models/RolePermissions.cs & PasswordHelper.cs – RBAC and authentication logic
- Models/Utils.cs – shared helper functions
- Data Access Layer
- Models/FileHandler.cs – repository-style API for reading/writing CSV files
- Persistence / Storage
- Data/*.txt / Data/*.csv – persistent storage of users, appointments, journals, backups
- Unit Tests (XUnit)
- Tests/UserTests.cs, Tests/AdminTests.cs – automated validation of authentication, registration, permissions

##### Relationships and data flows
- User inputs → Presentation Layer
- Presentation invokes → Business Services (JournalService, ScheduleService)
- Services operate on → Domain Entities (User, Appointment, etc.)
- Services call → FileHandler
- FileHandler reads/writes → CSV data files in Data folder
- RolePermissions & PasswordHelper are used by both UI and services for auth checks

##### Key patterns and principles
- Layered architecture: clean separation UI → services → data access → storage
- RBAC & security as cross-cutting concerns (Password hashing, Permission checks)
- Repository-style pattern in FileHandler for abstracting CSV I/O
- Domain-driven design: small cohesive classes for entities and operations

##### Technologies & frameworks
- C# / .NET 9 console application
- CSV files as lightweight persistent store
- XUnit for unit testing of core business/security logic

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Program["Program.cs"]:::presentation
        NotificationService["NotificationService.cs"]:::presentation
        PersonnelUI["PersonnelUI.cs"]:::presentation
    end

    %% Business Services Layer
    subgraph "Business Services Layer"
        direction TB
        JournalService["JournalService.cs"]:::business
        ScheduleService["ScheduleService.cs"]:::business
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        direction TB
        User["User.cs"]:::domain
        Appointment["Appointment.cs"]:::domain
        Location["Location.cs"]:::domain
        Schedule["Schedule.cs"]:::domain
        WorkShift["WorkShift.cs"]:::domain
        RolePermissions["RolePermissions.cs"]:::domain
        PasswordHelper["PasswordHelper.cs"]:::domain
        Utils["Utils.cs"]:::domain
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        FileHandler["FileHandler.cs"]:::dataaccess
    end

    %% Data Storage
    subgraph "Data Storage"
        direction TB
        DataDir["Data/"]:::storage
        AppointmentsFile["appointments.txt"]:::storage
        JournalsFile["journals.txt"]:::storage
        UsersFile["users.csv"]:::storage
        BackupFile["backup.txt"]:::storage
    end

    %% Unit Tests
    subgraph "Unit Tests"
        direction TB
        UserTests["UserTests.cs"]:::tests
        AdminTests["Admintests.cs"]:::tests
    end

    %% Relationships
    Program -->|invokes| JournalService
    Program -->|invokes| ScheduleService
    Program -->|alerts via| NotificationService
    PersonnelUI -->|prompts| Program

    JournalService -->|manipulate| Appointment
    JournalService -->|manipulate| User
    ScheduleService -->|manipulate| Appointment
    ScheduleService -->|manipulate| Schedule

    JournalService -->|calls| FileHandler
    ScheduleService -->|calls| FileHandler

    FileHandler -->|read/write| AppointmentsFile
    FileHandler -->|read/write| JournalsFile
    FileHandler -->|read/write| UsersFile
    FileHandler -->|read/write| BackupFile

    %% Cross-cutting
    Program -.->|auth checks| RolePermissions
    Program -.->|hash passwords| PasswordHelper
    JournalService -.->|auth checks| RolePermissions
    ScheduleService -.->|auth checks| RolePermissions
    JournalService -.->|hash passwords| PasswordHelper
    ScheduleService -.->|hash passwords| PasswordHelper

    %% Tests relationships
    UserTests -->|tests auth| RolePermissions
    UserTests -->|tests hashing| PasswordHelper
    AdminTests -->|tests admin scenarios| RolePermissions

    %% Click Events
    click Program "https://github.com/mezea11/health-care-system/blob/master/Program.cs"
    click NotificationService "https://github.com/mezea11/health-care-system/blob/master/NotificationService.cs"
    click PersonnelUI "https://github.com/mezea11/health-care-system/blob/master/Models/PersonnelUI.cs"
    click JournalService "https://github.com/mezea11/health-care-system/blob/master/Services/JournalService.cs"
    click ScheduleService "https://github.com/mezea11/health-care-system/blob/master/Services/ScheduleService.cs"
    click User "https://github.com/mezea11/health-care-system/blob/master/Models/User.cs"
    click Appointment "https://github.com/mezea11/health-care-system/blob/master/Models/Appointment.cs"
    click Location "https://github.com/mezea11/health-care-system/blob/master/Models/Location.cs"
    click Schedule "https://github.com/mezea11/health-care-system/blob/master/Models/Schedule.cs"
    click WorkShift "https://github.com/mezea11/health-care-system/blob/master/Models/WorkShift.cs"
    click RolePermissions "https://github.com/mezea11/health-care-system/blob/master/Models/RolePermissions.cs"
    click PasswordHelper "https://github.com/mezea11/health-care-system/blob/master/Models/PasswordHelper.cs"
    click Utils "https://github.com/mezea11/health-care-system/blob/master/Models/Utils.cs"
    click FileHandler "https://github.com/mezea11/health-care-system/blob/master/Models/FileHandler.cs"
    click DataDir "https://github.com/mezea11/health-care-system/tree/master/Data/"
    click AppointmentsFile "https://github.com/mezea11/health-care-system/blob/master/Data/appointments.txt"
    click JournalsFile "https://github.com/mezea11/health-care-system/blob/master/Data/journals.txt"
    click UsersFile "https://github.com/mezea11/health-care-system/blob/master/Data/users.csv"
    click BackupFile "https://github.com/mezea11/health-care-system/blob/master/Data/backup.txt"
    click UserTests "https://github.com/mezea11/health-care-system/blob/master/Tests/UserTests.cs"
    click AdminTests "https://github.com/mezea11/health-care-system/blob/master/Tests/Admintests.cs"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef business fill:#d4edda,stroke:#333,stroke-width:1px
    classDef domain fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef dataaccess fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef storage fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef tests fill:#f5c6cb,stroke:#333,stroke-width:1px
```
