# devgamers/changement-climatique-bretagne architecture

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

- Interactive diagram: https://gitdiagram.com/devgamers/changement-climatique-bretagne
- Repository: https://github.com/devgamers/changement-climatique-bretagne

## Overview

This is a Flask API serving cached French departmental weather observations. At startup it fetches and prepares two datasets for four departments, then stores department-level and annual aggregates in Redis. Request handlers serve cached data or calculate date-based monthly, yearly, and cross-dataset averages. The README is empty and app.py excerpts omit portions of the implementation, so the graph includes only evidenced routes and data flows.

Main entry points: [`app.py`](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py) (Preload and routes), [`functions.py`](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/functions.py) (Dataset assembly), [`utils.py`](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/utils.py) (CSV and preprocessing), [`run.py`](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/run.py) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and loading"]
  node_startup["App startup<br/>[run.py]"]
  node_loader["Preload and routes<br/>[app.py]"]
  node_gaz["Gaz endpoint<br/>[app.py]"]
  node_monthly["Monthly endpoint<br/>[app.py]"]
  node_yearly["Yearly endpoint<br/>[app.py]"]
  node_annual["Annual endpoint<br/>[app.py]"]
  node_average["Average endpoint<br/>[app.py]"]
end

subgraph group_data["Data preparation"]
  node_fetch["Dataset assembly<br/>[functions.py]"]
  node_filterfetch["Cached CSV loading<br/>[functions.py]"]
  node_csv["CSV and preprocessing<br/>[utils.py]"]
end

subgraph group_storage["Cache"]
  node_redis[("Redis cache")]
end

node_client(("API client"))
node_weather["Weather datasets"]

node_client -->|"requests"| node_gaz
node_client -->|"requests"| node_monthly
node_client -->|"requests"| node_yearly
node_client -->|"requests"| node_annual
node_client -->|"requests"| node_average
node_startup -->|"creates app"| node_loader
node_loader -->|"loads datasets"| node_fetch
node_fetch -->|"loads periods"| node_filterfetch
node_filterfetch -->|"calls"| node_csv
node_csv -->|"reads CSV"| node_weather
node_loader -->|"writes preload"| node_redis
node_gaz -->|"reads cache"| node_redis
node_monthly -->|"reads and writes"| node_redis
node_yearly -->|"reads and writes"| node_redis
node_annual -->|"reads cache"| node_redis
node_average -->|"reads datasets"| node_redis
node_gaz -->|"returns response"| node_client
node_monthly -->|"returns response"| node_client
node_yearly -->|"returns response"| node_client
node_annual -->|"returns response"| node_client
node_average -->|"returns response"| node_client

click node_startup "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/run.py"
click node_loader "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_gaz "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_monthly "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_yearly "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_annual "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_average "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py"
click node_fetch "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/functions.py"
click node_filterfetch "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/functions.py"
click node_csv "https://github.com/devgamers/changement-climatique-bretagne/blob/backend/utils.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_startup,node_loader,node_gaz,node_monthly,node_yearly,node_annual,node_average,node_client toneBlue
class node_fetch,node_filterfetch,node_csv toneAmber
class node_redis toneMint
class node_weather toneIndigo
```

## Components

### API and loading

- [App startup](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/run.py): `run.py`
- [Preload and routes](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`
- [Gaz endpoint](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`
- [Monthly endpoint](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`
- [Yearly endpoint](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`
- [Annual endpoint](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`
- [Average endpoint](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/app.py): `app.py`

### Data preparation

- [Dataset assembly](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/functions.py): `functions.py`
- [Cached CSV loading](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/functions.py): `functions.py`
- [CSV and preprocessing](https://github.com/devgamers/changement-climatique-bretagne/blob/backend/utils.py): `utils.py`

### Cache

- **Redis cache**

### Other components

- **API client**
- **Weather datasets**

## Connections

- API client → Gaz endpoint: requests
- API client → Monthly endpoint: requests
- API client → Yearly endpoint: requests
- API client → Annual endpoint: requests
- API client → Average endpoint: requests
- App startup → Preload and routes: creates app
- Preload and routes → Dataset assembly: loads datasets
- Dataset assembly → Cached CSV loading: loads periods
- Cached CSV loading → CSV and preprocessing: calls
- CSV and preprocessing → Weather datasets: reads CSV
- Preload and routes → Redis cache: writes preload
- Gaz endpoint → Redis cache: reads cache
- Monthly endpoint → Redis cache: reads and writes
- Yearly endpoint → Redis cache: reads and writes
- Annual endpoint → Redis cache: reads cache
- Average endpoint → Redis cache: reads datasets
- Gaz endpoint → API client: returns response
- Monthly endpoint → API client: returns response
- Yearly endpoint → API client: returns response
- Annual endpoint → API client: returns response
- Average endpoint → API client: returns response
