# tadyuh76/oop---hrms architecture

> Architecture diagram of the GitHub repository tadyuh76/oop---hrms, 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/tadyuh76/oop---hrms
- Repository: https://github.com/tadyuh76/oop---hrms

## Overview

##### Main Components
- User Interface (UI) / Presentation Layer:
- Forms/Windows – Representing the WinForms UI components like MainForm, Employee forms, Department forms, Attendance forms, Leave forms, and Payroll forms.
- Domain Layer (Core):
- Domain Models – Classes representing entities like Employee, Department, Attendance, Payroll, LeaveRequest, etc.
- Factories & Events – Modules (e.g., EmployeeFactory, EventArgs) that encapsulate creation logic and event handling.
- Custom Exceptions – For business rule violations.
- Service Layer (Business Logic):
- Services – Components handling operations such as AttendanceService, DepartmentService, EmployeeService, LeaveService, PayrollService, and RoleSelectionService.
- Storage Layer / Data Access:
- Repository Implementation – JSONFileStorage and FileManager handling file-based I/O and data serialization.
- Data files – JSON files (Employees.json, Departments.json, etc.) that act as the data source.
- Supporting Utilities:
- Core utilities like ColorPalette, Enums, etc., which support the overall functionality within the layers.

##### Relationships and Data Flow
- The UI (Forms) interacts with the Service Layer to process user commands.
- The Service Layer contains the business logic and calls the Domain Layer for operations on business entities.
- The Storage layer is accessed by the Service Layer (using repository-like patterns) to perform persistent data operations (read/write to JSON files).

##### Architectural Patterns
- Layered Architecture: Clearly separate the UI, service, and data layers.
- Use of Factories for object creation improves modularity.
- Employ repository/file storage for handling persistence.
- Implementation of event-driven communication (using Events/Delegates).

##### Details on Technologies and Tools
- WinForms for the UI.
- C# (.NET) for business and domain logic.
- JSON file handling via custom serialization.
- Visual Studio project structure (indicating .csproj, use of .NET 8.0) which supports the multi-layered architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer (UI)"
        mainForm["MainForm"]:::ui
        empForm["EmployeeForm"]:::ui
        deptForm["DepartmentForm"]:::ui
        attForm["AttendanceForm"]:::ui
        leaveForm["LeaveForm"]:::ui
        payrollForm["PayrollForm"]:::ui
    end

    subgraph "Service Layer (Business Logic)"
        attService["AttendanceService"]:::service
        deptService["DepartmentService"]:::service
        empService["EmployeeService"]:::service
        leaveService["LeaveService"]:::service
        payrollService["PayrollService"]:::service
        roleService["RoleSelectionService"]:::service
    end

    subgraph "Domain Layer (Core)"
        emp["Employee"]:::domain
        dept["Department"]:::domain
        attendance["Attendance"]:::domain
        payroll["Payroll"]:::domain
        leaveReq["LeaveRequest"]:::domain
        empFactory["EmployeeFactory"]:::domain
        eventArgs["EventArgs"]:::domain
        customEx["CustomExceptions"]:::domain
    end

    subgraph "Data Storage Layer"
        fileManager["FileManager"]:::storage
        jsonStorage["JSONFileStorage"]:::storage
        dataFiles["Data Files"]:::storage
    end

    subgraph "Supporting Utilities"
        colorPalette["ColorPalette"]:::utils
        enums["Enums"]:::utils
    end

    %% UI to Service Layer connections
    mainForm -->|"calls"| empService
    empForm  -->|"calls"| empService
    deptForm -->|"calls"| deptService
    attForm  -->|"calls"| attService
    leaveForm-->|"calls"| leaveService
    payrollForm -->|"calls"| payrollService

    %% Service to Domain Layer connections
    empService -->|"handles"| emp
    deptService -->|"handles"| dept
    attService -->|"handles"| attendance
    payrollService -->|"handles"| payroll
    leaveService -->|"handles"| leaveReq

    %% Service to Storage Layer connections
    empService -->|"persists"| jsonStorage
    empService -->|"uses"| fileManager

    %% Domain internal interactions (Factory and Events)
    empFactory -->|"creates"| emp
    eventArgs   -->|"triggers"| emp
    emp         -->|"validated_by"| customEx

    %% Storage file interaction
    jsonStorage -->|"reads/writes"| dataFiles

    %% Domain support from utilities
    emp -->|"supported_by"| colorPalette

    %% Click Events
    click mainForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"
    click empForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"
    click deptForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"
    click attForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"
    click leaveForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"
    click payrollForm "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Forms"

    click emp "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Core/Models"
    click dept "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Core/Models"
    click empFactory "https://github.com/tadyuh76/oop---hrms/blob/main/HRManagementSystem/Core/Factory (EmployeeFactory.cs)"
    click eventArgs "https://github.com/tadyuh76/oop---hrms/blob/main/HRManagementSystem/Core/EventArgs.cs"
    click customEx "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Core/Exceptions"

    click empService "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Services"

    click fileManager "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Storage"
    click jsonStorage "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Storage"
    click dataFiles "https://github.com/tadyuh76/oop---hrms/tree/main/HRManagementSystem/Data"

    click colorPalette "https://github.com/tadyuh76/oop---hrms/blob/main/HRManagementSystem/Core/ColorPalette.cs"
    click enums "https://github.com/tadyuh76/oop---hrms/blob/main/HRManagementSystem/Core/Enums.cs"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef service fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef domain fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
    classDef storage fill:#f5cba7,stroke:#d35400,stroke-width:2px;
    classDef utils fill:#d7bde2,stroke:#6c3483,stroke-width:2px;
```
