# melkeydev/go-blueprint architecture

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

- Interactive diagram: https://gitdiagram.com/melkeydev/go-blueprint
- Repository: https://github.com/melkeydev/go-blueprint

## Overview

##### Project type and purpose
- This is a standalone CLI tool (“go-blueprint”) written in Go.
- Its purpose is to generate scaffolded Go projects with optional integrations (HTTP frameworks, databases, advanced features) based on user input (flags or interactive UI).

##### Top-level architectural components
a. User Interface Layer
- CLI entry point (main.go + cmd/root.go)
- Interactive UI components (cmd/ui/*) for multi-input, multi-select, spinner, text input
- Flag definitions (cmd/flags/*)
b. Command Orchestration Layer
- Command handlers (cmd/create.go, cmd/steps/steps.go)
- Program logic (cmd/program/program.go, cmd/program/*)
- Global config (cmd/globalEnv.go, cmd/version.go)
c. Template Engine Layer
- Template definitions (cmd/template/*) organized by feature:
– Frameworks (cmd/template/framework/*)
– Database drivers (cmd/template/dbdriver/*)
– Advanced features (HTMX, CI/CD, React, Tailwind, Docker) (cmd/template/advanced/*)
- File templating logic (go’s text/template under the hood)
d. Utility Layer
- Common helpers and abstractions (cmd/utils/*)
e. Output Layer
- Filesystem operations to write project directories and files
- Git initialization (optional “--git commit” integration)

##### Relationships and data flows
1. User invokes `go-blueprint create [--flags]`
2. Root command parses flags, invokes interactive UI if needed
3. UI returns structured input (project name, framework, driver, advanced features)
4. Command orchestrator builds a plan (list of steps)
5. For each step:
a. Template Engine picks the right template based on input
b. Template is rendered with placeholders (project name, package names, imports)
c. Filesystem writer dumps the rendered files into a new project folder
d. Optionally invokes Git, Docker, or CI/CD setup routines
6. CLI reports success/failure

##### Architectural patterns and design principles
- Layered architecture: UI → Orchestration → Templating → I/O
- Single binary with clearly separated packages (cmd, ui, template, utils)
- Template-driven code generation (declarative file templates)
- Dependency inversion: high-level CLI logic depends on abstract template interfaces
- Modularity: each feature (framework, driver, advanced) is a self-contained subpackage

##### Essential elements
- Clear component names (cmd/root, cmd/create, cmd/ui, cmd/template/advanced, etc.)
- Notes on major external dependencies (Gin, Chi, Postgres, Mongo, Tailwind, React, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External User
    User["User"]:::external

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Main["main.go"]:::ui
        Root["cmd/root.go"]:::ui
        AF["advancedFeatures.go"]:::ui
        DBF["database.go"]:::ui
        FW["frameworks.go"]:::ui
        GF["git.go"]:::ui
        MI["multiInput.go"]:::ui
        MS["multiSelect.go"]:::ui
        SP["spinner.go"]:::ui
        TI["textinput.go"]:::ui
    end

    %% Orchestration Layer
    subgraph "Command Orchestration Layer"
        direction TB
        Create["cmd/create.go"]:::orchestration
        Steps["cmd/steps/steps.go"]:::orchestration
        Program["cmd/program/program.go"]:::orchestration
        GlobalEnv["cmd/globalEnv.go"]:::orchestration
        Version["cmd/version.go"]:::orchestration
    end

    %% Template Engine Layer
    subgraph "Template Engine Layer"
        direction TB
        subgraph "Advanced Features" 
            direction TB
            AdvLogic["docker.go\ngitHubAction.go\nroutes.go"]:::template
            AdvFiles["advanced/files"]:::template
        end
        subgraph "Database Drivers"
            direction TB
            Mongo["mongo.go"]:::template
            MySQL["mysql.go"]:::template
            Postgres["postgres.go"]:::template
            Redis["redis.go"]:::template
            Scylla["scylla.go"]:::template
            SQLite["sqlite.go"]:::template
            DBEnvFiles["files/env/*.tmpl"]:::template
            DBServiceFiles["files/service/*.tmpl"]:::template
            DBTestFiles["files/tests/*.tmpl"]:::template
        end
        subgraph "HTTP Frameworks"
            direction TB
            MainF["main.go"]:::template
            Gin["ginRoutes.go"]:::template
            Chi["chiRoutes.go"]:::template
            Echo["echoRoutes.go"]:::template
            Fiber["fiberServer.go"]:::template
            Gorilla["gorillaRoutes.go"]:::template
            HTTP["httpRoutes.go"]:::template
            Router["routerRoutes.go"]:::template
            FWFiles["files/**/*.tmpl"]:::template
        end
    end

    %% Utility Layer
    subgraph "Utility Layer"
        direction TB
        Utils["utils.go\nutils_test.go"]:::utils
    end

    %% Output Layer
    subgraph "Output Layer"
        direction TB
        FS["File System Writer"]:::output
        GitOpt["Git Init"]:::output
        DockerOpt["Docker Setup"]:::output
        CIOpt["CI/CD Setup"]:::output
        OutDir["New Project Output"]:::output
    end

    %% Flow
    User --> Main
    Main -->|parses flags| AF & DBF & FW & GF
    Main -->|invokes UI| MI & MS & SP & TI
    AF & DBF & FW & GF & MI & MS & SP & TI --> Create
    Create --> Steps
    Steps --> Program
    Program --> AdvLogic & AdvFiles & Mongo & MySQL & Postgres & Redis & Scylla & SQLite & DBEnvFiles & DBServiceFiles & DBTestFiles & MainF & Gin & Chi & Echo & Fiber & Gorilla & HTTP & Router & FWFiles
    Program --> Utils
    AdvLogic & AdvFiles & Mongo & MySQL & Postgres & Redis & Scylla & SQLite & DBEnvFiles & DBServiceFiles & DBTestFiles & MainF & Gin & Chi & Echo & Fiber & Gorilla & HTTP & Router & FWFiles --> FS
    FS --> OutDir
    FS -.-> GitOpt
    FS -.-> DockerOpt
    FS -.-> CIOpt
    OutDir --> User

    %% Click Events
    click Main "https://github.com/melkeydev/go-blueprint/blob/main/main.go"
    click Root "https://github.com/melkeydev/go-blueprint/blob/main/cmd/root.go"
    click AF "https://github.com/melkeydev/go-blueprint/blob/main/cmd/flags/advancedFeatures.go"
    click DBF "https://github.com/melkeydev/go-blueprint/blob/main/cmd/flags/database.go"
    click FW "https://github.com/melkeydev/go-blueprint/blob/main/cmd/flags/frameworks.go"
    click GF "https://github.com/melkeydev/go-blueprint/blob/main/cmd/flags/git.go"
    click MI "https://github.com/melkeydev/go-blueprint/blob/main/cmd/ui/multiInput/multiInput.go"
    click MS "https://github.com/melkeydev/go-blueprint/blob/main/cmd/ui/multiSelect/multiSelect.go"
    click SP "https://github.com/melkeydev/go-blueprint/blob/main/cmd/ui/spinner/spinner.go"
    click TI "https://github.com/melkeydev/go-blueprint/blob/main/cmd/ui/textinput/textinput.go"
    click Create "https://github.com/melkeydev/go-blueprint/blob/main/cmd/create.go"
    click Steps "https://github.com/melkeydev/go-blueprint/blob/main/cmd/steps/steps.go"
    click Program "https://github.com/melkeydev/go-blueprint/blob/main/cmd/program/program.go"
    click GlobalEnv "https://github.com/melkeydev/go-blueprint/blob/main/cmd/globalEnv.go"
    click Version "https://github.com/melkeydev/go-blueprint/blob/main/cmd/version.go"
    click AdvLogic "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/advanced/docker.go"
    click AdvLogic "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/advanced/gitHubAction.go"
    click AdvLogic "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/advanced/routes.go"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/advanced/files/docker/docker_compose.yml.tmpl"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/advanced/files/docker/dockerfile.tmpl"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/advanced/files/htmx"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/advanced/files/react"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/advanced/files/tailwind"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/advanced/files/websocket"
    click AdvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/advanced/files/workflow/github"
    click Mongo "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/mongo.go"
    click MySQL "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/mysql.go"
    click Postgres "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/postgres.go"
    click Redis "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/redis.go"
    click Scylla "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/scylla.go"
    click SQLite "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/dbdriver/sqlite.go"
    click DBEnvFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/dbdriver/files/env"
    click DBServiceFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/dbdriver/files/service"
    click DBTestFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/dbdriver/files/tests"
    click MainF "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/main.go"
    click Gin "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/ginRoutes.go"
    click Chi "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/chiRoutes.go"
    click Echo "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/echoRoutes.go"
    click Fiber "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/fiberServer.go"
    click Gorilla "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/gorillaRoutes.go"
    click HTTP "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/httpRoutes.go"
    click Router "https://github.com/melkeydev/go-blueprint/blob/main/cmd/template/framework/routerRoutes.go"
    click FWFiles "https://github.com/melkeydev/go-blueprint/tree/main/cmd/template/framework/files"
    
    %% Styles
    classDef external fill:#ddd,stroke:#333,stroke-width:1px;
    classDef ui fill:#c6f6d5,stroke:#2f855a,stroke-width:2px;
    classDef orchestration fill:#bee3f8,stroke:#2b6cb0,stroke-width:2px;
    classDef template fill:#fed7aa,stroke:#dd6b20,stroke-width:2px;
    classDef utils fill:#faf089,stroke:#d69e2e,stroke-width:2px;
    classDef output fill:#e2e8f0,stroke:#4a5568,stroke-width:2px;
```
