# leandrotsampa/fatorsimples architecture

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

- Interactive diagram: https://gitdiagram.com/leandrotsampa/fatorsimples
- Repository: https://github.com/leandrotsampa/fatorsimples

## Overview

FatorSimples is a desktop app for service businesses to calculate Simples Nacional and Fator R, plan monthly transfers, compare outcomes, and maintain a tax history. Users enter company details and monthly revenue/payroll, then review the calculation and save or import records. The app also supports PDF and JSON transfer, print-ready reports, onboarding, settings, and updated tax tables. The calculation, storage, Electron, and remote-table paths are supported by sampled source references; some feature wiring is unsampled, so those links are shown as unverified.

Main entry points: [`src/App.tsx`](https://github.com/leandrotsampa/fatorsimples/blob/main/src/App.tsx) (App coordinator), [`src/utils/taxCalculations.ts`](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/taxCalculations.ts) (Tax calculations), [`src/components/MonthApurationView.tsx`](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/MonthApurationView.tsx) (Monthly calculation), [`src/components/ImportDocumentModal.tsx`](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ImportDocumentModal.tsx) (PGDAS document import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_welcome["Welcome and setup<br/>[Welcome.tsx]"]
  node_month["Monthly calculation"]
  node_comparison["Fator R comparison<br/>[ComparisonView.tsx]"]
  node_settings["Company and tax settings<br/>[SettingsModal.tsx]"]
  node_report["Printable report"]
end

subgraph group_tax["Tax domain"]
  node_engine["Tax calculations<br/>[taxCalculations.ts]"]
  node_tax_types["Tax domain types<br/>[tax.ts]"]
  node_tables["Official tax tables"]
end

subgraph group_records["Records and transfer"]
  node_history["Monthly history<br/>[HistoryTable.tsx]"]
  node_add_month["Add or edit month<br/>[AddMonthModal.tsx]"]
  node_document_import["PGDAS document import"]
  node_document_parser["Document parsing<br/>[documentImport.ts]"]
  node_data_transfer["JSON data transfer<br/>[dataTransfer.ts]"]
end

subgraph group_desktop["Desktop storage"]
  node_storage_adapter["Storage adapter<br/>[storageAdapter.ts]"]
  node_electron["Electron main process<br/>[main.cjs]"]
  node_sqlite[("Local SQLite database<br/>[main.cjs]")]
end

subgraph group_updates["Tax table updates"]
  node_remote_tables["Remote table updates<br/>[remoteTables.ts]"]
end

node_user(("Business owner"))
node_github["GitHub tables"]

node_user -->|"uses"| node_app
node_app -.->|"offers onboarding"| node_welcome
node_app -->|"renders"| node_month
node_app -.->|"offers"| node_comparison
node_app -.->|"offers"| node_history
node_app -->|"renders"| node_settings
node_app -->|"renders"| node_document_import
node_app -->|"generates sample data"| node_engine
node_month -->|"calculates"| node_engine
node_add_month -->|"calculates"| node_engine
node_engine -->|"uses types"| node_tax_types
node_engine -->|"reads tables"| node_tables
node_document_import -.->|"parses documents"| node_document_parser
node_app -->|"loads and saves"| node_storage_adapter
node_storage_adapter -->|"reads and writes"| node_sqlite
node_electron -->|"queries"| node_sqlite
node_app -->|"loads and applies"| node_remote_tables
node_remote_tables -->|"checks for updates"| node_github
node_user -.->|"exports or imports"| node_data_transfer
node_user -->|"prints or saves"| node_report

click node_app "https://github.com/leandrotsampa/fatorsimples/blob/main/src/App.tsx"
click node_welcome "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/Welcome.tsx"
click node_month "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/MonthApurationView.tsx"
click node_comparison "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ComparisonView.tsx"
click node_settings "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/SettingsModal.tsx"
click node_report "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ReportPrintView.tsx"
click node_engine "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/taxCalculations.ts"
click node_tax_types "https://github.com/leandrotsampa/fatorsimples/blob/main/src/types/tax.ts"
click node_tables "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/taxTablesRegistry.ts"
click node_history "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/HistoryTable.tsx"
click node_add_month "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/AddMonthModal.tsx"
click node_document_import "https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ImportDocumentModal.tsx"
click node_document_parser "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/documentImport.ts"
click node_data_transfer "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/dataTransfer.ts"
click node_storage_adapter "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/storageAdapter.ts"
click node_electron "https://github.com/leandrotsampa/fatorsimples/blob/main/electron/main.cjs"
click node_sqlite "https://github.com/leandrotsampa/fatorsimples/blob/main/electron/main.cjs"
click node_remote_tables "https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/remoteTables.ts"

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_welcome,node_month,node_comparison,node_settings,node_report toneBlue
class node_engine,node_tax_types,node_tables toneAmber
class node_history,node_add_month,node_document_import,node_document_parser,node_data_transfer toneMint
class node_storage_adapter,node_electron,node_sqlite toneRose
class node_remote_tables,node_user,node_github toneIndigo
```

## Components

### App experience

- [App coordinator](https://github.com/leandrotsampa/fatorsimples/blob/main/src/App.tsx): `src/App.tsx`
- [Welcome and setup](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/Welcome.tsx): `src/components/Welcome.tsx`
- [Monthly calculation](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/MonthApurationView.tsx): `src/components/MonthApurationView.tsx`
- [Fator R comparison](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ComparisonView.tsx): `src/components/ComparisonView.tsx`
- [Company and tax settings](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/SettingsModal.tsx): `src/components/SettingsModal.tsx`
- [Printable report](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ReportPrintView.tsx): `src/components/ReportPrintView.tsx`

### Tax domain

- [Tax calculations](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/taxCalculations.ts): `src/utils/taxCalculations.ts`
- [Tax domain types](https://github.com/leandrotsampa/fatorsimples/blob/main/src/types/tax.ts): `src/types/tax.ts`
- [Official tax tables](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/taxTablesRegistry.ts): `src/utils/taxTablesRegistry.ts`

### Records and transfer

- [Monthly history](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/HistoryTable.tsx): `src/components/HistoryTable.tsx`
- [Add or edit month](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/AddMonthModal.tsx): `src/components/AddMonthModal.tsx`
- [PGDAS document import](https://github.com/leandrotsampa/fatorsimples/blob/main/src/components/ImportDocumentModal.tsx): `src/components/ImportDocumentModal.tsx`
- [Document parsing](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/documentImport.ts): `src/utils/documentImport.ts`
- [JSON data transfer](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/dataTransfer.ts): `src/utils/dataTransfer.ts`

### Desktop storage

- [Storage adapter](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/storageAdapter.ts): `src/utils/storageAdapter.ts`
- [Electron main process](https://github.com/leandrotsampa/fatorsimples/blob/main/electron/main.cjs): `electron/main.cjs`
- [Local SQLite database](https://github.com/leandrotsampa/fatorsimples/blob/main/electron/main.cjs): `electron/main.cjs`

### Tax table updates

- [Remote table updates](https://github.com/leandrotsampa/fatorsimples/blob/main/src/utils/remoteTables.ts): `src/utils/remoteTables.ts`

### Other components

- **Business owner**
- **GitHub tables**

## Connections

- Business owner → App coordinator: uses (evidence: `README.md`)
- App coordinator → Welcome and setup: offers onboarding (evidence: `src/App.tsx`)
- App coordinator → Monthly calculation: renders (evidence: `src/App.tsx`)
- App coordinator → Fator R comparison: offers (evidence: `src/App.tsx`)
- App coordinator → Monthly history: offers (evidence: `src/App.tsx`)
- App coordinator → Company and tax settings: renders (evidence: `src/App.tsx`)
- App coordinator → PGDAS document import: renders (evidence: `src/App.tsx`)
- App coordinator → Tax calculations: generates sample data (evidence: `src/App.tsx`)
- Monthly calculation → Tax calculations: calculates (evidence: `src/components/MonthApurationView.tsx`)
- Add or edit month → Tax calculations: calculates (evidence: `src/components/AddMonthModal.tsx`)
- Tax calculations → Tax domain types: uses types (evidence: `src/utils/taxCalculations.ts`)
- Tax calculations → Official tax tables: reads tables (evidence: `src/utils/taxCalculations.ts`)
- PGDAS document import → Document parsing: parses documents
- App coordinator → Storage adapter: loads and saves (evidence: `src/App.tsx`)
- Storage adapter → Local SQLite database: reads and writes (evidence: `src/utils/storageAdapter.ts`)
- Electron main process → Local SQLite database: queries (evidence: `electron/main.cjs`)
- App coordinator → Remote table updates: loads and applies (evidence: `src/App.tsx`)
- Remote table updates → GitHub tables: checks for updates (evidence: `README.md`)
- Business owner → JSON data transfer: exports or imports
- Business owner → Printable report: prints or saves (evidence: `README.md`)
