# cs-truong/caculator_ga architecture

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

- Interactive diagram: https://gitdiagram.com/cs-truong/caculator_ga
- Repository: https://github.com/cs-truong/caculator_ga

## Overview

This is a React handheld-calculator simulator. A user presses keypad controls; the keypad dispatches input through shared calculator state, the adapter applies state transitions and invokes arithmetic operations in the engine, and the display renders the formatted result. The same state layer maintains calculation history, while the interface exposes history and service metadata panels. The graph follows the supplied excerpts and README; unsampled styling details and undocumented runtime connections are omitted.

Main entry points: [`src/context/CalculatorContext.jsx`](https://github.com/cs-truong/caculator_ga/blob/main/src/context/CalculatorContext.jsx) (Calculator state and history), [`src/components/CalculatorApp.jsx`](https://github.com/cs-truong/caculator_ga/blob/main/src/components/CalculatorApp.jsx) (Calculator panels), [`src/App.jsx`](https://github.com/cs-truong/caculator_ga/blob/main/src/App.jsx) (App provider wrapper), [`src/components/Keypad.jsx`](https://github.com/cs-truong/caculator_ga/blob/main/src/components/Keypad.jsx) (Input keypad)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_mount["React mount<br/>[main.jsx]"]
  node_app["App provider wrapper<br/>[App.jsx]"]
  node_styles["Interface styles<br/>[index.css]"]
end

subgraph group_interface["Calculator interface"]
  node_calculator["Calculator panels<br/>[CalculatorApp.jsx]"]
  node_keypad["Input keypad<br/>[Keypad.jsx]"]
  node_display["Result display<br/>[Display.jsx]"]
end

subgraph group_logic["Calculation logic"]
  node_state["Calculator state and history"]
  node_adapter["Input adapter"]
  node_engine["Calculation engine<br/>[engine.js]"]
end

node_user(("Calculator user"))

node_mount -->|"renders"| node_app
node_mount -->|"loads styles"| node_styles
node_app -->|"provides state"| node_state
node_app -->|"renders"| node_calculator
node_calculator -->|"reads panel data"| node_state
node_calculator -->|"renders"| node_display
node_calculator -->|"renders"| node_keypad
node_user -.->|"presses controls"| node_keypad
node_keypad -->|"dispatches input"| node_state
node_display -->|"reads display data"| node_state
node_state -->|"processes input"| node_adapter
node_state -->|"gets service info"| node_adapter
node_state -->|"formats display"| node_engine
node_adapter -->|"calculates operations"| node_engine

click node_mount "https://github.com/cs-truong/caculator_ga/blob/main/src/main.jsx"
click node_app "https://github.com/cs-truong/caculator_ga/blob/main/src/App.jsx"
click node_styles "https://github.com/cs-truong/caculator_ga/blob/main/src/index.css"
click node_calculator "https://github.com/cs-truong/caculator_ga/blob/main/src/components/CalculatorApp.jsx"
click node_keypad "https://github.com/cs-truong/caculator_ga/blob/main/src/components/Keypad.jsx"
click node_display "https://github.com/cs-truong/caculator_ga/blob/main/src/components/Display.jsx"
click node_state "https://github.com/cs-truong/caculator_ga/blob/main/src/context/CalculatorContext.jsx"
click node_adapter "https://github.com/cs-truong/caculator_ga/blob/main/src/logic/calculatorAdapter.js"
click node_engine "https://github.com/cs-truong/caculator_ga/blob/main/src/logic/engine.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_mount,node_app,node_styles,node_user toneBlue
class node_calculator,node_keypad,node_display toneAmber
class node_state,node_adapter,node_engine toneMint
```

## Components

### Application entry

- [React mount](https://github.com/cs-truong/caculator_ga/blob/main/src/main.jsx): `src/main.jsx`
- [App provider wrapper](https://github.com/cs-truong/caculator_ga/blob/main/src/App.jsx): `src/App.jsx`
- [Interface styles](https://github.com/cs-truong/caculator_ga/blob/main/src/index.css): `src/index.css`

### Calculator interface

- [Calculator panels](https://github.com/cs-truong/caculator_ga/blob/main/src/components/CalculatorApp.jsx): `src/components/CalculatorApp.jsx`
- [Input keypad](https://github.com/cs-truong/caculator_ga/blob/main/src/components/Keypad.jsx): `src/components/Keypad.jsx`
- [Result display](https://github.com/cs-truong/caculator_ga/blob/main/src/components/Display.jsx): `src/components/Display.jsx`

### Calculation logic

- [Calculator state and history](https://github.com/cs-truong/caculator_ga/blob/main/src/context/CalculatorContext.jsx): `src/context/CalculatorContext.jsx`
- [Input adapter](https://github.com/cs-truong/caculator_ga/blob/main/src/logic/calculatorAdapter.js): `src/logic/calculatorAdapter.js`
- [Calculation engine](https://github.com/cs-truong/caculator_ga/blob/main/src/logic/engine.js): `src/logic/engine.js`

### Other components

- **Calculator user**

## Connections

- React mount → App provider wrapper: renders (evidence: `src/main.jsx`)
- React mount → Interface styles: loads styles (evidence: `src/main.jsx`)
- App provider wrapper → Calculator state and history: provides state (evidence: `src/App.jsx`)
- App provider wrapper → Calculator panels: renders (evidence: `src/App.jsx`)
- Calculator panels → Calculator state and history: reads panel data (evidence: `src/components/CalculatorApp.jsx`)
- Calculator panels → Result display: renders (evidence: `src/components/CalculatorApp.jsx`)
- Calculator panels → Input keypad: renders (evidence: `src/components/CalculatorApp.jsx`)
- Calculator user → Input keypad: presses controls
- Input keypad → Calculator state and history: dispatches input (evidence: `src/components/Keypad.jsx`)
- Result display → Calculator state and history: reads display data (evidence: `src/components/Display.jsx`)
- Calculator state and history → Input adapter: processes input (evidence: `src/context/CalculatorContext.jsx`)
- Calculator state and history → Input adapter: gets service info (evidence: `src/context/CalculatorContext.jsx`)
- Calculator state and history → Calculation engine: formats display (evidence: `src/context/CalculatorContext.jsx`)
- Input adapter → Calculation engine: calculates operations (evidence: `src/logic/calculatorAdapter.js`)
