103 lines
3.9 KiB
Python
103 lines
3.9 KiB
Python
"""Génère 2 schémas d'architecture (infrastructure + couches logiques)
|
|
pour le dossier technique, à partir de la structure réelle du projet."""
|
|
|
|
import matplotlib
|
|
matplotlib.use("Agg")
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.patches as mpatches
|
|
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
|
|
|
|
# Palette neutre, sobre, accessible (contraste élevé)
|
|
NAVY = "#1f2937"
|
|
BLUE = "#2563eb"
|
|
GREEN = "#16a34a"
|
|
GRAY = "#6b7280"
|
|
BG = "#f3f4f6"
|
|
WHITE = "#ffffff"
|
|
|
|
|
|
def box(ax, xy, w, h, text, face, edge=NAVY, fontsize=11, fontcolor=WHITE):
|
|
b = FancyBboxPatch(
|
|
xy, w, h, boxstyle="round,pad=0.02,rounding_size=0.08",
|
|
linewidth=1.6, edgecolor=edge, facecolor=face, zorder=2,
|
|
)
|
|
ax.add_patch(b)
|
|
ax.text(xy[0] + w / 2, xy[1] + h / 2, text, ha="center", va="center",
|
|
fontsize=fontsize, color=fontcolor, weight="bold", zorder=3, wrap=True)
|
|
|
|
|
|
def arrow(ax, start, end, color=GRAY):
|
|
a = FancyArrowPatch(start, end, arrowstyle="-|>", mutation_scale=16,
|
|
linewidth=1.6, color=color, zorder=1)
|
|
ax.add_patch(a)
|
|
|
|
|
|
# --- Diagramme 1 : infrastructure Docker (3 tiers) --------------------------
|
|
fig, ax = plt.subplots(figsize=(10, 6))
|
|
ax.set_xlim(0, 10)
|
|
ax.set_ylim(0, 6.6)
|
|
ax.axis("off")
|
|
ax.set_facecolor(BG)
|
|
fig.patch.set_facecolor(WHITE)
|
|
|
|
ax.text(5, 6.25, "GestHub — Architecture d'infrastructure (Docker Compose)",
|
|
ha="center", fontsize=13, weight="bold", color=NAVY)
|
|
|
|
box(ax, (3.7, 5.0), 2.6, 0.7, "Internet (HTTPS 443)", GRAY, fontsize=10)
|
|
box(ax, (3.7, 3.7), 2.6, 0.8, "Caddy\n(reverse proxy + TLS auto)", BLUE)
|
|
arrow(ax, (5, 5.0), (5, 4.5))
|
|
|
|
box(ax, (0.4, 2.2), 2.4, 0.9, "Flask\n(app.py, gunicorn 4 workers)", GREEN)
|
|
box(ax, (3.8, 2.2), 2.4, 0.9, "Keycloak\n(SSO / OIDC)", GREEN)
|
|
box(ax, (7.2, 2.2), 2.4, 0.9, "Mattermost\n(chat + Kanban)", GREEN)
|
|
arrow(ax, (4.4, 3.7), (1.7, 3.1))
|
|
arrow(ax, (5.4, 3.7), (5.0, 3.1))
|
|
arrow(ax, (6.0, 3.7), (8.3, 3.1))
|
|
|
|
box(ax, (0.4, 0.7), 2.4, 0.9, "MariaDB\n(gesthub : annonces, fichiers,\nevenements, blocks, audit_log)", NAVY, fontsize=9)
|
|
box(ax, (3.8, 0.7), 2.4, 0.9, "PostgreSQL\n(keycloak-db)", NAVY, fontsize=10)
|
|
box(ax, (7.2, 0.7), 2.4, 0.9, "PostgreSQL\n(mattermost-db)", NAVY, fontsize=10)
|
|
arrow(ax, (1.6, 2.2), (1.6, 1.6))
|
|
arrow(ax, (5.0, 2.2), (5.0, 1.6))
|
|
arrow(ax, (8.4, 2.2), (8.4, 1.6))
|
|
|
|
ax.text(5, 0.15, "Réseau Docker interne \"gesthub-net\" — seul Caddy expose un port public (TS-06)",
|
|
ha="center", fontsize=9, color=GRAY, style="italic")
|
|
|
|
plt.tight_layout()
|
|
plt.savefig("evidence/schema_infrastructure.png", dpi=160, facecolor=WHITE)
|
|
plt.close()
|
|
|
|
# --- Diagramme 2 : architecture logique en 5 couches -------------------------
|
|
fig, ax = plt.subplots(figsize=(9, 6.5))
|
|
ax.set_xlim(0, 9)
|
|
ax.set_ylim(0, 7)
|
|
ax.axis("off")
|
|
fig.patch.set_facecolor(WHITE)
|
|
|
|
ax.text(4.5, 6.7, "GestHub — Architecture logique en 5 couches",
|
|
ha="center", fontsize=13, weight="bold", color=NAVY)
|
|
|
|
layers = [
|
|
("Présentation", "templates/, static/ (Jinja2, CSS, JS)", BLUE, 5.5),
|
|
("Contrôleur (routes/)", "auth.py, annonces.py, fichiers.py, evenements.py, dashboard.py", GREEN, 4.35),
|
|
("Service (services/)", "annonce_service, fichier_service, auth_service, audit_service, ...", GREEN, 3.2),
|
|
("Accès données (models/) — Repository Pattern", "annonce_model, fichier_model, block_model, audit_model", NAVY, 2.05),
|
|
("Infrastructure", "db.py (PyMySQL) · config.py · MariaDB · Docker", GRAY, 0.9),
|
|
]
|
|
|
|
for title, subtitle, color, y in layers:
|
|
box(ax, (0.4, y), 8.2, 0.95, f"{title}\n{subtitle}", color, fontsize=10)
|
|
|
|
for y1, y2 in [(5.5, 5.3), (4.35, 4.15), (3.2, 3.0), (2.05, 1.85)]:
|
|
arrow(ax, (4.5, y1), (4.5, y2))
|
|
|
|
ax.text(4.5, 0.1, "Chaque flèche = dépendance descendante uniquement (aucune couche ne dépend d'une couche supérieure)",
|
|
ha="center", fontsize=9, color=GRAY, style="italic")
|
|
|
|
plt.tight_layout()
|
|
plt.savefig("evidence/schema_couches_logiques.png", dpi=160, facecolor=WHITE)
|
|
plt.close()
|
|
|
|
print("Diagrammes generes.")
|