# mouhibfahem/devops architecture

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

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

## Overview

This is a small, in-memory flashcards REST API. A client request enters the HTTP server, passes through observability middleware, reaches a route handler, and reads or changes the seeded card store; quiz mode returns a random question without its answer. The other main product branch is operational visibility: structured request logs, Prometheus metrics and optional OpenTelemetry export, with Prometheus/Grafana/Jaeger configuration represented where present. Handler and middleware relationships are supported by source excerpts; monitoring integrations and provisioning links are documented in the README. Some configuration wiring is not shown in source, so those links are documented or left out.

Main entry points: [`middleware.go`](https://github.com/mouhibfahem/devops/blob/main/middleware.go) (Request Middleware), [`main.go`](https://github.com/mouhibfahem/devops/blob/main/main.go) (HTTP Server), [`tracing.go`](https://github.com/mouhibfahem/devops/blob/main/tracing.go) (OpenTelemetry Tracing), [`metrics.go`](https://github.com/mouhibfahem/devops/blob/main/metrics.go) (Prometheus Metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Flashcards API"]
  node_server["HTTP Server<br/>[main.go]"]
  node_routes["API Routes<br/>[main.go]"]
  node_card_ops["Card Operations<br/>[main.go]"]
  node_quiz["Quiz Mode<br/>[main.go]"]
  node_store[("In-Memory Store<br/>[main.go]")]
end

subgraph group_observe["Request Observability"]
  node_middleware["Request Middleware<br/>[middleware.go]"]
  node_request_logs["Structured Logs<br/>[middleware.go]"]
  node_metrics["Prometheus Metrics<br/>[metrics.go]"]
  node_tracing["OpenTelemetry Tracing<br/>[tracing.go]"]
end

subgraph group_monitor["Monitoring Stack"]
  node_prometheus["Prometheus"]
  node_prom_config["Prometheus Config<br/>[prometheus.yml]"]
  node_grafana["Grafana Dashboard<br/>[flashcards.json]"]
  node_grafana_datasource["Grafana Datasource<br/>[prometheus.yml]"]
end

node_client(("API Client"))
node_jaeger["Jaeger"]

node_client -->|"sends requests"| node_server
node_server -->|"serves"| node_routes
node_server -->|"wraps handler"| node_middleware
node_routes -->|"routes card calls"| node_card_ops
node_routes -->|"routes quiz calls"| node_quiz
node_card_ops -->|"reads and writes"| node_store
node_quiz -->|"lists cards"| node_store
node_middleware -->|"writes logs"| node_request_logs
node_middleware -->|"records requests"| node_metrics
node_middleware -->|"starts spans"| node_tracing
node_prometheus -->|"scrapes"| node_metrics
node_prom_config -.->|"configures scrape"| node_prometheus
node_grafana_datasource -->|"queries metrics"| node_prometheus
node_grafana -->|"visualizes metrics"| node_prometheus
node_tracing -->|"exports OTLP"| node_jaeger

click node_server "https://github.com/mouhibfahem/devops/blob/main/main.go"
click node_routes "https://github.com/mouhibfahem/devops/blob/main/main.go"
click node_card_ops "https://github.com/mouhibfahem/devops/blob/main/main.go"
click node_quiz "https://github.com/mouhibfahem/devops/blob/main/main.go"
click node_store "https://github.com/mouhibfahem/devops/blob/main/main.go"
click node_middleware "https://github.com/mouhibfahem/devops/blob/main/middleware.go"
click node_request_logs "https://github.com/mouhibfahem/devops/blob/main/middleware.go"
click node_metrics "https://github.com/mouhibfahem/devops/blob/main/metrics.go"
click node_tracing "https://github.com/mouhibfahem/devops/blob/main/tracing.go"
click node_prom_config "https://github.com/mouhibfahem/devops/blob/main/observability/prometheus.yml"
click node_grafana "https://github.com/mouhibfahem/devops/blob/main/observability/grafana/dashboards/flashcards.json"
click node_grafana_datasource "https://github.com/mouhibfahem/devops/blob/main/observability/grafana/provisioning/datasources/prometheus.yml"

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_server,node_routes,node_card_ops,node_quiz,node_store,node_client toneBlue
class node_middleware,node_request_logs,node_metrics,node_tracing toneAmber
class node_prometheus,node_prom_config,node_grafana,node_grafana_datasource toneMint
class node_jaeger toneIndigo
```

## Components

### Flashcards API

- [HTTP Server](https://github.com/mouhibfahem/devops/blob/main/main.go): `main.go`
- [API Routes](https://github.com/mouhibfahem/devops/blob/main/main.go): `main.go`
- [Card Operations](https://github.com/mouhibfahem/devops/blob/main/main.go): `main.go`
- [Quiz Mode](https://github.com/mouhibfahem/devops/blob/main/main.go): `main.go`
- [In-Memory Store](https://github.com/mouhibfahem/devops/blob/main/main.go): `main.go`

### Request Observability

- [Request Middleware](https://github.com/mouhibfahem/devops/blob/main/middleware.go): `middleware.go`
- [Structured Logs](https://github.com/mouhibfahem/devops/blob/main/middleware.go): `middleware.go`
- [Prometheus Metrics](https://github.com/mouhibfahem/devops/blob/main/metrics.go): `metrics.go`
- [OpenTelemetry Tracing](https://github.com/mouhibfahem/devops/blob/main/tracing.go): `tracing.go`

### Monitoring Stack

- **Prometheus**
- [Prometheus Config](https://github.com/mouhibfahem/devops/blob/main/observability/prometheus.yml): `observability/prometheus.yml`
- [Grafana Dashboard](https://github.com/mouhibfahem/devops/blob/main/observability/grafana/dashboards/flashcards.json): `observability/grafana/dashboards/flashcards.json`
- [Grafana Datasource](https://github.com/mouhibfahem/devops/blob/main/observability/grafana/provisioning/datasources/prometheus.yml): `observability/grafana/provisioning/datasources/prometheus.yml`

### Other components

- **API Client**
- **Jaeger**

## Connections

- API Client → HTTP Server: sends requests (evidence: `README.md`)
- HTTP Server → API Routes: serves (evidence: `main.go`)
- HTTP Server → Request Middleware: wraps handler (evidence: `main.go`)
- API Routes → Card Operations: routes card calls (evidence: `main.go`)
- API Routes → Quiz Mode: routes quiz calls (evidence: `main.go`)
- Card Operations → In-Memory Store: reads and writes (evidence: `main.go`)
- Quiz Mode → In-Memory Store: lists cards (evidence: `main.go`)
- Request Middleware → Structured Logs: writes logs (evidence: `middleware.go`)
- Request Middleware → Prometheus Metrics: records requests (evidence: `middleware.go`)
- Request Middleware → OpenTelemetry Tracing: starts spans (evidence: `README.md`)
- Prometheus → Prometheus Metrics: scrapes (evidence: `README.md`)
- Prometheus Config → Prometheus: configures scrape
- Grafana Datasource → Prometheus: queries metrics (evidence: `README.md`)
- Grafana Dashboard → Prometheus: visualizes metrics (evidence: `README.md`)
- OpenTelemetry Tracing → Jaeger: exports OTLP (evidence: `README.md`)
