# ramenofficialgovpatsy/payrollhelper architecture

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

- Interactive diagram: https://gitdiagram.com/ramenofficialgovpatsy/payrollhelper
- Repository: https://github.com/ramenofficialgovpatsy/payrollhelper

## Overview

1. **Application type and runtime**
   - `PayrollHelper` is a **desktop WinForms application** targeting **.NET 6** on Windows.
   - `Program.cs` is the entry point, and `global.json` pins the SDK version so the project builds consistently with .NET 6 tooling.

2. **Top-level architectural shape**
   - The repo is organized into three main layers:
     - **UI layer**: WinForms forms for login, menu, CRUD screens, analytics, and reports.
     - **Data/access layer**: EF Core models and DbContext classes for PostgreSQL.
     - **Support utilities**: hashing, validation, formatting, and logging helpers.
   - Most behavior is driven by form events rather than a service/API boundary.

3. **Primary user flow**
   - The app starts at **LoginForm**.
   - On successful authentication, the user is routed to the **Menu/Dashboard** area.
   - From there, the user opens task-specific forms for employees, payments, taxes, positions, analytics, database editing, and reports.

4. **Authentication subsystem**
   - User accounts are handled separately from the main payroll database.
   - The README and file tree indicate a **`users.json` file** is created in the app folder and used for login/create-user flows.
   - Passwords are hashed with **SHA256**; the hashing logic is covered by `HashingTests.cs`.
   - This makes authentication a lightweight file-backed subsystem, distinct from the PostgreSQL payroll data.

5. **Payroll data model**
   - The core business entities live under `PayrollHelper/Models`:
     - `Employee`
     - `Payment`
     - `Position`
     - `Taxation`
     - `SalaryAndBonus`
   - These classes represent the payroll domain and are the objects that the forms read and edit.

6. **Database persistence boundary**
   - The app uses **Entity Framework Core** to talk to **PostgreSQL**.
   - `PayrollDbContext.cs` and `payroll_dbContext.cs` suggest a mix of custom and scaffolded/generated context code.
   - `App.config` likely supplies the DB connection string and other runtime settings.
   - The database schema is also documented in `Docs/DatabaseScripts/`, which includes create-table, foreign-key, seed, and drop scripts.

7. **Database setup and seeding**
   - The SQL scripts in `Docs/DatabaseScripts` define the physical database structure outside of the app runtime:
     - table creation
     - foreign key wiring
     - initial data insertion
     - full teardown
   - This implies the app expects a prebuilt PostgreSQL schema and seeded reference data before normal use.

8. **CRUD and admin screens**
   - Several forms implement the operational CRUD surface:
     - `ManagePaymentsForm`
     - `ManageTaxationForm`
     - `CreateUserForm`
     - `EditDatasBaseForm`
     - employee-related screens in the dashboard/menu flow
   - The README notes **database editing is admin-only**, so authorization affects navigation and screen availability.

9. **Analytics and reporting subsystem**
   - `AnalyticsForm` handles visualization of payroll trends and summaries, such as:
     - monthly/quarterly/yearly payment dynamics
     - distribution by payment type
     - top employees
   - `ReportsForm` generates output in **.txt** and **.csv** formats, meaning report generation is an export boundary between the database and files.

10. **Shared cross-cutting utilities**
   - `ValidationHelper` centralizes input validation and error highlighting for forms.
   - `FormattingHelper` standardizes display/serialization formatting.
   - `Logger` provides application logging.
   - These helpers reduce duplication across the WinForms screens and are likely invoked from multiple UI modules.

11. **Testing scope**
   - The test project is focused on core helper logic, not UI automation.
   - `FormattingTests`, `HashingTests`, and `ValidationTests` indicate the most important non-UI behaviors are:
     - output formatting
     - password hashing
     - input validation
   - This suggests business rules are partially extracted into testable utility code.

