# pslmodels/tax-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/pslmodels/tax-calculator
- Repository: https://github.com/pslmodels/tax-calculator

## Overview

##### Main Components

a. Core Components:
- Calculator Engine (calculator.py)
- Policy Management (policy.py)
- Records Management (records.py)
- Growth Factors (growfactors.py)
- Calculation Functions (calcfunctions.py)

b. Supporting Components:
- Data Management Layer (data.py)
- Input/Output Handler (taxcalcio.py)
- CLI Interface (cli/tc.py)
- Parameters System (parameters.py)
- Utilities (utils.py, utilsprvt.py)

**┌─ User Interface Layer ─────────────────┐**
- Command Line Interface (tc.py)       │
- Python API Interface                 │
- ┬───────────────────┘
- ↓
**┌─ Processing Layer ──────────────────────┐**
- Calculator Engine (calculator.py)        │
- ┌────────────────┐  ┌────────────────┐  │
- Policy Manager  │  │Records Manager  │  │
- (policy.py)     │←→│(records.py)    │  │
- ┘  └────────────────┘  │
- ↑                ↑             │
- ┌────────────────┐  ┌────────────────┐  │
- Growth Factors  │  │Calc Functions  │  │
- (growfactors.py)│  │(calcfunctions) │  │
- ┘  └────────────────┘  │
- ┬───────────────────┘
- ↓
**┌─ Data Layer ────────────────────────────┐**
- Data Management (data.py)             │
- Input/Output Processing (taxcalcio.py)│
- Configuration Files (.json)           │
- ┘

##### Key Relationships to Highlight

- Calculator class as the central orchestrator
- Policy and Records objects as primary data containers
- Growth factors influencing calculations
- Data flow from input files through processing to output
- Configuration management through JSON files

##### Implementation Details

- Modular design for easy maintenance
- Clear separation of concerns
- Data flow pathways
- Configuration management
- Testing and validation processes

##### Documentation Integration

References to:
- API documentation location
- Configuration file formats
- Input/output specifications
- Reform file structure

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#B3D9FF,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef data fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef config fill:#E6E6E6,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        CLI["Command Line Interface"]
        API["Python API Interface"]
    end

    %% Processing Layer
    subgraph Processing["Processing Layer"]
        Calculator["Calculator Engine"]
        Policy["Policy Manager"]
        Records["Records Manager"]
        Growth["Growth Factors"]
        CalcFunc["Calculation Functions"]
        Params["Parameters System"]
        Utils["Utilities"]
    end

    %% Data Layer
    subgraph Data["Data Layer"]
        DataMgmt["Data Management"]
        IO["Input/Output Handler"]
        PolicyConfig["Policy Configuration"]
        RecordsConfig["Records Configuration"]
        Reforms["Reforms System"]
        Validation["Validation System"]
    end

    %% Relationships
    CLI --> Calculator
    API --> Calculator
    Calculator --> Policy
    Calculator --> Records
    Policy <--> Records
    Growth --> Policy
    Growth --> Records
    CalcFunc --> Calculator
    Params --> Policy
    Utils --> Calculator
    DataMgmt --> Records
    IO --> Calculator
    PolicyConfig --> Policy
    RecordsConfig --> Records
    Reforms --> Policy
    Validation --> Calculator

    %% Click Events
    click Calculator "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/calculator.py"
    click Policy "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/policy.py"
    click Records "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/records.py"
    click Growth "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/growfactors.py"
    click CalcFunc "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/calcfunctions.py"
    click DataMgmt "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/data.py"
    click IO "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/taxcalcio.py"
    click CLI "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/cli/tc.py"
    click Params "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/parameters.py"
    click Utils "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/utils.py"
    click PolicyConfig "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/policy_current_law.json"
    click RecordsConfig "https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/records_variables.json"
    click Reforms "https://github.com/PSLmodels/Tax-Calculator/tree/master/taxcalc/reforms/"
    click Validation "https://github.com/PSLmodels/Tax-Calculator/tree/master/taxcalc/validation/"

    %% Style Applications
    class CLI,API ui
    class Calculator,Policy,Records,Growth,CalcFunc,Params,Utils core
    class DataMgmt,IO data
    class PolicyConfig,RecordsConfig,Reforms,Validation config
```
