# hoojinguyen/airo architecture

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

- Interactive diagram: https://gitdiagram.com/hoojinguyen/airo
- Repository: https://github.com/hoojinguyen/airo

## Overview

Based on our analysis of the file tree and README, Airo is a command-line deployment tool written in Go that simplifies deploying Dockerized services to a self-hosted production server. Its primary purpose is to allow developers to build, push, and deploy containerized applications without the overhead of setting up complex CI/CD pipelines or using managed platforms.

##### Main Components
- CLI Interface & Command Engine: Represented by the main executable (src/main.go) that accepts commands such as “deploy”, “compose”, and “caddy”.
- Configuration Module: Located in src/lib/config.go, which reads and interprets the deployment environment files (env.yml) and service definitions (compose.yml). These configuration files are essential for defining server details and service parameters.
- Remote Deployment Engine: The part of the tool that handles SSH connections (as indicated by the README) to update the configurations and Docker containers on the self-hosted server.
- Reverse Proxy & HTTPS Manager: This is achieved via handling the Caddy configuration (example/Caddyfile) for automatically setting up HTTPS and reverse proxy rules on the production server.
- Auxiliary/Example Configuration: The “example” directory contains sample files (Caddyfile, compose.yml, env.yml) that illustrate how services should be set up, helping users understand what to expect and configure.

##### Relationships and Interactions
- The CLI receives user commands which, through the Go-based command engine, trigger different workflows (deploy, compose, caddy).
- The configuration component reads from env.yml and compose.yml to obtain deployment and service definitions.
- Upon a deployment command, the tool will trigger routines to:
a. Build Docker images based on provided Dockerfiles.
b. Push these images to a specified registry.
c. Use SSH to connect to the target production server.
d. Deploy or update running containers.
- For reverse proxy and HTTPS updates, the tool uses the Caddyfile configuration to reconfigure the server’s reverse proxy via a specific subcommand.
- Data flows from the local machine (where commands are issued and Docker operations happen) toward the production server (receiving the deployment updates).

##### Architectural Patterns and Design Principles
- Modular Design: The separation into distinct modules (command interface, configuration parsing, deployment logic) helps in maintaining and extending the tool.
- Single Command Deployment: Emphasizes simplicity by abstracting multiple steps (build, push, deploy) into simple command-line operations.
- Decoupling: The tool is designed so that services (defined in compose.yml) and server settings (in env.yml) are decoupled from the application logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Local Environment"
        direction TB
        CLI["CLI Command Engine"]:::local
        Config["Configuration Parser"]:::local
        Docker["Docker Builder & Pusher"]:::local
        SSH["SSH Deployment Module"]:::local
        Aux["Auxiliary/Example Configuration"]:::local
    end

    subgraph "Remote Production Server"
        direction TB
        RemoteDocker["Remote Server: Docker Containers"]:::remote
        Caddy["Caddy Reverse Proxy & HTTPS Manager"]:::remote
    end

    subgraph "External Services"
        direction TB
        Registry["Container Registry"]:::external
    end

    CLI -->|"triggers"| Config
    Config -->|"passesConfiguration"| Docker
    Config -->|"passesConfiguration"| SSH
    Docker -->|"builds&pushes"| Registry
    Registry -->|"deliversImages"| RemoteDocker
    SSH -->|"updatesContainers"| RemoteDocker
    SSH -->|"triggersConfigUpdate"| Caddy
    Config ---|"readsConfigFiles"| Aux

    click CLI "https://github.com/hoojinguyen/airo/blob/main/src/main.go"
    click Config "https://github.com/hoojinguyen/airo/blob/main/src/lib/config.go"
    click Aux "https://github.com/hoojinguyen/airo/tree/main/example"
    click Caddy "https://github.com/hoojinguyen/airo/tree/main/example/Caddyfile"

    classDef local fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef remote fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