12. **What to draw as the main architecture**
   - A good diagram would show:
     - **User → WinForms UI**
     - **UI → helpers** for validation/formatting/hashing
     - **UI → EF Core DbContext → PostgreSQL**
     - **UI → users.json** for authentication/admin user management
     - **Database/Models → analytics & reports → file exports**
   - The key boundaries are: **desktop UI**, **file-backed auth**, **relational payroll database**, and **export/report generation**.

Main entry points: [`PayrollHelper/Models/PayrollDbContext.cs`](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/PayrollDbContext.cs) (DbContext), [`PayrollHelper/Menu.cs`](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Menu.cs) (Menu), [`PayrollHelper/LoginForm.cs`](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/LoginForm.cs) (Login Form), [`PayrollHelper/DashBoardForm.cs`](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/DashBoardForm.cs) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["WinForms UI"]
  node_program["Program<br/>entrypoint<br/>[Program.cs]"]
  node_login["Login Form<br/>auth UI<br/>[LoginForm.cs]"]
  node_menu["Menu<br/>navigation UI<br/>[Menu.cs]"]
  node_dashboard["Dashboard<br/>home UI<br/>[DashBoardForm.cs]"]
  node_manage_payments["Payments<br/>CRUD UI"]
  node_manage_taxation["Taxation<br/>CRUD UI"]
  node_edit_db["DB Editor<br/>admin UI"]
  node_create_user["Create User<br/>admin UI<br/>[CreateUserForm.cs]"]
  node_analytics["Analytics<br/>analysis UI<br/>[AnalyticsForm.cs]"]
  node_reports["Reports<br/>export UI<br/>[ReportsForm.cs]"]
end

subgraph group_data["Payroll Data"]
  node_employee["Employee<br/>domain model<br/>[Employee.cs]"]
  node_payment["Payment<br/>domain model<br/>[Payment.cs]"]
  node_position["Position<br/>domain model<br/>[Position.cs]"]
  node_taxation["Taxation<br/>domain model<br/>[Taxation.cs]"]
  node_salary_bonus["Salary & Bonus<br/>domain model<br/>[SalaryAndBonus.cs]"]
  node_dbcontext[("DbContext<br/>EF Core context")]
  node_scaffolded_ctx[("Scaffolded Context<br/>generated EF Core")]
end

subgraph group_auth["Auth Files"]
  node_users_json["users.json<br/>auth store<br/>[example_users.json]"]
end

subgraph group_support["Shared Helpers"]
  node_hashing["Hashing<br/>security helper<br/>[Logger.cs]"]
  node_validation["Validation<br/>form helper"]
  node_formatting["Formatting<br/>format helper"]
  node_logger["Logger<br/>[Logger.cs]"]
end

subgraph group_docs["Database Scripts"]
  node_sql_scripts["SQL Scripts<br/>database setup"]
end

node_program -->|"starts"| node_login
node_login -->|"reads/writes"| node_users_json
node_login -->|"hashes"| node_hashing
node_login -->|"checks"| node_validation
node_login -->|"opens"| node_menu
node_menu -->|"navigates"| node_dashboard
node_menu -->|"opens"| node_manage_payments
node_menu -->|"opens"| node_manage_taxation
node_menu -->|"opens"| node_edit_db
node_menu -->|"opens"| node_create_user
node_menu -->|"opens"| node_analytics
node_menu -->|"opens"| node_reports
node_manage_payments -->|"uses"| node_dbcontext
node_manage_taxation -->|"uses"| node_dbcontext
node_edit_db -->|"uses"| node_dbcontext
node_analytics -->|"reads"| node_dbcontext
node_reports -->|"reads"| node_dbcontext
node_reports -->|"formats"| node_formatting
node_dashboard -->|"shows"| node_employee
node_manage_payments -->|"edits"| node_payment
node_manage_taxation -->|"edits"| node_taxation
node_dashboard -->|"uses"| node_position
node_dashboard -->|"uses"| node_salary_bonus
node_dbcontext -->|"maps"| node_employee
node_dbcontext -->|"maps"| node_payment
node_dbcontext -->|"maps"| node_position
node_dbcontext -->|"maps"| node_taxation
node_dbcontext -->|"maps"| node_salary_bonus
node_scaffolded_ctx -.->|"reinforces"| node_dbcontext
node_dbcontext -.->|"matches"| node_sql_scripts
node_validation -->|"supports"| node_manage_payments
node_validation -->|"supports"| node_manage_taxation
node_validation -->|"supports"| node_create_user
node_formatting -->|"supports"| node_dashboard
node_logger -->|"logs"| node_program

