How iamgabs/database-composer works
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.