# hiprox/timesheet architecture

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

- Interactive diagram: https://gitdiagram.com/hiprox/timesheet
- Repository: https://github.com/hiprox/timesheet

## Overview

- Data Access Layer – Include the DataBase.cs file and any methods that parse the configuration (from timesheet.toml) and execute SQL operations. This layer is responsible for connecting to and querying the MySQL (MariaDB) database.
- Domain Entities – Highlight the classes under the Entities folder (Employee, Department, AttendanceRecordsStorage, MarkersStorage, ProductionCalendar) as the data models the application uses to encapsulate business data.

##### Out the relationships and interactions
- From the UI component to the Business Logic layer when a user interacts with the application (e.g., double-clicking a department).
- From the Business Logic layer to the Data Access Layer for fetching and updating data.
- From the Data Access Layer to the Database, indicating the execution of SQL queries based on the configuration settings stored in timesheet.toml.
- Data results should be shown flowing from the Database back to the UI for display.

##### Architectural patterns or principles
- Separation of concerns is key – clearly differentiate between the UI, business logic/data-access code, and the persistence layer (the MySQL database).
- Although a full MVC architecture isn’t fully implemented, you are essentially demonstrating a layered approach where each layer (presentation, logic, and data) has distinct responsibilities.
- The configuration management (using timesheet.toml) should be noted as a means to separate environment-specific parameters from the code.

##### Technologies and tools
- The application is built using Microsoft Visual Studio 2022, C#, and .NET 6.0.
- It uses Windows Forms for its UI.
- The database is MySQL/MariaDB, as indicated by the README with version details.
- Mention the role of the configuration file (timesheet.toml) for database connection settings.
- You might also represent the development environment artifacts (the Visual Studio solution and project files) very simply, as they support the development process rather than the runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interface (Windows Forms)"]
    end

    %% Business Logic Layer
    subgraph "Business Logic / Controller"
        BL["Business Logic / Controller (FormTable.cs)"]
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAL["Data Access (DataBase.cs)"]
        Config["Configuration File (timesheet.toml)"]
    end

    %% Domain Entities
    subgraph "Domain Layer"
        Entities["Domain Entities"]
    end

    %% Persistence - Database
    subgraph "Persistence"
        DB["MySQL/MariaDB Database"]
        subgraph "Database Schema"
            Depts["departments"]
            Emps["employees"]
            ProdCal["production_calendar"]
            AttRec["attendance_records"]
            Marks["markers"]
        end
    end

    %% Relationships between layers
    UI -->|"triggers"| BL
    BL -->|"fetches/upd8s"| DAL
    DAL -->|"reads config"| Config
    DAL -->|"executes SQL"| DB
    DB -->|"returns data"| DAL
    BL -->|"maps to"| Entities
    DAL -->|"maps to"| Entities

    %% Database Schema Relationships
    Depts -->|"1-to-many"| Emps
    Emps -->|"1-to-many"| AttRec

    %% Click Events
    click UI "https://github.com/hiprox/timesheet/blob/main/TimeSheet/TimeSheet/FormTable.Designer.cs"
    click BL "https://github.com/hiprox/timesheet/blob/main/TimeSheet/TimeSheet/FormTable.cs"
    click DAL "https://github.com/hiprox/timesheet/blob/main/TimeSheet/TimeSheet/DataBase.cs"
    click Config "https://github.com/hiprox/timesheet/blob/main/TimeSheet/TimeSheet/bin/Debug/net6.0-windows/timesheet.toml"
    click Entities "https://github.com/hiprox/timesheet/tree/main/TimeSheet/TimeSheet/Entities/"

    %% Styles
    classDef UI fill:#add8e6,stroke:#000,stroke-width:1px
    classDef Business fill:#90ee90,stroke:#000,stroke-width:1px
    classDef DAL fill:#ffffcc,stroke:#000,stroke-width:1px
    classDef Entity fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef Database fill:#ffcccb,stroke:#000,stroke-width:1px

    %% Apply Classes
    class UI UI
    class BL Business
    class DAL,Config DAL
    class Entities Entity
    class DB,Depts,Emps,ProdCal,AttRec,Marks Database
```
