# ydnarf/calculator architecture

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

- Interactive diagram: https://gitdiagram.com/ydnarf/calculator
- Repository: https://github.com/ydnarf/calculator

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React that exposes a simple calculator UI in the browser.
- Purpose: allow users to perform basic arithmetic operations (addition, subtraction, multiplication, division) with an intuitive, responsive interface.

##### File structure
- Top level:
- index.html – entry point served to the browser
- src/ – all React source code
– App.jsx – root component
– componentes/ – reusable UI components (Boton, BotonClear, Pantalla)
– styles/ – per‐component CSS files
– main.jsx – ReactDOM.render (mount app)
- public/ – static public assets
- config files: package.json, vite.config.js, eslint.config.js

##### Key insights from the README
- Uses React with useState for state management
- Fully responsive design
- Deploys as a static site (e.g., Netlify link provided)
- No backend or external services

##### Main components and interactions
a. Components
1. Browser UI
2. Static hosting/CDN (Netlify or similar)
3. React bundle (JS/CSS)
4. React root component (App)
5. Child components:
– Pantalla: displays input and result
– Boton: digit/operator button
– BotonClear: clear button
6. State store (React useState inside App)

b. Relationships / data flow
- User clicks Boton ⇒ onClick handler passed from App ⇒ App updates state
- State flows down via props to Pantalla for rendering
- BotonClear click resets App state
- App → re‐renders children with new state

c. Architectural patterns / design principles
- Component‐based architecture (separation of concerns)
- Unidirectional data flow (parent manages state, children emit events)
- CSS modularity: each component has its own stylesheet

d. Technologies / frameworks
- React (JSX, useState hook)
- Vite (build & dev server)
- HTML5 / CSS3
- Netlify (static hosting/CDN)

##### Detailed callouts
- Hook usage (useState) inside App
- Call out “Vite Dev Server / Build” step for local development
- “Netlify CDN” as the deployment target

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Build Pipeline"
    direction TB
    S1["src/main.jsx"]:::code
    S2["src/App.jsx"]:::code
    Cpt1["src/componentes/Boton.jsx"]:::code
    Cpt2["src/componentes/BotonClear.jsx"]:::code
    Cpt3["src/componentes/Pantalla.jsx"]:::code
    CSS1["src/styles/Boton.css"]:::code
    CSS2["src/styles/BotonClear.css"]:::code
    CSS3["src/styles/Pantalla.css"]:::code
    CSS4["src/App.css"]:::code
    CSS5["src/index.css"]:::code
    Assets["src/assets"]:::code
    Public["public/"]:::infra
    Config1["package.json"]:::code
    Config2["vite.config.js"]:::code
    Config3["eslint.config.js"]:::code
    Lock["package-lock.json"]:::code
    Vite["Vite (Dev Server / Build)"]:::infra
    Bundle["Production Bundle (JS/CSS)"]:::infra
    S1 & S2 & Cpt1 & Cpt2 & Cpt3 & CSS1 & CSS2 & CSS3 & CSS4 & CSS5 & Assets & Public & Config1 & Config2 & Config3 & Lock --> Vite
    Vite --> Bundle
  end

  subgraph "Static Hosting / CDN"
    direction TB
    CDN["Netlify CDN"]:::infra
  end

  Bundle -->|"deploy"| CDN

  subgraph "Browser"
    direction TB
    HTML["index.html"]:::infra
    BrowserApp["React Application"]:::ui
    HTML -->|"loads bundle"| BundleFetch["fetch bundle"]:::infra
    BundleFetch --> BrowserApp
    subgraph "App Container"
      direction TB
      AppComp["App.jsx\n(useState hook)"]:::ui
      Pantalla["Pantalla.jsx"]:::ui
      Boton["Boton.jsx"]:::ui
      BotonClear["BotonClear.jsx"]:::ui
      State["useState Store"]:::ui
      Boton -->|"click"| State
      BotonClear -->|"click"| State
      State -->|"state props"| Pantalla
      State -->|"triggers re-render"| AppComp
      BrowserApp --> AppComp
    end
  end

  User["User"]:::external
  User -->|"interacts"| BrowserApp

  click S1 "https://github.com/ydnarf/calculator/blob/main/src/main.jsx"
  click S2 "https://github.com/ydnarf/calculator/blob/main/src/App.jsx"
  click Cpt1 "https://github.com/ydnarf/calculator/blob/main/src/componentes/Boton.jsx"
  click Cpt2 "https://github.com/ydnarf/calculator/blob/main/src/componentes/BotonClear.jsx"
  click Cpt3 "https://github.com/ydnarf/calculator/blob/main/src/componentes/Pantalla.jsx"
  click CSS1 "https://github.com/ydnarf/calculator/blob/main/src/styles/Boton.css"
  click CSS2 "https://github.com/ydnarf/calculator/blob/main/src/styles/BotonClear.css"
  click CSS3 "https://github.com/ydnarf/calculator/blob/main/src/styles/Pantalla.css"
  click CSS4 "https://github.com/ydnarf/calculator/blob/main/src/App.css"
  click CSS5 "https://github.com/ydnarf/calculator/blob/main/src/index.css"
  click Assets "https://github.com/ydnarf/calculator/tree/main/src/assets"
  click Public "https://github.com/ydnarf/calculator/tree/main/public/"
  click HTML "https://github.com/ydnarf/calculator/blob/main/index.html"
  click Config1 "https://github.com/ydnarf/calculator/blob/main/package.json"
  click Config2 "https://github.com/ydnarf/calculator/blob/main/vite.config.js"
  click Config3 "https://github.com/ydnarf/calculator/blob/main/eslint.config.js"
  click Lock "https://github.com/ydnarf/calculator/blob/main/package-lock.json"

  classDef ui fill:#E0F7FA,stroke:#0288D1,stroke-width:1px
  classDef infra fill:#ECEFF1,stroke:#90A4AE,stroke-width:1px
  classDef code fill:#FFF8E1,stroke:#F9A825,stroke-width:1px
  classDef external fill:#FFECB3,stroke:#FFA000,stroke-width:1px
```
