# iamgabs/database-composer architecture

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

- Interactive diagram: https://gitdiagram.com/iamgabs/database-composer
- Repository: https://github.com/iamgabs/database-composer

## Overview

##### Main Components
- Application Core: The Go-based CLI/TUI that is defined by main.go (and its dependencies via go.mod/go.sum). This is the control layer where users interact.
- Build Artifacts: The pre-built binaries in the build/ directory for different platforms, indicating cross-platform support.
- Docker Configurations: Each subdirectory within docker-configs represents a specific database engine, with further segmentation by version. These files (docker-compose.yml) are used by the tool to launch the appropriate database container.
- External Dependencies: Docker and Docker Compose. These are external services that the tool depends on to actually spin up database containers.

##### Relationships and Interactions
- User Interaction: The user launches the binary (from build/ or after building from source) and is greeted with a TUI.
- Input & Selection: Through the TUI, the user chooses the desired database engine and version.
- Command Execution: Upon selection, the tool uses the docker-compose configuration files (from docker-configs) to execute “docker compose up”, thereby starting the corresponding Docker container.
- Feedback: Docker (and Docker Compose) handles the instantiation and management of the containerized database instance, with the tool providing status or logs via the CLI.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates the application’s interface (CLI/TUI) from its infrastructure (Docker Compose configurations). The Go application focuses on user input and orchestration.
- Modularity: The use of distinct directories for docker configurations per database engine and version promotes modularity and easy extensibility.
- Cross-Platform Build Strategy: The presence of pre-built binaries for different operating systems (Linux, macOS, Windows) underlines a focus on broad compatibility.
- Containerization: Emphasis on using Docker Compose to manage the lifecycle of external DB services encourages a microservices-like decoupling between the application core and the database layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external
    CLI_TUI["CLI/TUI – DB Composer Application"]:::app
    BuildArtifacts["Build Artifacts (Pre-built Binaries)"]:::build
    DockerCompose["Docker Compose Controller"]:::app
    DockerEngine["Docker Engine / Container Instances"]:::external

    subgraph "Database Configurations"
        PostgreSQL["PostgreSQL Configs"]:::config
        MySQL["MySQL Configs"]:::config
        MariaDB["MariaDB Configs"]:::config
        SQLServer["SQL Server Configs"]:::config
        Oracle["Oracle Configs"]:::config
        MongoDB["MongoDB Configs"]:::config
    end

    User -->|"launches"| CLI_TUI
    CLI_TUI -->|"uses"| BuildArtifacts
    CLI_TUI -->|"sends_command"| DockerCompose

    DockerCompose -->|"selects_config"| PostgreSQL
    DockerCompose -->|"selects_config"| MySQL
    DockerCompose -->|"selects_config"| MariaDB
    DockerCompose -->|"selects_config"| SQLServer
    DockerCompose -->|"selects_config"| Oracle
    DockerCompose -->|"selects_config"| MongoDB

    PostgreSQL -->|"deploys_to"| DockerEngine
    MySQL -->|"deploys_to"| DockerEngine
    MariaDB -->|"deploys_to"| DockerEngine
    SQLServer -->|"deploys_to"| DockerEngine
    Oracle -->|"deploys_to"| DockerEngine
    MongoDB -->|"deploys_to"| DockerEngine

    click CLI_TUI "https://github.com/iamgabs/database-composer/blob/main/main.go"
    click BuildArtifacts "https://github.com/iamgabs/database-composer/tree/main/build/"
    click PostgreSQL "https://github.com/iamgabs/database-composer/tree/main/docker-configs/PostgreSQL/"
    click MySQL "https://github.com/iamgabs/database-composer/tree/main/docker-configs/MySQL/"
    click MariaDB "https://github.com/iamgabs/database-composer/tree/main/docker-configs/MariaDB/"
    click SQLServer "https://github.com/iamgabs/database-composer/tree/main/docker-configs/SQL Server/"
    click Oracle "https://github.com/iamgabs/database-composer/tree/main/docker-configs/Oracle/"
    click MongoDB "https://github.com/iamgabs/database-composer/tree/main/docker-configs/MongoDB/"

    classDef app fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef build fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef config fill:#F0E68C,stroke:#000,stroke-width:1px;
    classDef external fill:#98FB98,stroke:#000,stroke-width:1px;
```
