# rhythmgarg13/f1simulationproject architecture

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

- Interactive diagram: https://gitdiagram.com/rhythmgarg13/f1simulationproject
- Repository: https://github.com/rhythmgarg13/f1simulationproject

## Overview

The product is a full-stack F1 race-strategy simulator: users choose a circuit and weather in the dashboard, request a strategy, and view the resulting race, pit, tire, circuit, and telemetry data. The documented backend workflow combines constrained SLSQP strategy optimization with Monte Carlo race outcomes and tire degradation; weather changes trigger re-optimization. The README documents server-side comparative visualizations and all 24 circuits, but the sampled excerpts do not show their precise API wiring, so those links are omitted.

Main entry points: [`frontend/src/components/Dashboard.jsx`](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/Dashboard.jsx) (Dashboard), [`backend/api.py`](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/api.py) (API routes), [`backend/monte_carlo.py`](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/monte_carlo.py) (Monte Carlo engine), [`backend/optimizer.py`](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/optimizer.py) (SLSQP optimizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Race dashboard"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_circuitview["Circuit map<br/>[CircuitMap.jsx]"]
  node_lapchart["Lap-time chart<br/>[LapTimeChart.jsx]"]
  node_pitview["Pit strategy<br/>[PitStrategy.jsx]"]
  node_tireview["Tire strategy<br/>[TireStrategy.jsx]"]
  node_telemetry["Telemetry<br/>[TelemetryCard.jsx]"]
  node_stats["Race overview<br/>[StatsRow.jsx]"]
  node_api_client["Strategy API client<br/>[strategyApi.js]"]
end

subgraph group_api["API and orchestration"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_routes["API routes<br/>[api.py]"]
end

subgraph group_simulation["Strategy simulation"]
  node_weather["Weather logic<br/>[weather.py]"]
  node_optimizer["SLSQP optimizer<br/>[optimizer.py]"]
  node_monte_carlo["Monte Carlo engine<br/>[monte_carlo.py]"]
  node_visualizations["Race visualizations<br/>[visualizations.py]"]
end

subgraph group_data["Race inputs and outputs"]
  node_track_paths["Circuit SVG paths<br/>[trackPaths.js]"]
  node_models["Domain models<br/>[models.py]"]
  node_tracks["Circuit definitions<br/>[track_data.py]"]
end

node_user(("Race strategist"))

node_user -->|"chooses race inputs"| node_dashboard
node_dashboard -->|"requests strategy"| node_api_client
node_dashboard -->|"changes weather"| node_api_client
node_api_client -->|"sends API requests"| node_routes
node_fastapi -->|"mounts router"| node_routes
node_fastapi -->|"warms degradation cache"| node_monte_carlo
node_routes -->|"requests optimization"| node_optimizer
node_routes -->|"requests simulations"| node_monte_carlo
node_routes -->|"reads circuit data"| node_tracks
node_routes -->|"requests weather update"| node_weather
node_optimizer -->|"evaluates strategies"| node_monte_carlo
node_optimizer -->|"uses domain types"| node_models
node_monte_carlo -->|"uses race types"| node_models
node_tracks -->|"defines circuit records"| node_models
node_routes -->|"returns strategy data"| node_dashboard
node_dashboard -->|"renders circuit data"| node_circuitview
node_dashboard -->|"renders lap data"| node_lapchart
node_dashboard -->|"renders pit plan"| node_pitview
node_dashboard -->|"renders compounds"| node_tireview
node_dashboard -->|"renders metrics"| node_telemetry
node_dashboard -->|"renders race summary"| node_stats
node_circuitview -->|"reads track paths"| node_track_paths

click node_dashboard "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/Dashboard.jsx"
click node_circuitview "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/CircuitMap.jsx"
click node_lapchart "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/LapTimeChart.jsx"
click node_pitview "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/PitStrategy.jsx"
click node_tireview "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/TireStrategy.jsx"
click node_telemetry "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/TelemetryCard.jsx"
click node_stats "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/StatsRow.jsx"
click node_api_client "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/api/strategyApi.js"
click node_track_paths "https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/data/trackPaths.js"
click node_fastapi "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/main.py"
click node_routes "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/api.py"
click node_models "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/models.py"
click node_tracks "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/track_data.py"
click node_weather "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/weather.py"
click node_optimizer "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/optimizer.py"
click node_monte_carlo "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/monte_carlo.py"
click node_visualizations "https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/visualizations.py"

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_dashboard,node_circuitview,node_lapchart,node_pitview,node_tireview,node_telemetry,node_stats,node_api_client toneBlue
class node_fastapi,node_routes toneAmber
class node_weather,node_optimizer,node_monte_carlo,node_visualizations toneMint
class node_track_paths,node_models,node_tracks toneRose
class node_user toneIndigo
```

## Components

### Race dashboard

- [Dashboard](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/Dashboard.jsx): `frontend/src/components/Dashboard.jsx`
- [Circuit map](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/CircuitMap.jsx): `frontend/src/components/CircuitMap.jsx`
- [Lap-time chart](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/LapTimeChart.jsx): `frontend/src/components/LapTimeChart.jsx`
- [Pit strategy](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/PitStrategy.jsx): `frontend/src/components/PitStrategy.jsx`
- [Tire strategy](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/TireStrategy.jsx): `frontend/src/components/TireStrategy.jsx`
- [Telemetry](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/TelemetryCard.jsx): `frontend/src/components/TelemetryCard.jsx`
- [Race overview](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/components/StatsRow.jsx): `frontend/src/components/StatsRow.jsx`
- [Strategy API client](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/api/strategyApi.js): `frontend/src/api/strategyApi.js`

### API and orchestration

- [FastAPI app](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/main.py): `backend/main.py`
- [API routes](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/api.py): `backend/api.py`

### Strategy simulation

- [Weather logic](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/weather.py): `backend/weather.py`
- [SLSQP optimizer](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/optimizer.py): `backend/optimizer.py`
- [Monte Carlo engine](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/monte_carlo.py): `backend/monte_carlo.py`
- [Race visualizations](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/visualizations.py): `backend/visualizations.py`

### Race inputs and outputs

- [Circuit SVG paths](https://github.com/rhythmgarg13/f1simulationproject/blob/main/frontend/src/data/trackPaths.js): `frontend/src/data/trackPaths.js`
- [Domain models](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/models.py): `backend/models.py`
- [Circuit definitions](https://github.com/rhythmgarg13/f1simulationproject/blob/main/backend/track_data.py): `backend/track_data.py`

### Other components

- **Race strategist**

## Connections

- Race strategist → Dashboard: chooses race inputs
- Dashboard → Strategy API client: requests strategy
- Dashboard → Strategy API client: changes weather
- Strategy API client → API routes: sends API requests
- FastAPI app → API routes: mounts router
- FastAPI app → Monte Carlo engine: warms degradation cache
- API routes → SLSQP optimizer: requests optimization
- API routes → Monte Carlo engine: requests simulations
- API routes → Circuit definitions: reads circuit data
- API routes → Weather logic: requests weather update
- SLSQP optimizer → Monte Carlo engine: evaluates strategies
- SLSQP optimizer → Domain models: uses domain types
- Monte Carlo engine → Domain models: uses race types
- Circuit definitions → Domain models: defines circuit records
- API routes → Dashboard: returns strategy data
- Dashboard → Circuit map: renders circuit data
- Dashboard → Lap-time chart: renders lap data
- Dashboard → Pit strategy: renders pit plan
- Dashboard → Tire strategy: renders compounds
- Dashboard → Telemetry: renders metrics
- Dashboard → Race overview: renders race summary
- Circuit map → Circuit SVG paths: reads track paths
