# thabadcode/propostacomerciav2 architecture

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

- Interactive diagram: https://gitdiagram.com/thabadcode/propostacomerciav2
- Repository: https://github.com/thabadcode/propostacomerciav2

## Overview

Proposta Comercial V2 is a static React application for preparing asphalt-supply and related-services proposals. The user enters customer and proposal details, adds and manages priced products, reviews the formatted A4 proposal, then prints it or saves it as PDF. Separate supporting capabilities include CNPJ lookup, browser draft recovery, and JSON import/export. The graph follows the sampled App orchestration and documented product features; some supporting modules were not excerpted, so uncertain links are omitted or marked unverified.

Main entry points: [`src/App.tsx`](https://github.com/thabadcode/propostacomerciav2/blob/main/src/App.tsx) (Application orchestration), [`src/components/Preview/Preview.tsx`](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Preview/Preview.tsx) (A4 proposal preview), [`src/core/hooks/useMainForm.ts`](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useMainForm.ts) (Proposal form state), [`src/components/Forms/MainForm.tsx`](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Forms/MainForm.tsx) (Proposal details form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Proposal authoring"]
  node_app["Application orchestration<br/>[App.tsx]"]
  node_mainformui["Proposal details form<br/>[MainForm.tsx]"]
  node_productformui["Product editor<br/>[ProductForm.tsx]"]
  node_header["Header actions<br/>[Header.tsx]"]
  node_productlist["Responsive product list<br/>[ProductCard.tsx]"]
  node_table["Product table<br/>[Table.tsx]"]
end

subgraph group_domain["Form and product state"]
  node_mainstate["Proposal form state<br/>[useMainForm.ts]"]
  node_fieldstate["Validated form fields<br/>[useFormField.ts]"]
  node_productstate["Product form state<br/>[useProductForm.ts]"]
  node_products["Product collection and totals<br/>[useProducts.ts]"]
  node_rules["Business validation rules<br/>[rules.ts]"]
  node_formoptions["Form options<br/>[formOptions.ts]"]
  node_formatter["Proposal formatting<br/>[formatter.ts]"]
end

subgraph group_output["Proposal output"]
  node_preview["A4 proposal preview<br/>[Preview.tsx]"]
  node_panzoom["Preview pan and zoom<br/>[usePanZoom.ts]"]
  node_print["Browser print dialog"]
  node_provider["Supplier information<br/>[providerInfo.ts]"]
end

subgraph group_persistence["Drafts and integrations"]
  node_snapshot["Snapshot validation and storage<br/>[snapshot.ts]"]
  node_autosave["Debounced draft saving<br/>[useAutoSave.ts]"]
  node_localstorage[("Browser localStorage")]
  node_json["JSON import and export<br/>[exportImport.ts]"]
  node_cnpj["CNPJ lookup<br/>[searchCnpj.ts]"]
  node_brasilapi["BrasilAPI"]
  node_serviceworker["PWA service worker<br/>[sw.js]"]
end

node_user(("Proposal author"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_mainformui
node_app -->|"renders"| node_productformui
node_app -->|"renders"| node_header
node_app -->|"initializes"| node_mainstate
node_app -->|"initializes"| node_productstate
node_app -->|"initializes"| node_products
node_mainformui -->|"edits"| node_mainstate
node_productformui -->|"edits"| node_productstate
node_mainstate -->|"builds fields"| node_fieldstate
node_productstate -->|"builds fields"| node_fieldstate
node_mainstate -->|"validates with"| node_rules
node_productstate -->|"validates with"| node_rules
node_mainformui -->|"uses options"| node_formoptions
node_mainformui -->|"looks up CNPJ"| node_cnpj
node_cnpj -.->|"queries"| node_brasilapi
node_app -->|"renders on desktop"| node_table
node_app -->|"renders on mobile"| node_productlist
node_table -->|"reads and manages"| node_products
node_productlist -->|"reads and manages"| node_products
node_app -->|"renders"| node_preview
node_preview -->|"reads proposal data"| node_mainstate
node_preview -->|"reads product data"| node_products
node_preview -->|"formats display"| node_formatter
node_preview -->|"displays supplier data"| node_provider
node_preview -->|"controls viewport"| node_panzoom
node_app -->|"opens for printing"| node_print
node_app -->|"loads draft"| node_snapshot
node_app -->|"starts autosave"| node_autosave
node_autosave -->|"saves snapshot"| node_snapshot
node_snapshot -->|"reads and writes"| node_localstorage
node_header -->|"triggers actions"| node_app
node_app -->|"handles JSON actions"| node_json
node_json -->|"validates snapshot"| node_snapshot
node_app -.->|"enables PWA"| node_serviceworker

click node_app "https://github.com/thabadcode/propostacomerciav2/blob/main/src/App.tsx"
click node_mainformui "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Forms/MainForm.tsx"
click node_productformui "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Forms/ProductForm.tsx"
click node_header "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Header/Header.tsx"
click node_mainstate "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useMainForm.ts"
click node_fieldstate "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useFormField.ts"
click node_productstate "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useProductForm.ts"
click node_products "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useProducts.ts"
click node_rules "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/rules.ts"
click node_formoptions "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/constants/formOptions.ts"
click node_formatter "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/formatter.ts"
click node_productlist "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/ProductCard/ProductCard.tsx"
click node_table "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/ui/Table/Table.tsx"
click node_preview "https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Preview/Preview.tsx"
click node_panzoom "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/usePanZoom.ts"
click node_snapshot "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/snapshot.ts"
click node_autosave "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useAutoSave.ts"
click node_json "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/exportImport.ts"
click node_cnpj "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/searchCnpj.ts"
click node_provider "https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/constants/providerInfo.ts"
click node_serviceworker "https://github.com/thabadcode/propostacomerciav2/blob/main/public/sw.js"

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_mainformui,node_productformui,node_header,node_productlist,node_table toneBlue
class node_mainstate,node_fieldstate,node_productstate,node_products,node_rules,node_formoptions,node_formatter toneAmber
class node_preview,node_panzoom,node_print,node_provider toneMint
class node_snapshot,node_autosave,node_localstorage,node_json,node_cnpj,node_brasilapi,node_serviceworker toneRose
class node_user toneIndigo
```

## Components

### Proposal authoring

- [Application orchestration](https://github.com/thabadcode/propostacomerciav2/blob/main/src/App.tsx): `src/App.tsx`
- [Proposal details form](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Forms/MainForm.tsx): `src/components/Forms/MainForm.tsx`
- [Product editor](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Forms/ProductForm.tsx): `src/components/Forms/ProductForm.tsx`
- [Header actions](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Header/Header.tsx): `src/components/Header/Header.tsx`
- [Responsive product list](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/ProductCard/ProductCard.tsx): `src/components/ProductCard/ProductCard.tsx`
- [Product table](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/ui/Table/Table.tsx): `src/components/ui/Table/Table.tsx`

### Form and product state

- [Proposal form state](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useMainForm.ts): `src/core/hooks/useMainForm.ts`
- [Validated form fields](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useFormField.ts): `src/core/hooks/useFormField.ts`
- [Product form state](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useProductForm.ts): `src/core/hooks/useProductForm.ts`
- [Product collection and totals](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useProducts.ts): `src/core/hooks/useProducts.ts`
- [Business validation rules](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/rules.ts): `src/core/utils/rules.ts`
- [Form options](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/constants/formOptions.ts): `src/core/constants/formOptions.ts`
- [Proposal formatting](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/formatter.ts): `src/core/utils/formatter.ts`

### Proposal output

- [A4 proposal preview](https://github.com/thabadcode/propostacomerciav2/blob/main/src/components/Preview/Preview.tsx): `src/components/Preview/Preview.tsx`
- [Preview pan and zoom](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/usePanZoom.ts): `src/core/hooks/usePanZoom.ts`
- **Browser print dialog**
- [Supplier information](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/constants/providerInfo.ts): `src/core/constants/providerInfo.ts`

### Drafts and integrations

- [Snapshot validation and storage](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/snapshot.ts): `src/core/utils/snapshot.ts`
- [Debounced draft saving](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/hooks/useAutoSave.ts): `src/core/hooks/useAutoSave.ts`
- **Browser localStorage**
- [JSON import and export](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/exportImport.ts): `src/core/utils/exportImport.ts`
- [CNPJ lookup](https://github.com/thabadcode/propostacomerciav2/blob/main/src/core/utils/searchCnpj.ts): `src/core/utils/searchCnpj.ts`
- **BrasilAPI**
- [PWA service worker](https://github.com/thabadcode/propostacomerciav2/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Proposal author**

## Connections

- Proposal author → Application orchestration: uses (evidence: `README.md`)
- Application orchestration → Proposal details form: renders (evidence: `src/App.tsx`)
- Application orchestration → Product editor: renders (evidence: `src/App.tsx`)
- Application orchestration → Header actions: renders (evidence: `src/App.tsx`)
- Application orchestration → Proposal form state: initializes (evidence: `src/App.tsx`)
- Application orchestration → Product form state: initializes (evidence: `src/App.tsx`)
- Application orchestration → Product collection and totals: initializes (evidence: `src/App.tsx`)
- Proposal details form → Proposal form state: edits (evidence: `src/components/Forms/MainForm.tsx`)
- Product editor → Product form state: edits (evidence: `src/components/Forms/ProductForm.tsx`)
- Proposal form state → Validated form fields: builds fields (evidence: `src/core/hooks/useMainForm.ts`)
- Product form state → Validated form fields: builds fields (evidence: `src/core/hooks/useProductForm.ts`)
- Proposal form state → Business validation rules: validates with (evidence: `src/core/hooks/useMainForm.ts`)
- Product form state → Business validation rules: validates with (evidence: `src/core/hooks/useProductForm.ts`)
- Proposal details form → Form options: uses options (evidence: `src/components/Forms/MainForm.tsx`)
- Proposal details form → CNPJ lookup: looks up CNPJ (evidence: `src/components/Forms/MainForm.tsx`)
- CNPJ lookup → BrasilAPI: queries (evidence: `src/core/utils/searchCnpj.ts`)
- Application orchestration → Product table: renders on desktop (evidence: `src/App.tsx`)
- Application orchestration → Responsive product list: renders on mobile (evidence: `src/App.tsx`)
- Product table → Product collection and totals: reads and manages (evidence: `src/components/ui/Table/Table.tsx`)
- Responsive product list → Product collection and totals: reads and manages (evidence: `src/components/ProductCard/ProductCard.tsx`)
- Application orchestration → A4 proposal preview: renders (evidence: `src/App.tsx`)
- A4 proposal preview → Proposal form state: reads proposal data (evidence: `src/components/Preview/Preview.tsx`)
- A4 proposal preview → Product collection and totals: reads product data (evidence: `src/components/Preview/Preview.tsx`)
- A4 proposal preview → Proposal formatting: formats display (evidence: `src/components/Preview/Preview.tsx`)
- A4 proposal preview → Supplier information: displays supplier data (evidence: `src/components/Preview/Preview.tsx`)
- A4 proposal preview → Preview pan and zoom: controls viewport (evidence: `src/components/Preview/Preview.tsx`)
- Application orchestration → Browser print dialog: opens for printing (evidence: `src/App.tsx`)
- Application orchestration → Snapshot validation and storage: loads draft (evidence: `src/App.tsx`)
- Application orchestration → Debounced draft saving: starts autosave (evidence: `src/App.tsx`)
- Debounced draft saving → Snapshot validation and storage: saves snapshot (evidence: `src/core/hooks/useAutoSave.ts`)
- Snapshot validation and storage → Browser localStorage: reads and writes (evidence: `src/core/utils/snapshot.ts`)
- Header actions → Application orchestration: triggers actions (evidence: `src/App.tsx`)
- Application orchestration → JSON import and export: handles JSON actions (evidence: `src/App.tsx`)
- JSON import and export → Snapshot validation and storage: validates snapshot (evidence: `src/core/utils/exportImport.ts`)
- Application orchestration → PWA service worker: enables PWA (evidence: `README.md`)
