How abanoubha/gobrew works
Main architectural layers & components
a. Presentation (CLI) Layer
– Component: gobrew CLI (main.go)
– Responsibilities: parse command-line flags, dispatch commands (-l, -b, -s, -d, etc.)
b. Application / Service Layer
– Component: Command Dispatcher
• Maps each sub-command to a service function
– Component: Language/Build-System Service
• Orchestrates data fetch + parsing + aggregation
c. Domain / Business-Logic Layer
– Component: DataFetcher
• Fetches Homebrew Core formulae JSON (via GitHub API or raw Git)
– Component: FormulaParser
• Parses each formula’s metadata, extracts language, build-system, deps
– Component: Analyzer
• Aggregates counts by language, versions, build systems, dependencies
d. Infrastructure / Integration Layer
– External Service: GitHub / Homebrew Core repository
– External Service: Snap Store (for distribution)
– Packaging: snap/snapcraft.yaml → Snapcraft build pipeline
Relationships & data flow
– User invokes gobrew CLI → CLI Layer
– CLI Layer → Command Dispatcher (flags → service method)
– Dispatcher → Language/Build-System Service
– Service → DataFetcher → HTTP GETs to GitHub/Homebrew
– DataFetcher → returns raw formula JSON/data
– FormulaParser → transforms raw data into structured records
– Analyzer → computes counts, filters, sorts
– Service → OutputFormatter → prints results to stdout
– User sees results in terminal
– Snapcraft packaging → takes built binary → publishes to Snap Store
Architectural patterns & design principles
– Layered Architecture: clear separation of CLI, services, domain logic, infra
– Single-binary modular design: all modules compile into one executable
– Dependency Injection (via function parameters) for testability
– Use of Go Modules (go.mod) for dependency management
– Snap packaging keeps runtime isolated (confined Snap)
Important technologies & libraries
– Go standard library: flag (CLI), net/http (data fetch), encoding/json (parse)
– Go Modules: go.mod / go.sum
– Snapcraft: snap/snapcraft.yaml for packaging & publishing
– Homebrew Core repository (GitHub) as data source
Detail without over-splitting
– Show sub-components only if they have distinct responsibilities