# hitomi-ap/urbanwatt_sql architecture

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

- Interactive diagram: https://gitdiagram.com/hitomi-ap/urbanwatt_sql
- Repository: https://github.com/hitomi-ap/urbanwatt_sql

## Overview

Urbanwatt SQL combines a PostgreSQL charging-network database with a small FastAPI read API. The user-facing workflow is a client requesting station or charger data, the API querying PostgreSQL, and the API returning JSON; the README also documents initializing and administering the database. The domain extends beyond the sampled endpoints to customers, vehicles, charging sessions, payments, incidents, and interventions. Those broader capabilities and the SQL operations are documented, but their implementation details were not sampled, so their relationships are limited to README-supported links.

Main entry points: [`app/main.py`](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/main.py) (FastAPI routes), [`app/database.py`](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/database.py) (PostgreSQL connection), [`sql/Procédure d'imports.md`](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/Proc%C3%A9dure%20d'imports.md) (Data imports), [`sql/01_schema.sql`](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql) (Stations and chargers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API access"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_db_conn["PostgreSQL connection<br/>[database.py]"]
  node_web_assets["Web assets<br/>[index.html]"]
end

subgraph group_domain["Charging domain"]
  node_stations_chargers["Stations and chargers<br/>[01_schema.sql]"]
  node_customers_sessions["Customers and sessions<br/>[01_schema.sql]"]
  node_payments_incidents["Payments and incidents<br/>[01_schema.sql]"]
  node_interventions["Interventions<br/>[01_schema.sql]"]
end

subgraph group_operations["SQL operations"]
  node_sql_checks["Data verification"]
  node_sql_queries["SQL queries<br/>[03_requetes.sql]"]
  node_sql_optimization["Query optimization<br/>[optimisation.sql]"]
  node_imports["Data imports"]
end

subgraph group_admin["Database administration"]
  node_postgres[("PostgreSQL database")]
  node_backup["Backups<br/>[Sauvegardes.md]"]
  node_pgadmin["pgAdmin"]
end

node_client(("API client"))

node_client -->|"requests data"| node_api
node_api -->|"opens connection"| node_db_conn
node_db_conn -->|"connects to"| node_postgres
node_api -->|"queries stations and chargers"| node_postgres
node_postgres -->|"returns JSON"| node_client
node_postgres -->|"stores network data"| node_stations_chargers
node_postgres -->|"stores activity data"| node_customers_sessions
node_postgres -->|"stores records"| node_payments_incidents
node_postgres -->|"stores interventions"| node_interventions
node_postgres -->|"validates data"| node_sql_checks
node_postgres -->|"supports SQL analysis"| node_sql_queries
node_postgres -.->|"optimizes queries"| node_sql_optimization
node_imports -->|"imports data"| node_postgres
node_postgres -->|"backs up"| node_backup
node_pgadmin -->|"administers"| node_postgres

click node_api "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/main.py"
click node_db_conn "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/database.py"
click node_stations_chargers "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql"
click node_customers_sessions "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql"
click node_payments_incidents "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql"
click node_interventions "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql"
click node_sql_checks "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/02_verifications.sql"
click node_sql_queries "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/03_requetes.sql"
click node_sql_optimization "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/optimisation.sql"
click node_imports "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/Proc%C3%A9dure%20d'imports.md"
click node_backup "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/Sauvegardes/Sauvegardes.md"
click node_web_assets "https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/static/index.html"

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_api,node_db_conn,node_web_assets,node_client toneBlue
class node_stations_chargers,node_customers_sessions,node_payments_incidents,node_interventions toneAmber
class node_sql_checks,node_sql_queries,node_sql_optimization,node_imports toneMint
class node_postgres,node_backup,node_pgadmin toneRose
```

## Components

### API access

- [FastAPI routes](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/main.py): `app/main.py`
- [PostgreSQL connection](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/database.py): `app/database.py`
- [Web assets](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/app/static/index.html): `app/static/index.html`

### Charging domain

- [Stations and chargers](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql): `sql/01_schema.sql`
- [Customers and sessions](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql): `sql/01_schema.sql`
- [Payments and incidents](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql): `sql/01_schema.sql`
- [Interventions](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/01_schema.sql): `sql/01_schema.sql`

### SQL operations

- [Data verification](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/02_verifications.sql): `sql/02_verifications.sql`
- [SQL queries](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/03_requetes.sql): `sql/03_requetes.sql`
- [Query optimization](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/optimisation.sql): `sql/optimisation.sql`
- [Data imports](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/sql/Proc%C3%A9dure%20d'imports.md): `sql/Procédure d'imports.md`

### Database administration

- **PostgreSQL database**
- [Backups](https://github.com/hitomi-ap/urbanwatt_sql/blob/main/Sauvegardes/Sauvegardes.md): `Sauvegardes/Sauvegardes.md`
- **pgAdmin**

### Other components

- **API client**

## Connections

- API client → FastAPI routes: requests data (evidence: `README.md`)
- FastAPI routes → PostgreSQL connection: opens connection (evidence: `app/main.py`)
- PostgreSQL connection → PostgreSQL database: connects to (evidence: `app/database.py`)
- FastAPI routes → PostgreSQL database: queries stations and chargers (evidence: `app/main.py`)
- PostgreSQL database → API client: returns JSON (evidence: `README.md`)
- PostgreSQL database → Stations and chargers: stores network data (evidence: `README.md`)
- PostgreSQL database → Customers and sessions: stores activity data (evidence: `README.md`)
- PostgreSQL database → Payments and incidents: stores records (evidence: `README.md`)
- PostgreSQL database → Interventions: stores interventions (evidence: `README.md`)
- PostgreSQL database → Data verification: validates data (evidence: `README.md`)
- PostgreSQL database → SQL queries: supports SQL analysis (evidence: `README.md`)
- PostgreSQL database → Query optimization: optimizes queries
- Data imports → PostgreSQL database: imports data (evidence: `README.md`)
- PostgreSQL database → Backups: backs up (evidence: `README.md`)
- pgAdmin → PostgreSQL database: administers (evidence: `README.md`)
