# yaesen-hany/charge_spot architecture

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

- Interactive diagram: https://gitdiagram.com/yaesen-hany/charge_spot
- Repository: https://github.com/yaesen-hany/charge_spot

## Overview

ChargeSpot Egypt is a Streamlit EV-station management platform. Drivers authenticate, find stations and available slots, and book or manage charging sessions; operators manage station slots and congestion, while administrators oversee operators and network performance. Supporting capabilities include validation, fast booking lookup, greedy scheduling, sorting with undo history, telemetry cleaning, analytics, and optional AI assistance. The graph combines sampled source relationships with documented capabilities; some UI workflows and persistence wiring are only described in the README, so those links cite it rather than implying unsampled code was inspected.

Main entry points: [`models/app.py`](https://github.com/yaesen-hany/charge_spot/blob/main/models/app.py) (Streamlit App), [`models/auth.py`](https://github.com/yaesen-hany/charge_spot/blob/main/models/auth.py) (Authentication), [`models/analytics.py`](https://github.com/yaesen-hany/charge_spot/blob/main/models/analytics.py) (Analytics Engine), [`models/models.py`](https://github.com/yaesen-hany/charge_spot/blob/main/models/models.py) (Domain Entities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Application"]
  node_app["Streamlit App<br/>[app.py]"]
  node_copilot["Driver AI Copilot<br/>[app.py]"]
end

subgraph group_domain["Identity and Domain"]
  node_auth["Authentication<br/>[auth.py]"]
  node_entities["Domain Entities<br/>[models.py]"]
  node_errors["Domain Errors<br/>[exceptions.py]"]
  node_users[("User Accounts<br/>[users.json]")]
end

subgraph group_operations["Booking Operations"]
  node_scheduler["Greedy Scheduler<br/>[scheduler.py]"]
  node_lookup["Booking Lookup<br/>[lookup_engine.py]"]
  node_sorting["Sorting and Undo<br/>[sorting_engine.py]"]
  node_bookings[("Booking Records<br/>[bookings.json]")]
  node_state[("System Snapshot")]
  node_stations[("Stations and Slots<br/>[stations_slots.csv]")]
end

subgraph group_insights["Analytics"]
  node_analytics["Analytics Engine<br/>[analytics.py]"]
  node_telemetry[("Charging Telemetry<br/>[charging_data.csv]")]
end

node_driver(("EV Driver"))
node_operator(("Station Operator"))
node_admin(("System Admin"))
node_gemini["Gemini API"]

node_driver -->|"uses"| node_app
node_operator -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"invokes"| node_auth
node_app -->|"uses"| node_entities
node_app -->|"uses"| node_scheduler
node_app -->|"uses"| node_lookup
node_app -->|"uses"| node_sorting
node_app -->|"uses"| node_analytics
node_app -->|"offers"| node_copilot
node_copilot -.->|"queries"| node_gemini
node_auth -->|"creates"| node_entities
node_auth -->|"reads and writes"| node_users
node_auth -->|"raises"| node_errors
node_entities -->|"raises"| node_errors
node_app -->|"manages"| node_bookings
node_app -->|"manages"| node_stations
node_app -->|"persists state"| node_state
node_lookup -->|"raises"| node_errors
node_analytics -->|"uses"| node_sorting
node_analytics -->|"cleans and analyzes"| node_telemetry

click node_app "https://github.com/yaesen-hany/charge_spot/blob/main/models/app.py"
click node_copilot "https://github.com/yaesen-hany/charge_spot/blob/main/models/app.py"
click node_auth "https://github.com/yaesen-hany/charge_spot/blob/main/models/auth.py"
click node_entities "https://github.com/yaesen-hany/charge_spot/blob/main/models/models.py"
click node_errors "https://github.com/yaesen-hany/charge_spot/blob/main/models/exceptions.py"
click node_users "https://github.com/yaesen-hany/charge_spot/blob/main/data/users.json"
click node_scheduler "https://github.com/yaesen-hany/charge_spot/blob/main/models/scheduler.py"
click node_lookup "https://github.com/yaesen-hany/charge_spot/blob/main/models/lookup_engine.py"
click node_sorting "https://github.com/yaesen-hany/charge_spot/blob/main/models/sorting_engine.py"
click node_bookings "https://github.com/yaesen-hany/charge_spot/blob/main/data/bookings.json"
click node_state "https://github.com/yaesen-hany/charge_spot/blob/main/data/chargespot_state.json"
click node_stations "https://github.com/yaesen-hany/charge_spot/blob/main/data/stations_slots.csv"
click node_analytics "https://github.com/yaesen-hany/charge_spot/blob/main/models/analytics.py"
click node_telemetry "https://github.com/yaesen-hany/charge_spot/blob/main/data/charging_data.csv"

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_copilot toneBlue
class node_auth,node_entities,node_errors,node_users toneAmber
class node_scheduler,node_lookup,node_sorting,node_bookings,node_state,node_stations,node_gemini toneMint
class node_analytics,node_telemetry toneRose
class node_driver,node_operator,node_admin toneIndigo
```

## Components

### Application

- [Streamlit App](https://github.com/yaesen-hany/charge_spot/blob/main/models/app.py): `models/app.py`
- [Driver AI Copilot](https://github.com/yaesen-hany/charge_spot/blob/main/models/app.py): `models/app.py`

### Identity and Domain

- [Authentication](https://github.com/yaesen-hany/charge_spot/blob/main/models/auth.py): `models/auth.py`
- [Domain Entities](https://github.com/yaesen-hany/charge_spot/blob/main/models/models.py): `models/models.py`
- [Domain Errors](https://github.com/yaesen-hany/charge_spot/blob/main/models/exceptions.py): `models/exceptions.py`
- [User Accounts](https://github.com/yaesen-hany/charge_spot/blob/main/data/users.json): `data/users.json`

### Booking Operations

- [Greedy Scheduler](https://github.com/yaesen-hany/charge_spot/blob/main/models/scheduler.py): `models/scheduler.py`
- [Booking Lookup](https://github.com/yaesen-hany/charge_spot/blob/main/models/lookup_engine.py): `models/lookup_engine.py`
- [Sorting and Undo](https://github.com/yaesen-hany/charge_spot/blob/main/models/sorting_engine.py): `models/sorting_engine.py`
- [Booking Records](https://github.com/yaesen-hany/charge_spot/blob/main/data/bookings.json): `data/bookings.json`
- [System Snapshot](https://github.com/yaesen-hany/charge_spot/blob/main/data/chargespot_state.json): `data/chargespot_state.json`
- [Stations and Slots](https://github.com/yaesen-hany/charge_spot/blob/main/data/stations_slots.csv): `data/stations_slots.csv`

### Analytics

- [Analytics Engine](https://github.com/yaesen-hany/charge_spot/blob/main/models/analytics.py): `models/analytics.py`
- [Charging Telemetry](https://github.com/yaesen-hany/charge_spot/blob/main/data/charging_data.csv): `data/charging_data.csv`

### Other components

- **EV Driver**
- **Station Operator**
- **System Admin**
- **Gemini API**

## Connections

- EV Driver → Streamlit App: uses (evidence: `README.md`)
- Station Operator → Streamlit App: uses (evidence: `README.md`)
- System Admin → Streamlit App: uses (evidence: `README.md`)
- Streamlit App → Authentication: invokes (evidence: `models/app.py`)
- Streamlit App → Domain Entities: uses (evidence: `models/app.py`)
- Streamlit App → Greedy Scheduler: uses (evidence: `models/app.py`)
- Streamlit App → Booking Lookup: uses (evidence: `models/app.py`)
- Streamlit App → Sorting and Undo: uses (evidence: `models/app.py`)
- Streamlit App → Analytics Engine: uses (evidence: `models/app.py`)
- Streamlit App → Driver AI Copilot: offers (evidence: `README.md`)
- Driver AI Copilot → Gemini API: queries (evidence: `README.md`)
- Authentication → Domain Entities: creates (evidence: `models/auth.py`)
- Authentication → User Accounts: reads and writes (evidence: `models/auth.py`)
- Authentication → Domain Errors: raises (evidence: `models/auth.py`)
- Domain Entities → Domain Errors: raises (evidence: `models/models.py`)
- Streamlit App → Booking Records: manages (evidence: `README.md`)
- Streamlit App → Stations and Slots: manages (evidence: `README.md`)
- Streamlit App → System Snapshot: persists state (evidence: `README.md`)
- Booking Lookup → Domain Errors: raises (evidence: `models/lookup_engine.py`)
- Analytics Engine → Sorting and Undo: uses (evidence: `models/analytics.py`)
- Analytics Engine → Charging Telemetry: cleans and analyzes (evidence: `README.md`)
