# celiagmqrz/fluent-bit_loki_grafana__docker-drupal architecture

> Architecture diagram of the GitHub repository celiagmqrz/fluent-bit_loki_grafana__docker-drupal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal
- Repository: https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal

## Overview

##### Project Type and Purpose
- Although it hosts a Drupal application stack (web server + database), the README makes clear the focus is on the logging pipeline.

##### File Structure Analysis
- Top-level files:
- `.env` / `docker-compose.yaml` – orchestration and environment variables
- `build_images.sh` – builds custom container images (Drupal, Nginx, MySQL)
- Service folders:
- `nginx/` – Dockerfile, entrypoint scripts, and Nginx configuration template
- `drupal/` – Dockerfile for the Drupal container (PHP-FPM)
- `mysql/` – Dockerfile for MySQL
- `fluent-bit/` – Fluent-Bit config files (`fluent-bit.conf`, `parsers.conf`)
- `loki/` – Loki config (`loki.yml`)
- `grafana/` – Grafana provisioning (datasource YAML)
- The `docker-compose.yaml` ties these services together on a single network (`milocal`).

##### Key Components and Interactions
a. User → Nginx container (ports 80/443) → Drupal/PHP-FPM → MySQL (port 3306)
b. Docker logging driver on each service (nginx, drupal, mysql) emits logs to Fluent-Bit’s forward input (TCP/UDP 24224).
c. Fluent-Bit container reads incoming logs (`[INPUT] Name forward`) and pushes them to Loki via HTTP (`loki/api/v1/push`).
d. Loki stores, indexes, and exposes logs via its HTTP API on port 3100.
e. Grafana container queries Loki (configured via `datasource.yml`) and visualizes logs on dashboards (port 3000).

##### Architectural Patterns and Principles
- Micro-services in containers, each single-responsibility (web, application, database, logging, storage, visualization).
- Log-aggregation pipeline pattern: side-car/collector (Fluent-Bit) → log store (Loki) → visualization (Grafana).
- Separation of concerns: application workload vs. monitoring/observability workload.

##### Step-by-Step
6) Volume mounts for MySQL data and Drupal files if needed.

## Diagram (Mermaid)

```mermaid
graph TB

    %% Configuration artifacts
    subgraph "Configuration"
        E_ENV[".env"]:::config
        DC["docker-compose.yaml"]:::config
        BUILD["build_images.sh"]:::config
    end

    %% Docker network boundary
    subgraph "Docker Host / milocal network"

        %% Application Stack
        subgraph "Application Stack"
            USER["User Browser"]:::external
            NGINX["Nginx\n(80/443)"]:::app
            DRUPAL["Drupal PHP-FPM\n(9000)"]:::app
            MYSQL["MySQL\n(3306)"]:::app
            VOL_MYSQL[(MySQL Data Volume)]:::storage
            VOL_DRUPAL[(Drupal Files Volume)]:::storage
        end

        %% Observability Stack
        subgraph "Observability Stack"
            FLUENTBIT["Fluent-Bit\n(24224)"]:::logging
            LOKI["Loki\n(3100)"]:::logging
            GRAFANA["Grafana\n(3000)"]:::logging
        end

    end

    %% Data flow between application components
    USER -->|"HTTP"|NGINX
    NGINX -->|"FastCGI/HTTP"|DRUPAL
    DRUPAL -->|"SQL"|MYSQL
    VOL_MYSQL -->|"Volume Mount"|MYSQL
    VOL_DRUPAL -->|"Volume Mount"|DRUPAL

    %% Logging pipeline flows
    NGINX -->|"fluentd-driver (24224)"|FLUENTBIT
    DRUPAL -->|"fluentd-driver (24224)"|FLUENTBIT
    MYSQL -->|"fluentd-driver (24224)"|FLUENTBIT

    FLUENTBIT -->|"HTTP API (loki/api/v1/push)"|LOKI
    GRAFANA -->|"API Query"|LOKI

    %% Click Events
    click E_ENV "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/.env"
    click DC "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/docker-compose.yaml"
    click BUILD "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/build_images.sh"
    click NGINX "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/tree/main/nginx/Dockerfile"
    click NGINX "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/nginx/assets/bin/docker-entrypoint.sh"
    click NGINX "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/nginx/assets/templates/nginx.conf.tmpl"
    click DRUPAL "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/tree/main/drupal/Dockerfile"
    click MYSQL "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/tree/main/mysql/Dockerfile"
    click FLUENTBIT "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/fluent-bit/fluent-bit.conf"
    click FLUENTBIT "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/fluent-bit/parsers.conf"
    click LOKI "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/loki/configs/loki.yml"
    click GRAFANA "https://github.com/celiagmqrz/fluent-bit_loki_grafana__docker-drupal/blob/main/grafana/configs/datasource.yml"

    %% Styles
    classDef app fill:#E3F2FD,stroke:#1E88E5
    classDef logging fill:#FFF8E1,stroke:#FBC02D
    classDef storage fill:#E8F5E9,stroke:#43A047
    classDef config fill:#F3E5F5,stroke:#8E24AA
    classDef external fill:#ECEFF1,stroke:#607D8B
```
