# bmangesh/ansiblelaravel architecture

> Architecture diagram of the GitHub repository bmangesh/ansiblelaravel, 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/bmangesh/ansiblelaravel
- Repository: https://github.com/bmangesh/ansiblelaravel

## Overview

Based on your project’s file tree and the README, this is an Ansible automation project intended to deploy a Laravel PHP application platform with several supporting infrastructure components. The system deploys and configures services such as:
- A Laravel application platform (in roles/laravel)
- A MariaDB Galera cluster (with separate roles for galera, master, and node configuration)
- PHP (with roles/php)
- Nginx as the webserver (in roles/nginx)
- Firewall rules via firewalld (in roles/firewalld)
- And support for additional tasks such as backups and Letsencrypt SSL certificate management

##### Main Components
- Ansible Controller: Central node running the playbook.yml that orchestrates executing the different roles.
- Inventory & Group Vars: Inventory directories (inventories/production, hosts, group_vars) that define which nodes get which configuration.
- Roles:
– Laravel Deployment: Covers pulling changes from GitLab and deploying the Laravel PHP platform.
– MariaDB Galera Cluster: Split into roles for galera, master, and node; each role has tasks, handlers, templates, and configuration files.
– Nginx Configuration: Manages web server configuration including load balancing, SSL termination, and virtual host configurations.
– PHP Deployment: Configures PHP 7 with its dedicated role.
– Firewalld: Sets up security rules on the deployment nodes.
- Supporting Tasks: Handling SSL certificates issuance and distribution (likely to be integrated within the nginx role or as a separate play) and server backups to an offsite cloud backup service.

##### Relationships and Interactions
- The Ansible Controller dispatches playbooks to target servers via SSH, using the hosts defined in inventories.
- Each role is executed against specific groups of servers (e.g., nginx on web nodes, MariaDB roles on DB cluster members).
- The Laravel role might include hooks to pull new code from GitLab and compile/deploy it, while the nginx role handles cert issuance (via Letsencrypt) and distributes those certs across nodes.
- The backup playbook (likely not fully depicted in the file tree but mentioned in the README) ties into all server roles to ensure backup tasks are scheduled/executed.

##### Architectural Patterns and Design Principles
- Modular Role-Based Design: Each aspect of the deployment (firewall, nginx, laravel, database, etc.) is isolated in its own role for clean separation of concerns.
- Inventory/Group Based Targeting: The use of group_vars and inventories reflects an environment-based deployment pattern, allowing different configurations for production.
- Declarative Infrastructure as Code: The entire process is automated via idempotent playbooks following Ansible’s declarative model.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    ansible("Ansible Controller"):::control
    gitlab("Source Control/GitLab"):::external
    web("Web Servers (Nginx)"):::nginx
    backup("Backup Service"):::backup
    firewall_service("Firewall (Firewalld)"):::security

    subgraph "Application Servers"
        laravel("Laravel Deployment"):::app
        php("PHP Deployment"):::app
    end

    subgraph "Database Cluster (MariaDB Galera)"
        db_galera("Galera Configuration"):::db
        db_master("Master Node Configuration"):::db
        db_node("Node Configuration"):::db
    end

    %% Connections
    ansible -->|"orchestrates"| gitlab
    ansible -->|"deploys"| web
    ansible -->|"deploys"| laravel
    ansible -->|"deploys"| php
    ansible -->|"configures"| db_galera
    db_galera -->|"sets_master"| db_master
    db_master -->|"adds_node"| db_node
    ansible -->|"configures"| firewall_service
    ansible -->|"schedules"| backup

    %% Click Events for Ansible Controller (multiple entries as provided)
    click ansible "https://github.com/bmangesh/ansiblelaravel/blob/master/playbook.yml"
    click ansible "https://github.com/bmangesh/ansiblelaravel/tree/master/hosts"
    click ansible "https://github.com/bmangesh/ansiblelaravel/tree/master/group_vars"
    click ansible "https://github.com/bmangesh/ansiblelaravel/tree/master/inventories/production/hosts"

    %% Click Events for Roles
    click laravel "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/laravel"
    click php "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/php"
    click web "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/nginx"
    click db_galera "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/mariadb_galera"
    click db_master "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/mariadb_gmaster"
    click db_node "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/mariadb_gnode"
    click firewall_service "https://github.com/bmangesh/ansiblelaravel/tree/master/roles/firewalld"

    %% Styles
    classDef control fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef external fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef nginx fill:#577590,stroke:#fff,stroke-width:2px;
    classDef app fill:#9d4edd,stroke:#fff,stroke-width:2px;
    classDef db fill:#f94144,stroke:#fff,stroke-width:2px;
    classDef security fill:#43aa8b,stroke:#fff,stroke-width:2px;
    classDef backup fill:#277da1,stroke:#fff,stroke-width:2px;
```
