# nithincninan/magento2-docker architecture

> Architecture diagram of the GitHub repository nithincninan/magento2-docker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithincninan/magento2-docker
- Repository: https://github.com/nithincninan/magento2-docker

## Overview

##### Project type and purpose
- This is a Docker-based development environment for running a Magento 2.4.x e-commerce application.
- It uses Docker Compose to wire up multiple containerized services (web server, PHP-FPM, database, caches, search engine, message queue, developer tools).

##### File structure
- Top-level Docker Compose definitions:
- docker-compose.yml (production)
- docker-compose.dev.yml (development)
- docker/nginx: Dockerfile + custom Nginx configs (default.conf, m2-config/nginx.conf)
- docker/php: Dockerfile + PHP-FPM pool config (www.conf)
- .env for environment variables, .github/workflows/docker-image.yml for CI, hosts Mageto code under magento247 folder.

##### Main components
a. Developer workstation
- Hosts code, runs Docker CLI, PHPStorm + Xdebug
b. Reverse proxy / web server
- Nginx container (port 80 → Magento frontend/admin)
c. Application
- PHP-FPM container running Magento code at /var/www/magento247
- Xdebug frontend in PHP container
- Blackfire Probe + CLI inside PHP container, Blackfire agent container
d. Persistent data stores
- MariaDB container (MySQL 10.6)
- Redis container (session & page-cache DBs 0–2)
- OpenSearch container (catalog search index)
- RabbitMQ container (message queue for asynchronous tasks)
e. Developer support tools
- MailHog container (SMTP catch-all & UI on port 8025)
- RedisInsight container (Redis GUI on port 8001)
- OpenSearch Dashboards container (Kibana-like UI on port 5601)

##### Relationships & data flows
- HTTP request → Nginx → proxy_pass to PHP-FPM
- PHP-FPM ↔ MariaDB for CRUD operations
- PHP-FPM ↔ Redis for session & cache reads/writes
- PHP-FPM ↔ OpenSearch for catalog search indexing & queries
- PHP-FPM → RabbitMQ for enqueuing background jobs → PHP-FPM workers consume
- PHP-FPM → MailHog SMTP port for transactional emails
- PHPStorm ↔ PHP-FPM (Xdebug) and PHPStorm ↔ Blackfire client → Blackfire agent → Blackfire cloud

##### Architectural patterns & design principles
- Container-per-service (microservices-style)
- Single Docker network (magento_network) connects all services
- Clear separation of concerns: web proxy, app runtime, data persistence, dev tools
- Environment configuration via .env, docker-compose overrides for dev/prod

##### Essential elements
- Exact container names (nginx, php, mariadb, redis, opensearch, rabbitmq, mailhog, redisinsight, opensearch-dashboards, blackfire)
- Volume mounts (./magento247 → /var/www/magento247)
- Port mappings (80, 9000, 3306, 6379, 9200, 5672, 8025, 8001, 5601)
- FastCGI connection between Nginx and PHP-FPM
- Network name (“magento_network”) encapsulating all services

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Local Config Files"
        DCprod["docker-compose.yml"]:::config
        DCdev["docker-compose.dev.yml"]:::config
        env[".env"]:::config
        cicfg[".github/workflows/docker-image.yml"]:::config
    end

    Developer["Developer Host<br>(IDE, Git, Docker CLI)"]:::host

    subgraph "Docker Network<br>(magento_network)"
        Nginx["nginx<br>(port 80)"]:::web
        PHP["php-fpm<br>(port 9000)"]:::app
        BFagent["blackfire-agent"]:::app
        Maria["mariadb<br>(port 3306)"]:::db
        Redis["redis<br>(port 6379)"]:::db
        OpenSearch["opensearch<br>(port 9200)"]:::db
        RabbitMQ["rabbitmq<br>(port 5672)"]:::broker
        MailHog["mailhog<br>(SMTP 1025,<br>UI 8025)"]:::tool
        RedisInsight["redisinsight<br>(UI 8001)"]:::tool
        OSDB["opensearch-dashboards<br>(UI 5601)"]:::tool
    end

    Developer -->|"mounts ./magento247"| PHP
    Developer -->|"HTTP 80"| Nginx
    Developer -->|"Xdebug"| PHP
    Developer -->|"Blackfire client"| BFagent

    Nginx -->|"FastCGI 9000"| PHP
    PHP -->|"SQL 3306"| Maria
    PHP <-->|"cache read/write"| Redis
    PHP -->|"search HTTP 9200"| OpenSearch
    PHP -->|"AMQP 5672"| RabbitMQ
    PHP -->|"SMTP 1025"| MailHog

    RedisInsight -->|"connects 6379"| Redis
    OSDB -->|"connects 9200"| OpenSearch
    BFagent -->|"probes PHP"| PHP

    click DCprod "https://github.com/nithincninan/magento2-docker/blob/master/docker-compose.yml"
    click DCdev "https://github.com/nithincninan/magento2-docker/blob/master/docker-compose.dev.yml"
    click env "https://github.com/nithincninan/magento2-docker/blob/master/.env"
    click cicfg "https://github.com/nithincninan/magento2-docker/blob/master/.github/workflows/docker-image.yml"
    click nginx_dockerfile "https://github.com/nithincninan/magento2-docker/tree/master/docker/nginx/Dockerfile"
    click nginx_default "https://github.com/nithincninan/magento2-docker/blob/master/docker/nginx/default.conf"
    click nginx_m2 "https://github.com/nithincninan/magento2-docker/blob/master/docker/nginx/m2-config/nginx.conf"
    click php_dockerfile "https://github.com/nithincninan/magento2-docker/tree/master/docker/php/Dockerfile"
    click php_www "https://github.com/nithincninan/magento2-docker/blob/master/docker/php/www.conf"
    click magento "https://github.com/nithincninan/magento2-docker/tree/master/magento247"

    classDef web fill:#ACE7FF,stroke:#000;
    classDef app fill:#C2F0C2,stroke:#000;
    classDef db fill:#FFD580,stroke:#000;
    classDef broker fill:#D9B3FF,stroke:#000;
    classDef tool fill:#E0E0E0,stroke:#000;
    classDef host fill:#FFF2CC,stroke:#000;
    classDef config fill:#F2F2F2,stroke:#000;
```
