# kirancg/fullstack_calculator architecture

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

- Interactive diagram: https://gitdiagram.com/kirancg/fullstack_calculator
- Repository: https://github.com/kirancg/fullstack_calculator

## Overview

This MERN calculator lets a user enter an arithmetic expression, evaluate it in the browser, and save the expression and result. A history view fetches and displays the ten most recent saved calculations. The server parses requests and mounts the calculation API; its routes validate and persist records through the Mongoose model, while startup connects to MongoDB. The graph follows the sampled client and server code and the README’s API/schema description; it does not infer additional calculation or authentication services.

Main entry points: [`routes/calculation.routes.js`](https://github.com/kirancg/fullstack_calculator/blob/master/routes/calculation.routes.js) (Calculation routes), [`client/src/App.js`](https://github.com/kirancg/fullstack_calculator/blob/master/client/src/App.js) (Calculator app), [`server.js`](https://github.com/kirancg/fullstack_calculator/blob/master/server.js) (Express server), [`client/src/components/Button.js`](https://github.com/kirancg/fullstack_calculator/blob/master/client/src/components/Button.js) (Calculator controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Calculator client"]
  node_app["Calculator app<br/>[App.js]"]
  node_calculator["Calculator controls<br/>[Button.js]"]
  node_history["History list<br/>[List.js]"]
end

subgraph group_api["Calculation API"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Calculation routes"]
end

subgraph group_persistence["Persistence"]
  node_database_connection["Database connection<br/>[db.js]"]
  node_calculation_model["Calculation model<br/>[Calculation.js]"]
  node_mongodb[("MongoDB")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_calculator
node_app -->|"renders"| node_history
node_calculator -->|"posts calculation"| node_routes
node_history -->|"fetches history"| node_routes
node_server -->|"mounts at /api"| node_routes
node_server -->|"connects on startup"| node_database_connection
node_routes -->|"saves and queries"| node_calculation_model
node_database_connection -->|"connects"| node_mongodb

click node_app "https://github.com/kirancg/fullstack_calculator/blob/master/client/src/App.js"
click node_calculator "https://github.com/kirancg/fullstack_calculator/blob/master/client/src/components/Button.js"
click node_history "https://github.com/kirancg/fullstack_calculator/blob/master/client/src/components/List.js"
click node_server "https://github.com/kirancg/fullstack_calculator/blob/master/server.js"
click node_routes "https://github.com/kirancg/fullstack_calculator/blob/master/routes/calculation.routes.js"
click node_database_connection "https://github.com/kirancg/fullstack_calculator/blob/master/config/db.js"
click node_calculation_model "https://github.com/kirancg/fullstack_calculator/blob/master/model/Calculation.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_calculator,node_history,node_user toneBlue
class node_server,node_routes toneAmber
class node_database_connection,node_calculation_model,node_mongodb toneMint
```

## Components

### Calculator client

- [Calculator app](https://github.com/kirancg/fullstack_calculator/blob/master/client/src/App.js): `client/src/App.js`
- [Calculator controls](https://github.com/kirancg/fullstack_calculator/blob/master/client/src/components/Button.js): `client/src/components/Button.js`
- [History list](https://github.com/kirancg/fullstack_calculator/blob/master/client/src/components/List.js): `client/src/components/List.js`

### Calculation API

- [Express server](https://github.com/kirancg/fullstack_calculator/blob/master/server.js): `server.js`
- [Calculation routes](https://github.com/kirancg/fullstack_calculator/blob/master/routes/calculation.routes.js): `routes/calculation.routes.js`

### Persistence

- [Database connection](https://github.com/kirancg/fullstack_calculator/blob/master/config/db.js): `config/db.js`
- [Calculation model](https://github.com/kirancg/fullstack_calculator/blob/master/model/Calculation.js): `model/Calculation.js`
- **MongoDB**

### Other components

- **User**

## Connections

- User → Calculator app: uses (evidence: `client/src/App.js`)
- Calculator app → Calculator controls: renders (evidence: `client/src/App.js`)
- Calculator app → History list: renders (evidence: `client/src/App.js`)
- Calculator controls → Calculation routes: posts calculation (evidence: `client/src/components/Button.js`)
- History list → Calculation routes: fetches history (evidence: `client/src/components/List.js`)
- Express server → Calculation routes: mounts at /api (evidence: `server.js`)
- Express server → Database connection: connects on startup (evidence: `server.js`)
- Calculation routes → Calculation model: saves and queries (evidence: `routes/calculation.routes.js`)
- Database connection → MongoDB: connects (evidence: `config/db.js`)
