# maxonyar/tp-devops architecture

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

- Interactive diagram: https://gitdiagram.com/maxonyar/tp-devops
- Repository: https://github.com/maxonyar/tp-devops

## Overview

Ce dépôt présente une application Flask avec Redis, accompagnée d’un déploiement blue/green et d’une pile d’observabilité. Le parcours principal va des requêtes HTTP vers les routes Flask, puis vers Redis pour la santé et les visites, tandis que Prometheus collecte les métriques exposées par l’application. Le déploiement et le rollback sont représentés comme branches opérationnelles distinctes. Les relations s’appuient sur les extraits de `app.py` et sur les descriptions du README ; les fichiers de configuration non échantillonnés ne sont pas présentés comme inspectés.

Main entry points: [`app.py`](https://github.com/maxonyar/tp-devops/blob/main/app.py) (API Flask), [`deploy/deploy.sh`](https://github.com/maxonyar/tp-devops/blob/main/deploy/deploy.sh) (Déploiement blue/green), [`monitoring/prometheus.yml`](https://github.com/maxonyar/tp-devops/blob/main/monitoring/prometheus.yml) (Prometheus), [`deploy/nginx/conf.d/default.conf`](https://github.com/maxonyar/tp-devops/blob/main/deploy/nginx/conf.d/default.conf) (Proxy Nginx)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application"]
  node_api["API Flask<br/>[app.py]"]
  node_health["Contrôle santé<br/>[app.py]"]
  node_visits["Compteur visites<br/>[app.py]"]
  node_status["Statut déployé<br/>[app.py]"]
  node_error["Erreur simulée<br/>[app.py]"]
  node_instrumentation["Instrumentation HTTP<br/>[app.py]"]
  node_metrics_endpoint["Endpoint métriques<br/>[app.py]"]
  node_redis_client["Client Redis<br/>[app.py]"]
end

subgraph group_deployment["Déploiement"]
  node_deployer["Déploiement blue/green<br/>[deploy.sh]"]
  node_compose_deploy["Services blue/green"]
  node_rollback["Rollback<br/>[rollback.sh]"]
end

subgraph group_observability["Observabilité"]
  node_prometheus["Prometheus<br/>[prometheus.yml]"]
  node_alerts["Règles alertes<br/>[alert.rules.yml]"]
  node_grafana["Grafana dashboard<br/>[tp-devops.json]"]
  node_datasource["Source Grafana<br/>[datasource.yml]"]
end

subgraph group_runtime["Services runtime"]
  node_redis[("Redis<br/>[docker-compose.yml]")]
  node_nginx["Proxy Nginx<br/>[default.conf]"]
end

node_user(("Client HTTP"))
node_image_registry[("GHCR")]
node_operator(("Opérateur ou CD"))

node_user -->|"appelle"| node_api
node_user -->|"accède via"| node_nginx
node_nginx -->|"route vers"| node_api
node_api -->|"route"| node_health
node_api -->|"route"| node_visits
node_api -->|"route"| node_status
node_api -->|"route"| node_error
node_api -->|"route"| node_metrics_endpoint
node_api -->|"exécute hooks"| node_instrumentation
node_health -->|"ping via"| node_redis_client
node_visits -->|"incrémente via"| node_redis_client
node_redis_client -->|"lit et écrit"| node_redis
node_metrics_endpoint -->|"expose à"| node_prometheus
node_prometheus -->|"évalue"| node_alerts
node_prometheus -->|"alimente"| node_datasource
node_datasource -->|"alimente"| node_grafana
node_operator -->|"déclenche"| node_deployer
node_image_registry -->|"fournit image"| node_deployer
node_deployer -->|"démarre couleur"| node_compose_deploy
node_deployer -->|"reconfigure"| node_nginx
node_deployer -->|"lance si échec"| node_rollback

click node_api "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_health "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_visits "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_status "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_error "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_instrumentation "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_metrics_endpoint "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_redis_client "https://github.com/maxonyar/tp-devops/blob/main/app.py"
click node_redis "https://github.com/maxonyar/tp-devops/blob/main/docker-compose.yml"
click node_nginx "https://github.com/maxonyar/tp-devops/blob/main/deploy/nginx/conf.d/default.conf"
click node_prometheus "https://github.com/maxonyar/tp-devops/blob/main/monitoring/prometheus.yml"
click node_alerts "https://github.com/maxonyar/tp-devops/blob/main/monitoring/alert.rules.yml"
click node_grafana "https://github.com/maxonyar/tp-devops/blob/main/monitoring/grafana/dashboards/tp-devops.json"
click node_datasource "https://github.com/maxonyar/tp-devops/blob/main/monitoring/grafana/provisioning/datasources/datasource.yml"
click node_deployer "https://github.com/maxonyar/tp-devops/blob/main/deploy/deploy.sh"
click node_compose_deploy "https://github.com/maxonyar/tp-devops/blob/main/docker-compose.deploy.yml"
click node_rollback "https://github.com/maxonyar/tp-devops/blob/main/deploy/rollback.sh"

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_health,node_visits,node_status,node_error,node_instrumentation,node_metrics_endpoint,node_redis_client,node_user toneBlue
class node_deployer,node_compose_deploy,node_rollback,node_image_registry toneAmber
class node_prometheus,node_alerts,node_grafana,node_datasource toneMint
class node_redis,node_nginx toneRose
class node_operator toneIndigo
```

## Components

### Application

- [API Flask](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Contrôle santé](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Compteur visites](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Statut déployé](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Erreur simulée](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Instrumentation HTTP](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Endpoint métriques](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`
- [Client Redis](https://github.com/maxonyar/tp-devops/blob/main/app.py): `app.py`

### Déploiement

- [Déploiement blue/green](https://github.com/maxonyar/tp-devops/blob/main/deploy/deploy.sh): `deploy/deploy.sh`
- [Services blue/green](https://github.com/maxonyar/tp-devops/blob/main/docker-compose.deploy.yml): `docker-compose.deploy.yml`
- [Rollback](https://github.com/maxonyar/tp-devops/blob/main/deploy/rollback.sh): `deploy/rollback.sh`

### Observabilité

- [Prometheus](https://github.com/maxonyar/tp-devops/blob/main/monitoring/prometheus.yml): `monitoring/prometheus.yml`
- [Règles alertes](https://github.com/maxonyar/tp-devops/blob/main/monitoring/alert.rules.yml): `monitoring/alert.rules.yml`
- [Grafana dashboard](https://github.com/maxonyar/tp-devops/blob/main/monitoring/grafana/dashboards/tp-devops.json): `monitoring/grafana/dashboards/tp-devops.json`
- [Source Grafana](https://github.com/maxonyar/tp-devops/blob/main/monitoring/grafana/provisioning/datasources/datasource.yml): `monitoring/grafana/provisioning/datasources/datasource.yml`

### Services runtime

- [Redis](https://github.com/maxonyar/tp-devops/blob/main/docker-compose.yml): `docker-compose.yml`
- [Proxy Nginx](https://github.com/maxonyar/tp-devops/blob/main/deploy/nginx/conf.d/default.conf): `deploy/nginx/conf.d/default.conf`

### Other components

- **Client HTTP**
- **GHCR**
- **Opérateur ou CD**

## Connections

- Client HTTP → API Flask: appelle (evidence: `README.md`)
- Client HTTP → Proxy Nginx: accède via (evidence: `README.md`)
- Proxy Nginx → API Flask: route vers (evidence: `README.md`)
- API Flask → Contrôle santé: route (evidence: `app.py`)
- API Flask → Compteur visites: route (evidence: `app.py`)
- API Flask → Statut déployé: route (evidence: `app.py`)
- API Flask → Erreur simulée: route (evidence: `app.py`)
- API Flask → Endpoint métriques: route (evidence: `app.py`)
- API Flask → Instrumentation HTTP: exécute hooks (evidence: `app.py`)
- Contrôle santé → Client Redis: ping via (evidence: `app.py`)
- Compteur visites → Client Redis: incrémente via (evidence: `app.py`)
- Client Redis → Redis: lit et écrit (evidence: `README.md`)
- Endpoint métriques → Prometheus: expose à (evidence: `README.md`)
- Prometheus → Règles alertes: évalue (evidence: `README.md`)
- Prometheus → Source Grafana: alimente (evidence: `README.md`)
- Source Grafana → Grafana dashboard: alimente (evidence: `README.md`)
- Opérateur ou CD → Déploiement blue/green: déclenche (evidence: `README.md`)
- GHCR → Déploiement blue/green: fournit image (evidence: `README.md`)
- Déploiement blue/green → Services blue/green: démarre couleur (evidence: `README.md`)
- Déploiement blue/green → Proxy Nginx: reconfigure (evidence: `README.md`)
- Déploiement blue/green → Rollback: lance si échec (evidence: `README.md`)
