Architecture¶
Design Goal¶
Keep the code simple, testable, and easy to grow.
The main rule is: the CLI should stay thin.
Main Layers¶
CLI Layer¶
This layer turns user input into application calls.
Responsibilities:
- parse commands and flags
- show help and usage
- normalize simple input such as ticket ID or path
- call the right service
- choose human or JSON output
- return exit codes
Main packages:
cmd/giginternal/cli
Service Layer¶
This layer contains the real use cases.
Responsibilities:
- scan workspaces
- find ticket commits
- compare branches
- inspect a ticket across repos
- evaluate environment status
- build read-only verification and promotion plans
Main packages:
internal/repointernal/ticketinternal/diffinternal/inspectinternal/plan
Domain Layer¶
This layer holds the shared shapes the rest of the code works with.
Examples:
- repository info
- commit refs
- branch comparison results
- risk signals
- environment status
- promotion plan and verification results
Main locations today:
internal/scminternal/inspectinternal/plan
Adapter Layer¶
This layer talks to external tools such as Git.
Responsibilities:
- detect repos
- resolve branch names
- search commits
- compare branches
- inspect files changed by a commit
Main packages:
internal/scm/gitinternal/scm/svn
Request Flow¶
- CLI reads the command and flags.
- The scanner turns the path into one or more repositories.
- The service chooses the correct adapter for each repo.
- The adapter runs SCM-specific queries.
- The output package renders the result for terminal or JSON.
Why This Design Works¶
- each layer has one clear job
- Git details do not leak into the CLI
- new output formats can reuse the same service results
- future integrations can be added without rewriting the commands