# ullyanne/folha-de-pagamento architecture

> Architecture diagram of the GitHub repository ullyanne/folha-de-pagamento, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ullyanne/folha-de-pagamento
- Repository: https://github.com/ullyanne/folha-de-pagamento

## Overview

##### Project type and purpose
- This is a standalone, console-based payroll management system written in Python (“Folha de Pagamento”).
- It provides a CLI (run.py) to add/remove employees, record time cards, sales results, service fees, run payroll, schedule pay dates, and supports undo/redo via Memento.
- Key use case: manage employees, compute and disburse pay according to configurable schedules and deduction rules.

##### File structure
- Top-level:
- run.py – the CLI entry point (commands dispatcher)
- src/ – core package
- Folha_de_Pagamento.pdf – spec document
- src/company.py – Company aggregate holding all employees and coordinating operations
- src/employee/ – Employee hierarchy
- employeeFactory.py – Factory Method to instantiate Hourly, Salaried or Commissioned
- commissioned.py, hourly.py, salaried.py – concrete employee types
- employee.py – base abstract class
- src/payroll/ – payroll and schedule
- payroll.py – runs payroll cycle
- schedule.py – computes pay dates
- src/syndicate/ – union membership & fee management
- src/table/ – Template Method for consistent console table rendering (columns/rows)
- src/tools/ – cross-cutting utilities
- memento.py – undo/redo support
- util.py – helper functions
- src/workedHours.py – time-card (“punch”) logic

##### README for architectural hints
- Lists design patterns: Factory Method, Memento, Template Method, Extract/Move Method, Replace Temp With Query, Dispatch Table
- Describes core functions (add/remove employee, time card, sales, fee, change data, list, run payroll, undo/redo, payment schedules)

##### Details
- Every subpackage as its own component
- Cross-cutting utilities (Memento, Util) connecting to all state-modifying commands
- Schedule variants (weekly, bi-weekly, monthly) as part of Schedule component
- Design patterns next to the components that implement them (e.g., “<<Factory Method>>” on EmployeeFactory)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI["CLI UI / Command Dispatcher<br/>&laquo;Dispatch Table&raquo;"]:::ui
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Company["Company<br/>&laquo;Aggregate Root&raquo;"]:::domain
        subgraph "Employee Package"
            direction TB
            EmpFactory["EmployeeFactory<br/>&laquo;Factory Method&raquo;"]:::domain
            EmpBase["Employee (abstract)"]:::domain
            Hourly["HourlyEmployee"]:::domain
            Salaried["SalariedEmployee"]:::domain
            Commissioned["CommissionedEmployee"]:::domain
        end
        PayrollService["PayrollService"]:::domain
        ScheduleService["ScheduleService"]:::domain
        SyndicateService["SyndicateService"]:::domain
        FeeService["FeeManagement"]:::domain
        WorkedHours["WorkedHours / TimeCard Logic"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Memento["Memento Module<br/>&laquo;Memento&raquo;"]:::infra
        Util["Utilities Module"]:::infra
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Columns["TableColumns<br/>&laquo;Template Method&raquo;"]:::pres
        Rows["TableRows<br/>&laquo;Template Method&raquo;"]:::pres
    end

    %% Relationships
    UI -->|issues commands| Company
    UI -->|issues commands| PayrollService
    UI -->|issues commands| WorkedHours
    UI -->|issues commands| SyndicateService

    Company -->|uses| EmpFactory
    EmpFactory -->|instantiates| EmpBase
    EmpFactory -->|creates| Hourly
    EmpFactory -->|creates| Salaried
    EmpFactory -->|creates| Commissioned

    PayrollService -->|calculates| ScheduleService
    PayrollService -->|iterates| Company
    Company -->|contains| EmpBase
    PayrollService -->|applies fees via| FeeService
    SyndicateService -->|manages| FeeService

    WorkedHours -->|updates hours on| EmpBase

    Company -->|delegates schedule| ScheduleService

    Memento -->|wraps operations on| Company
    Memento -->|wraps operations on| EmpBase
    Util -->|assists| Company
    Util -->|assists| PayrollService
    Util -->|assists| ScheduleService
    Util -->|assists| SyndicateService

    Company -->|renders reports via| Columns
    Company -->|renders reports via| Rows
    PayrollService -->|outputs via| Columns
    PayrollService -->|outputs via| Rows

    %% Click Events
    click UI "https://github.com/ullyanne/folha-de-pagamento/blob/main/run.py"
    click Company "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/company.py"
    click EmpFactory "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/employee/employeeFactory.py"
    click EmpBase "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/employee/employee.py"
    click Hourly "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/employee/hourly.py"
    click Salaried "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/employee/salaried.py"
    click Commissioned "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/employee/commissioned.py"
    click PayrollService "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/payroll/payroll.py"
    click ScheduleService "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/payroll/schedule.py"
    click SyndicateService "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/syndicate/syndicate.py"
    click FeeService "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/syndicate/fee.py"
    click Columns "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/table/columns.py"
    click Rows "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/table/rows.py"
    click Memento "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/tools/memento.py"
    click Util "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/tools/util.py"
    click WorkedHours "https://github.com/ullyanne/folha-de-pagamento/blob/main/src/workedHours.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px;
    classDef domain fill:#D0FFD0,stroke:#333,stroke-width:1px;
    classDef infra fill:#FFF5C2,stroke:#333,stroke-width:1px;
    classDef pres fill:#FFD8A8,stroke:#333,stroke-width:1px;
```