click node_program "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Program.cs"
click node_login "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/LoginForm.cs"
click node_menu "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Menu.cs"
click node_dashboard "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/DashBoardForm.cs"
click node_manage_payments "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ManagePaymentsForm.cs"
click node_manage_taxation "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ManageTaxationForm.cs"
click node_edit_db "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/EditDatasBaseForm.cs"
click node_create_user "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/CreateUserForm.cs"
click node_analytics "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/AnalyticsForm.cs"
click node_reports "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ReportsForm.cs"
click node_employee "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Employee.cs"
click node_payment "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Payment.cs"
click node_position "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Position.cs"
click node_taxation "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Taxation.cs"
click node_salary_bonus "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/SalaryAndBonus.cs"
click node_dbcontext "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/PayrollDbContext.cs"
click node_scaffolded_ctx "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/payroll_dbContext.cs"
click node_users_json "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/Docs/example_users.json"
click node_hashing "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Logger.cs"
click node_validation "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ValidationHelper.cs"
click node_formatting "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/FormattingHelper.cs"
click node_logger "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Logger.cs"
click node_sql_scripts "https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/Docs/DatabaseScripts/1_create_tables.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_login,node_menu,node_dashboard,node_manage_payments,node_manage_taxation,node_edit_db,node_create_user,node_analytics,node_reports toneBlue
class node_employee,node_payment,node_position,node_taxation,node_salary_bonus,node_dbcontext,node_scaffolded_ctx toneAmber
class node_users_json toneMint
class node_hashing,node_validation,node_formatting,node_logger toneRose
class node_sql_scripts toneIndigo
```

## Components

### WinForms UI

Desktop screens and navigation flow

- [Program](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Program.cs): entrypoint · App startup and main form selection · `PayrollHelper/Program.cs`
- [Login Form](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/LoginForm.cs): auth UI · User authentication screen · `PayrollHelper/LoginForm.cs`
- [Menu](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Menu.cs): navigation UI · Post-login navigation hub · `PayrollHelper/Menu.cs`
- [Dashboard](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/DashBoardForm.cs): home UI · Primary landing and summary screen · `PayrollHelper/DashBoardForm.cs`
- [Payments](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ManagePaymentsForm.cs): CRUD UI · Payment management and editing · `PayrollHelper/ManagePaymentsForm.cs`
- [Taxation](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ManageTaxationForm.cs): CRUD UI · Taxation management and editing · `PayrollHelper/ManageTaxationForm.cs`
- [DB Editor](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/EditDatasBaseForm.cs): admin UI · Admin-only database editing screen · `PayrollHelper/EditDatasBaseForm.cs`
- [Create User](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/CreateUserForm.cs): admin UI · User account creation screen · `PayrollHelper/CreateUserForm.cs`
- [Analytics](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/AnalyticsForm.cs): analysis UI · Payroll trends and summaries · `PayrollHelper/AnalyticsForm.cs`
- [Reports](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ReportsForm.cs): export UI · CSV and TXT report generation · `PayrollHelper/ReportsForm.cs`

### Payroll Data

EF Core models and database context

- [Employee](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Employee.cs): domain model · Employee payroll entity · `PayrollHelper/Models/Employee.cs`
- [Payment](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Payment.cs): domain model · Payment and compensation entity · `PayrollHelper/Models/Payment.cs`
- [Position](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Position.cs): domain model · Job position reference entity · `PayrollHelper/Models/Position.cs`
- [Taxation](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/Taxation.cs): domain model · Tax rate and deduction entity · `PayrollHelper/Models/Taxation.cs`
- [Salary & Bonus](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/SalaryAndBonus.cs): domain model · Salary and bonus data entity · `PayrollHelper/Models/SalaryAndBonus.cs`
- [DbContext](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/PayrollDbContext.cs): EF Core context · Primary database access boundary · `PayrollHelper/Models/PayrollDbContext.cs`
- [Scaffolded Context](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Models/payroll_dbContext.cs): generated EF Core · Generated PostgreSQL context artifact · `PayrollHelper/Models/payroll_dbContext.cs`

### Auth Files

File-backed user account flow

- [users.json](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/Docs/example_users.json): auth store · File-backed user account data · `Docs/example_users.json`

### Shared Helpers

Cross-cutting utility code

- [Hashing](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Logger.cs): security helper · SHA256 password hashing logic · `PayrollHelper/Logger.cs`
- [Validation](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/ValidationHelper.cs): form helper · Input validation and highlighting · `PayrollHelper/ValidationHelper.cs`
- [Formatting](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/FormattingHelper.cs): format helper · Display and serialization formatting · `PayrollHelper/FormattingHelper.cs`
- [Logger](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/PayrollHelper/Logger.cs): utility · Application logging helper · `PayrollHelper/Logger.cs`

### Database Scripts

External SQL schema and seed scripts

- [SQL Scripts](https://github.com/ramenofficialgovpatsy/payrollhelper/blob/main/Docs/DatabaseScripts/1_create_tables.sql): database setup · Create, seed, foreign key, and drop scripts · `Docs/DatabaseScripts/1_create_tables.sql`

## Connections

- Program → Login Form: starts · Application launches into authentication
- Login Form → users.json: reads/writes · Login and create-user flow uses file-backed accounts
- Login Form → Hashing: hashes · Passwords are verified with SHA256 hashing
- Login Form → Validation: checks · Validates login input and feedback
- Login Form → Menu: opens · Successful authentication routes to main navigation
- Menu → Dashboard: navigates · Main hub opens dashboard view
- Menu → Payments: opens · Navigation to payment management
- Menu → Taxation: opens · Navigation to taxation management
- Menu → DB Editor: opens · Admin-only database editing access
- Menu → Create User: opens · Admin flow for creating accounts
- Menu → Analytics: opens · Navigation to analytics screens
- Menu → Reports: opens · Navigation to export/report screens
- Payments → DbContext: uses · CRUD operations go through EF Core context
- Taxation → DbContext: uses · CRUD operations go through EF Core context
- DB Editor → DbContext: uses · Database editing is backed by EF Core
- Analytics → DbContext: reads · Analytics aggregates payroll data from the database
- Reports → DbContext: reads · Reports are generated from persisted payroll data
- Reports → Formatting: formats · Output is shaped for TXT and CSV exports
- Dashboard → Employee: shows · Dashboard and forms work with payroll entities
- Payments → Payment: edits · Payment screen manipulates payment records
- Taxation → Taxation: edits · Taxation screen manipulates tax records
- Dashboard → Position: uses · Position data participates in payroll workflows
- Dashboard → Salary & Bonus: uses · Salary and bonus data participates in payroll workflows
- DbContext → Employee: maps · Context persists employee entities
- DbContext → Payment: maps · Context persists payment entities
- DbContext → Position: maps · Context persists position entities
- DbContext → Taxation: maps · Context persists taxation entities
- DbContext → Salary & Bonus: maps · Context persists salary and bonus entities
- Scaffolded Context → DbContext: reinforces · Generated and custom context code both define DB access
- DbContext → SQL Scripts: matches · Database context aligns with external schema scripts
- Validation → Payments: supports · Shared validation is reused across forms
- Validation → Taxation: supports · Shared validation is reused across forms
- Validation → Create User: supports · Shared validation is reused across forms
- Formatting → Dashboard: supports · Formatting helper standardizes display output
- Logger → Program: logs · Application-wide logging support
