# hmm0126/tax-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/hmm0126/tax-optimizer
- Repository: https://github.com/hmm0126/tax-optimizer

## Overview

#### Purpose and Entry Points
This is a small Python web service that exposes an income-tax calculation workflow through a server-rendered interface and API-oriented application entry point. The primary process entry is `app.py`; deployment startup is defined by `Procfile`. The user-facing HTML is `templates/index.html`.

#### Web Application Boundary
`app.py` owns HTTP request handling, input collection/validation, invocation of tax logic, and response rendering or serialization. It is the boundary between external clients and the calculation domain. `templates/index.html` is coupled to this layer for browser-based interaction.

#### Tax Calculation Domain
The `calculator/` package isolates business rules from the web layer:
- `calculator/income_tax.py` implements income-tax computation.
- `calculator/deductions.py` implements deduction-related calculations or rule application.
- `calculator/__init__.py` defines the package boundary.

This separation allows tax rules to be reused independently of HTTP and templates.

#### Primary Control Flow
A client submits income and deduction-related inputs to routes defined in `app.py`. The application delegates deduction processing to `calculator/deductions.py`, passes relevant taxable-income values into `calculator/income_tax.py`, then returns the calculated result through an HTTP response and, where applicable, `templates/index.html`.

The important dependency direction is: presentation/API layer → calculator domain. Calculation modules should not depend on Flask or template concerns.

#### Interfaces and Verification
The externally observable contract is exercised by `test_api.py`, indicating API behavior is a material integration boundary. Changes to request fields, response shape, validation behavior, or calculation output should preserve this contract alongside domain correctness.

#### Runtime and Deployment
The repository targets a Python runtime, with dependencies declared in `requirements.txt` and runtime version specified in `runtime.txt`. `Procfile` provides the process command expected by a platform-style process manager. No database, queue, or external service integration is represented in the repository tree; calculations appear to be request-local and stateless.

Main entry points: [`app.py`](https://github.com/hmm0126/tax-optimizer/blob/main/app.py) (Application entry), [`calculator/deductions.py`](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/deductions.py) (Deduction rules), [`calculator/income_tax.py`](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/income_tax.py) (Income-tax rules), [`calculator/__init__.py`](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/__init__.py) (Calculator package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web boundary"]
  node_app["Application entry<br/>Python web app<br/>[app.py]"]
  node_template["Tax form UI<br/>HTML template<br/>[index.html]"]
end

subgraph group_domain["Tax domain"]
  node_deductions["Deduction rules<br/>Python module<br/>[deductions.py]"]
  node_income_tax["Income-tax rules<br/>Python module<br/>[income_tax.py]"]
  node_calculator_pkg["Calculator package<br/>Python package<br/>[__init__.py]"]
end

subgraph group_runtime["Runtime &amp; deployment"]
  node_procfile["Process startup<br/>Procfile"]
  node_dependencies["Python dependencies<br/>Dependency manifest<br/>[requirements.txt]"]
  node_python_runtime["Python runtime version<br/>Runtime manifest<br/>[runtime.txt]"]
end

node_client(("External clients"))
node_api_tests["API contract tests<br/>Python tests<br/>[test_api.py]"]

node_client -->|"HTTP requests"| node_app
node_app -->|"renders"| node_template
node_app -->|"applies deductions"| node_deductions
node_app -->|"calculates tax"| node_income_tax
node_deductions -->|"taxable income"| node_income_tax
node_calculator_pkg -->|"contains"| node_deductions
node_calculator_pkg -->|"contains"| node_income_tax
node_api_tests -.->|"exercises API contract"| node_app
node_procfile -->|"starts"| node_app
node_dependencies -.->|"provides web dependencies"| node_app
node_python_runtime -.->|"runs on"| node_app
node_app -->|"HTML or API response"| node_client

click node_app "https://github.com/hmm0126/tax-optimizer/blob/main/app.py"
click node_template "https://github.com/hmm0126/tax-optimizer/blob/main/templates/index.html"
click node_deductions "https://github.com/hmm0126/tax-optimizer/blob/main/calculator/deductions.py"
click node_income_tax "https://github.com/hmm0126/tax-optimizer/blob/main/calculator/income_tax.py"
click node_calculator_pkg "https://github.com/hmm0126/tax-optimizer/blob/main/calculator/__init__.py"
click node_api_tests "https://github.com/hmm0126/tax-optimizer/blob/main/test_api.py"
click node_procfile "https://github.com/hmm0126/tax-optimizer/blob/main/Procfile"
click node_dependencies "https://github.com/hmm0126/tax-optimizer/blob/main/requirements.txt"
click node_python_runtime "https://github.com/hmm0126/tax-optimizer/blob/main/runtime.txt"

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_app,node_template toneBlue
class node_deductions,node_income_tax,node_calculator_pkg toneAmber
class node_procfile,node_dependencies,node_python_runtime toneMint
class node_client,node_api_tests toneNeutral
```

## Components

### Web boundary

- [Application entry](https://github.com/hmm0126/tax-optimizer/blob/main/app.py): Python web app · Handles HTTP, validation, orchestration, and responses. · `app.py`
- [Tax form UI](https://github.com/hmm0126/tax-optimizer/blob/main/templates/index.html): HTML template · `templates/index.html`

### Tax domain

- [Deduction rules](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/deductions.py): Python module · `calculator/deductions.py`
- [Income-tax rules](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/income_tax.py): Python module · `calculator/income_tax.py`
- [Calculator package](https://github.com/hmm0126/tax-optimizer/blob/main/calculator/__init__.py): Python package · Reusable tax-calculation boundary independent of HTTP. · `calculator/__init__.py`

### Runtime & deployment

- [Process startup](https://github.com/hmm0126/tax-optimizer/blob/main/Procfile): Procfile · Defines the platform process command. · `Procfile`
- [Python dependencies](https://github.com/hmm0126/tax-optimizer/blob/main/requirements.txt): Dependency manifest · `requirements.txt`
- [Python runtime version](https://github.com/hmm0126/tax-optimizer/blob/main/runtime.txt): Runtime manifest · `runtime.txt`

### Other components

- **External clients**: client · Browser and API consumers submit tax inputs.
- [API contract tests](https://github.com/hmm0126/tax-optimizer/blob/main/test_api.py): Python tests · Verifies request, response, validation, and calculation behavior. · `test_api.py`

## Connections

- External clients → Application entry: HTTP requests
- Application entry → Tax form UI: renders
- Application entry → Deduction rules: applies deductions
- Application entry → Income-tax rules: calculates tax
- Deduction rules → Income-tax rules: taxable income
- Calculator package → Deduction rules: contains
- Calculator package → Income-tax rules: contains
- API contract tests → Application entry: exercises API contract
- Process startup → Application entry: starts
- Python dependencies → Application entry: provides web dependencies
- Python runtime version → Application entry: runs on
- Application entry → External clients: HTML or API response
