# jersonmartinez/docker-lamp architecture

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

- Interactive diagram: https://gitdiagram.com/jersonmartinez/docker-lamp
- Repository: https://github.com/jersonmartinez/docker-lamp

## Overview

##### Main Components
- Docker Compose: This file (docker-compose.yml) orchestrates the services.
- Web Service Container: The “www” directory holds the PHP application (index.php, assets, includes) served by Apache with PHP.
- Database Container: MySQL runs as a separate service, with its configuration coming from the .env file (MYSQL_ROOT_PASSWORD, MYSQL_DATABASE, etc.).
- PHPMyAdmin Container: Although not directly represented as a directory, the README explains that PHPMyAdmin is included for database management (accessible on port 8080).
- Dockerfile: Contains instructions for building the PHP container, including any PHP extensions (e.g., pdo, pdo_mysql).

##### Relationships and Interactions
- The Docker Compose (orchestrator) sits at the top level and manages the lifecycle of the containers.
- The Web Service Container communicates with the Database Container for application data (PHP connecting to MySQL).
- The PHPMyAdmin service connects to the Database Container as its admin interface.
- The Web Service Container also responds to incoming HTTP requests from users (displayed on port 80).
- Environment variables (from .env) that are used to configure the database connection and service settings.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Each container represents an independent service (web server, database, admin dashboard), easing development and debugging.
- Containerization: Use of Docker allows for isolated, reproducible environments.
- Configuration as Code: Docker Compose and Dockerfile illustrate how the system is configured and built.

##### Relevant Technologies and Frameworks
- Docker & Docker Compose for container orchestration.
- Linux as the operating system.
- Apache as the web server.
- PHP (version 8.2) as the scripting language.
- MySQL as the database solution.
- PHPMyAdmin for database management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    A["User (Browser)"]:::external

    %% Orchestrator
    B["Docker Compose (Orchestrator)"]:::orchestrator

    %% Containers Subgraph
    subgraph "Containers"
        C["Web Service Container (Apache+PHP, Port:80)"]:::container
        D["Database Container (MySQL)"]:::container
        E["PHPMyAdmin Container (Port:8080)"]:::container
    end

    %% Configuration Files
    F["Dockerfile (PHP Build)"]:::config
    G["www/ Directory (PHP Application)"]:::config
    H[".env.example (Env Variables)"]:::config
    I["dump/myDb.sql (Sample DB Dump)"]:::config

    %% Relationships - External Access
    A -->|"HTTP_Request"| C
    A -->|"Access_Admin"| E

    %% Relationships - Orchestration
    B --> C
    B --> D
    B --> E

    %% Relationships - Container Communication
    C -->|"DBQueries"| D
    E -->|"DBAdmin"| D

    %% Relationships - Configuration and Build
    F -->|"Build"| C
    G -->|"Code"| C
    H -->|"Config"| D
    I -->|"DataInit"| D

    %% Click Events
    click B "https://github.com/jersonmartinez/docker-lamp/blob/main/docker-compose.yml"
    click C "https://github.com/jersonmartinez/docker-lamp/tree/main/www/"
    click F "https://github.com/jersonmartinez/docker-lamp/tree/main/Dockerfile"
    click H "https://github.com/jersonmartinez/docker-lamp/blob/main/.env.example"
    click I "https://github.com/jersonmartinez/docker-lamp/blob/main/dump/myDb.sql"
    click G "https://github.com/jersonmartinez/docker-lamp/tree/main/www/"

    %% Styles
    classDef orchestrator fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef container fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
