# johnysantos22/meu-orcamento architecture

> Architecture diagram of the GitHub repository johnysantos22/meu-orcamento, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/johnysantos22/meu-orcamento
- Repository: https://github.com/johnysantos22/meu-orcamento

## Overview

##### Project Type and Purpose
- This is a front-end single-page application (SPA) built with React and Vite.
- Its purpose is to generate camera-installation quotes: collect user input via a form, compute a price, render a PDF, and send it via WhatsApp.

##### File Structure Analysis
- Top-level files:
- package.json, package-lock.json – dependency definitions and lockfile
- vite.config.js, eslint.config.js – build and lint configurations
- index.html – SPA host page
- “public” folder – static assets that get served as-is
- “src” folder – source code:
- main.jsx – React entry point (renders <App/>)
- App.jsx – root component
- Components/Orcamentos.jsx – form and quote-generation component

##### README Insights
- Uses Vite for fast bundling and HMR (with either Babel or SWC plugin)
- Describes core features: form input, automatic calculation, PDF creation, WhatsApp sharing
- No backend—everything runs client-side

a. Main Components
1. User’s Browser (Client)
2. SPA Host (index.html + bundled JS/CSS)
3. React App
– App.jsx (shell)
– Orcamentos.jsx (form, state management, calculation logic)
– PDF Generation Module (e.g., jsPDF or pdf-lib)
– WhatsApp Integration Module (Web share link or API)
4. Build Toolchain (Vite + plugins + Node/NPM)
5. Static Asset Server (could be any CDN or hosting provider)
6. External Service: WhatsApp Web / WhatsApp API endpoint

b. Relationships & Data Flow
- User → Browser → loads index.html + bundled SPA from static server
- Inside SPA:
– User fills form in Orcamentos → triggers React state updates
– Calculation engine processes selections → outputs price
– User clicks “Generate PDF” → SPA calls PDF module → creates in-memory PDF blob
– User clicks “Send via WhatsApp” → SPA constructs WhatsApp share URL/API request with PDF attachment
- PDF blob is either downloaded client-side or temporarily uploaded (if using a middleman) before launching WhatsApp share

c. Architectural Patterns & Principles
- Component-based UI (React)
- Unidirectional data flow (state in React hooks or context)
- Separation of concerns: Form logic vs. PDF logic vs. external integration
- Build-time vs. runtime separation: Vite handles bundling, dev server, HMR

d. Key Technologies & Libraries
- React (UI)
- Vite (bundler/dev server) + @vitejs/plugin-react or plugin-react-swc
- jsPDF or pdf-lib (PDF generation)
- WhatsApp Web URL schema or official API (sharing)
- ESLint (code quality)

##### Key Points to Capture
- Client-only architecture—everything runs in the browser
- Clear separation of UI (form), business logic (calculation), and side-effects (PDF, WhatsApp)
- Build pipeline vs. runtime flow
- Interaction with third-party WhatsApp service

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build-time Components
    subgraph "Build System"
        direction TB
        VITE["Vite Config"]:::build
        PACKAGE_JSON["package.json"]:::build
        PACKAGE_LOCK["package-lock.json"]:::build
        ESLINT["eslint.config.js"]:::build
    end

    %% Static Hosting
    SERVER["Static Asset Server<br/>(index.html + JS bundle)"]:::runtime

    %% Runtime Client Components
    subgraph "Client-Side SPA"
        direction TB
        BROWSER["User's Browser / Client"]:::runtime
        subgraph "React App"
            direction TB
            ENTRY["React Entry Point<br/>(main.jsx)"]:::runtime
            ROOT["Root App Shell<br/>(App.jsx)"]:::runtime
            FORM["Quote Form & Calculation<br/>(Orcamentos.jsx)"]:::runtime
            PDFMOD["PDF Generation Module"]:::runtime
            WA_MOD["WhatsApp Integration Module"]:::runtime
            ASSETS["UI Assets<br/>(images, styles, icons)"]:::runtime
        end
    end

    %% External Service
    WHATSAPP["External Service:<br/>WhatsApp"]:::external

    %% Legend
    subgraph Legend
        direction LR
        BUILD_LEGEND["Build-time"]:::build
        RUNTIME_LEGEND["Runtime Client"]:::runtime
        EX_LEGEND["External Service"]:::external
    end

    %% Connections
    VITE -->|bundles assets| SERVER
    PACKAGE_JSON -->|defines deps| VITE
    PACKAGE_LOCK -->|locks deps| VITE
    ESLINT -->|ensures quality| ENTRY

    SERVER -->|HTTP GET bundle| BROWSER
    BROWSER -->|loads SPA| ENTRY
    ENTRY -->|renders| ROOT
    ROOT -->|renders form| FORM
    FORM -->|state updates| ROOT
    FORM -->|calculates price| FORM
    ROOT -->|calls| PDFMOD
    ROOT -->|calls| WA_MOD
    ASSETS -->|loaded by| ROOT

    WA_MOD -->|launch share| WHATSAPP

    %% Click Events
    click SERVER "https://github.com/johnysantos22/meu-orcamento/blob/master/index.html"
    click ENTRY "https://github.com/johnysantos22/meu-orcamento/blob/master/src/main.jsx"
    click ROOT "https://github.com/johnysantos22/meu-orcamento/blob/master/src/App.jsx"
    click FORM "https://github.com/johnysantos22/meu-orcamento/blob/master/src/Components/Orcamentos.jsx"
    click ASSETS "https://github.com/johnysantos22/meu-orcamento/tree/master/src/assets/"
    click VITE "https://github.com/johnysantos22/meu-orcamento/blob/master/vite.config.js"
    click PACKAGE_JSON "https://github.com/johnysantos22/meu-orcamento/blob/master/package.json"
    click PACKAGE_LOCK "https://github.com/johnysantos22/meu-orcamento/blob/master/package-lock.json"
    click ESLINT "https://github.com/johnysantos22/meu-orcamento/blob/master/eslint.config.js"

    %% Styles
    classDef build fill:#dddddd,stroke:#333,stroke-width:1px
    classDef runtime fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef external fill:#c8e6c9,stroke:#333,stroke-width:1px
```
