# frodo1209/proyecto1_iac architecture

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

- Interactive diagram: https://gitdiagram.com/frodo1209/proyecto1_iac
- Repository: https://github.com/frodo1209/proyecto1_iac

## Overview

El repositorio despliega dos aplicaciones de ejemplo: guestbook con Apache/PHP y MariaDB en máquinas virtuales, y un tablón de notas con Caddy/PHP-FPM y PostgreSQL en contenedores LXC. El flujo principal va de crear la infraestructura con OpenTofu a generar el inventario y configurar las máquinas con Ansible. La documentación describe las responsabilidades y conexiones; solo se muestra código de la aplicación de notas, así que no se detallan internals no muestreados.

Main entry points: [`ansible/site.yaml`](https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/site.yaml) (Playbook principal), [`opentofu/main.tf`](https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/main.tf) (VMs y discos), [`ansible/roles/lxc`](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc) (Host LXC y red), [`ansible/roles/web`](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/web) (Guestbook PHP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provisioning["Infraestructura"]
  node_tofu_network["Redes VM<br/>[network.tf]"]
  node_tofu_vms["VMs y discos<br/>[main.tf]"]
  node_cloud_init["Cloud-init"]
  node_ip_outputs["IPs VM<br/>[output.tf]"]
  node_inventory["Inventario Ansible<br/>[inventario.tf]"]
end

subgraph group_configuration["Configuración"]
  node_site["Playbook principal<br/>[site.yaml]"]
  node_commons["Configuración común"]
  node_vm_web["Servidor web VM"]
  node_vm_db["Servidor MariaDB"]
  node_lxc_host["Host LXC y red"]
end

subgraph group_guestbook["Guestbook"]
  node_guestbook_app["Guestbook PHP"]
  node_mariadb[("MariaDB")]
end

subgraph group_lxc_notes["Notas LXC"]
  node_lxc_postgres["PostgreSQL LXC"]
  node_postgres_db[("Base de notas<br/>[schema.sql.j2]")]
  node_lxc_caddy["Caddy y PHP-FPM"]
  node_notes_app["Aplicación de notas<br/>[index.php]"]
end

node_operator(("Operador"))
node_browser(("Navegador"))

node_operator -->|"aplica configuración"| node_tofu_network
node_operator -->|"aplica configuración"| node_tofu_vms
node_tofu_vms -->|"configura arranque"| node_cloud_init
node_tofu_vms -->|"expone direcciones"| node_ip_outputs
node_ip_outputs -->|"genera inventario"| node_inventory
node_operator -->|"ejecuta playbook"| node_site
node_inventory -->|"proporciona hosts"| node_site
node_site -->|"configura máquinas"| node_commons
node_site -->|"despliega web"| node_vm_web
node_site -->|"despliega base"| node_vm_db
node_site -->|"configura host"| node_lxc_host
node_vm_web -->|"despliega aplicación"| node_guestbook_app
node_guestbook_app -->|"consulta y actualiza"| node_mariadb
node_lxc_host -->|"configura contenedor"| node_lxc_postgres
node_lxc_host -->|"configura contenedor"| node_lxc_caddy
node_lxc_postgres -->|"crea esquema"| node_postgres_db
node_lxc_caddy -->|"sirve aplicación"| node_notes_app
node_notes_app -->|"lee y modifica notas"| node_postgres_db
node_browser -->|"visita sitio"| node_guestbook_app
node_browser -->|"visita tablón"| node_notes_app

click node_tofu_network "https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/network.tf"
click node_tofu_vms "https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/main.tf"
click node_cloud_init "https://github.com/frodo1209/proyecto1_iac/tree/main/opentofu/cloud-init"
click node_ip_outputs "https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/output.tf"
click node_inventory "https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/inventario.tf"
click node_site "https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/site.yaml"
click node_commons "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/commons"
click node_vm_web "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/web"
click node_vm_db "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/bd"
click node_lxc_host "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc"
click node_guestbook_app "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/web"
click node_mariadb "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/bd"
click node_lxc_postgres "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc_postgres"
click node_postgres_db "https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/roles/lxc_postgres/templates/schema.sql.j2"
click node_lxc_caddy "https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc_caddy"
click node_notes_app "https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/roles/lxc_caddy/files/index.php"

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_tofu_network,node_tofu_vms,node_cloud_init,node_ip_outputs,node_inventory toneBlue
class node_site,node_commons,node_vm_web,node_vm_db,node_lxc_host toneAmber
class node_guestbook_app,node_mariadb toneMint
class node_lxc_postgres,node_postgres_db,node_lxc_caddy,node_notes_app toneRose
class node_operator,node_browser toneIndigo
```

## Components

### Infraestructura

- [Redes VM](https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/network.tf): `opentofu/network.tf`
- [VMs y discos](https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/main.tf): `opentofu/main.tf`
- [Cloud-init](https://github.com/frodo1209/proyecto1_iac/tree/main/opentofu/cloud-init): `opentofu/cloud-init`
- [IPs VM](https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/output.tf): `opentofu/output.tf`
- [Inventario Ansible](https://github.com/frodo1209/proyecto1_iac/blob/main/opentofu/inventario.tf): `opentofu/inventario.tf`

### Configuración

- [Playbook principal](https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/site.yaml): `ansible/site.yaml`
- [Configuración común](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/commons): `ansible/roles/commons`
- [Servidor web VM](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/web): `ansible/roles/web`
- [Servidor MariaDB](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/bd): `ansible/roles/bd`
- [Host LXC y red](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc): `ansible/roles/lxc`

### Guestbook

- [Guestbook PHP](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/web): `ansible/roles/web`
- [MariaDB](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/bd): `ansible/roles/bd`

### Notas LXC

- [PostgreSQL LXC](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc_postgres): `ansible/roles/lxc_postgres`
- [Base de notas](https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/roles/lxc_postgres/templates/schema.sql.j2): `ansible/roles/lxc_postgres/templates/schema.sql.j2`
- [Caddy y PHP-FPM](https://github.com/frodo1209/proyecto1_iac/tree/main/ansible/roles/lxc_caddy): `ansible/roles/lxc_caddy`
- [Aplicación de notas](https://github.com/frodo1209/proyecto1_iac/blob/main/ansible/roles/lxc_caddy/files/index.php): `ansible/roles/lxc_caddy/files/index.php`

### Other components

- **Operador**
- **Navegador**

## Connections

- Operador → Redes VM: aplica configuración (evidence: `README.md`)
- Operador → VMs y discos: aplica configuración (evidence: `README.md`)
- VMs y discos → Cloud-init: configura arranque (evidence: `README.md`)
- VMs y discos → IPs VM: expone direcciones (evidence: `README.md`)
- IPs VM → Inventario Ansible: genera inventario (evidence: `README.md`)
- Operador → Playbook principal: ejecuta playbook (evidence: `README.md`)
- Inventario Ansible → Playbook principal: proporciona hosts (evidence: `README.md`)
- Playbook principal → Configuración común: configura máquinas (evidence: `README.md`)
- Playbook principal → Servidor web VM: despliega web (evidence: `README.md`)
- Playbook principal → Servidor MariaDB: despliega base (evidence: `README.md`)
- Playbook principal → Host LXC y red: configura host (evidence: `README.md`)
- Servidor web VM → Guestbook PHP: despliega aplicación (evidence: `README.md`)
- Guestbook PHP → MariaDB: consulta y actualiza (evidence: `README.md`)
- Host LXC y red → PostgreSQL LXC: configura contenedor (evidence: `README.md`)
- Host LXC y red → Caddy y PHP-FPM: configura contenedor (evidence: `README.md`)
- PostgreSQL LXC → Base de notas: crea esquema (evidence: `README.md`)
- Caddy y PHP-FPM → Aplicación de notas: sirve aplicación (evidence: `README.md`)
- Aplicación de notas → Base de notas: lee y modifica notas (evidence: `ansible/roles/lxc_caddy/files/index.php`)
- Navegador → Guestbook PHP: visita sitio (evidence: `README.md`)
- Navegador → Aplicación de notas: visita tablón (evidence: `README.md`)
