How johnysantos22/meu-orcamento works
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