# luizinhoh2o1/tabelas-ibpt architecture

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

- Interactive diagram: https://gitdiagram.com/luizinhoh2o1/tabelas-ibpt
- Repository: https://github.com/luizinhoh2o1/tabelas-ibpt

## Overview

This repository builds a static archive and API for historical IBPTax tax tables, plus browser-based consultation and a tax-rate panel. The main workflow is to read archived ZIPs, parse their CSVs, and generate compressed records, indexes, and consolidated yearly CSVs for static hosting; users then filter and fetch the published data. Economic series and panel calculations are an additional capability. Source excerpts show the build and panel internals; browser behavior and some generated outputs are documented in the README rather than sampled source.

Main entry points: [`src/geradorJson.ts`](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/geradorJson.ts) (Static API files), [`src/construir.ts`](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/construir.ts) (Build orchestrator), [`src/gerarPainel.ts`](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarPainel.ts) (Panel data generator), [`src/economia.ts`](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/economia.ts) (Economic calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data inputs"]
  node_archives[("IBPT ZIP archive")]
  node_economic_data[("Economic series")]
end

subgraph group_build["API generation"]
  node_csv_parser["CSV parser<br/>[processadorCsv.ts]"]
  node_constants["Types and UF map<br/>[constantes.ts]"]
  node_contracts["Data contracts<br/>[tipos.ts]"]
  node_builder["Build orchestrator<br/>[construir.ts]"]
  node_json_generator["API file generator<br/>[geradorJson.ts]"]
end

subgraph group_insights["Panel and economics"]
  node_economic_calcs["Economic calculations<br/>[economia.ts]"]
  node_index_updater["Economic data updater<br/>[gerarIndices.ts]"]
  node_panel_generator["Panel data generator<br/>[gerarPainel.ts]"]
  node_map_generator["UF map generator<br/>[gerarMalha.ts]"]
end

subgraph group_delivery["Static product"]
  node_api_files[("Static API files<br/>[geradorJson.ts]")]
  node_query_page["Browser consultation<br/>[index.html]"]
  node_panel_page["Tax panel<br/>[painel.html]"]
  node_pages["GitHub Pages"]
end

node_user(("Browser user"))

node_builder -->|"reads ZIPs"| node_archives
node_builder -->|"parses CSVs"| node_csv_parser
node_csv_parser -->|"maps types"| node_constants
node_builder -->|"generates files"| node_json_generator
node_json_generator -->|"writes JSON and CSV"| node_api_files
node_builder -->|"publishes data"| node_api_files
node_builder -->|"generates panel data"| node_panel_generator
node_panel_generator -->|"reads compressed records"| node_api_files
node_panel_generator -->|"uses calculations"| node_economic_calcs
node_economic_calcs -->|"reads series"| node_economic_data
node_index_updater -->|"updates series"| node_economic_data
node_index_updater -->|"checks INSS rules"| node_economic_calcs
node_map_generator -->|"writes map data"| node_pages
node_user -->|"chooses filters"| node_query_page
node_query_page -->|"fetches filtered data"| node_api_files
node_panel_page -->|"loads panel data"| node_api_files
node_api_files -->|"serves static files"| node_pages

click node_archives "https://github.com/luizinhoh2o1/tabelas-ibpt/tree/master/repositorio-ibpt"
click node_economic_data "https://github.com/luizinhoh2o1/tabelas-ibpt/tree/master/dados"
click node_csv_parser "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/processadorCsv.ts"
click node_constants "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/constantes.ts"
click node_contracts "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/tipos.ts"
click node_builder "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/construir.ts"
click node_json_generator "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/geradorJson.ts"
click node_api_files "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/geradorJson.ts"
click node_economic_calcs "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/economia.ts"
click node_index_updater "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarIndices.ts"
click node_panel_generator "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarPainel.ts"
click node_map_generator "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarMalha.ts"
click node_query_page "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/docs/index.html"
click node_panel_page "https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/docs/painel.html"

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_archives,node_economic_data,node_user toneBlue
class node_csv_parser,node_constants,node_contracts,node_builder,node_json_generator toneAmber
class node_economic_calcs,node_index_updater,node_panel_generator,node_map_generator toneMint
class node_api_files,node_query_page,node_panel_page,node_pages toneRose
```

## Components

### Data inputs

- [IBPT ZIP archive](https://github.com/luizinhoh2o1/tabelas-ibpt/tree/master/repositorio-ibpt): `repositorio-ibpt`
- [Economic series](https://github.com/luizinhoh2o1/tabelas-ibpt/tree/master/dados): `dados`

### API generation

- [CSV parser](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/processadorCsv.ts): `src/processadorCsv.ts`
- [Types and UF map](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/constantes.ts): `src/constantes.ts`
- [Data contracts](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/tipos.ts): `src/tipos.ts`
- [Build orchestrator](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/construir.ts): `src/construir.ts`
- [API file generator](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/geradorJson.ts): `src/geradorJson.ts`

### Panel and economics

- [Economic calculations](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/economia.ts): `src/economia.ts`
- [Economic data updater](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarIndices.ts): `src/gerarIndices.ts`
- [Panel data generator](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarPainel.ts): `src/gerarPainel.ts`
- [UF map generator](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/gerarMalha.ts): `src/gerarMalha.ts`

### Static product

- [Static API files](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/src/geradorJson.ts): `src/geradorJson.ts`
- [Browser consultation](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/docs/index.html): `docs/index.html`
- [Tax panel](https://github.com/luizinhoh2o1/tabelas-ibpt/blob/master/docs/painel.html): `docs/painel.html`
- **GitHub Pages**

### Other components

- **Browser user**

## Connections

- Build orchestrator → IBPT ZIP archive: reads ZIPs (evidence: `README.md`)
- Build orchestrator → CSV parser: parses CSVs (evidence: `src/construir.ts`)
- CSV parser → Types and UF map: maps types (evidence: `src/processadorCsv.ts`)
- Build orchestrator → API file generator: generates files (evidence: `src/construir.ts`)
- API file generator → Static API files: writes JSON and CSV (evidence: `README.md`)
- Build orchestrator → Static API files: publishes data (evidence: `src/construir.ts`)
- Build orchestrator → Panel data generator: generates panel data (evidence: `src/construir.ts`)
- Panel data generator → Static API files: reads compressed records (evidence: `src/gerarPainel.ts`)
- Panel data generator → Economic calculations: uses calculations (evidence: `src/gerarPainel.ts`)
- Economic calculations → Economic series: reads series (evidence: `src/economia.ts`)
- Economic data updater → Economic series: updates series (evidence: `src/gerarIndices.ts`)
- Economic data updater → Economic calculations: checks INSS rules (evidence: `src/gerarIndices.ts`)
- UF map generator → GitHub Pages: writes map data (evidence: `src/gerarMalha.ts`)
- Browser user → Browser consultation: chooses filters (evidence: `README.md`)
- Browser consultation → Static API files: fetches filtered data (evidence: `README.md`)
- Tax panel → Static API files: loads panel data (evidence: `README.md`)
- Static API files → GitHub Pages: serves static files (evidence: `README.md`)
