How melkeydev/go-blueprint works
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.)