How jbrinkman/ghi works
Main Components
• CLI Interface: Represented by the main executable (main.go) and the individual command implementations found under the cmd/ directory (auth.go, pr/pullrequest.go, review.go, view.go).
• GitHub Client: The pkg/clients package (specifically pkg/clients/github.go) which handles communication with the GitHub API.
• GitHub Functionality: The pkg/github package encapsulates additional logic for processing, displaying, and formatting GitHub data.
• Database Interaction: The pkg/db package manages interactions with the Turso/LibSQL database used for tracking review history.
• Logging: The pkg/logger package provides logging functionality which is used by various commands to log debug information.
• External Services: The GitHub API and Turso/LibSQL database (set up via the auth commands) should be depicted as external systems interacting with your tool.
Relationships and Interactions
• When executing a command (e.g., pr, view, review, auth), the command layer invokes the corresponding functionality in the pkg/ packages.
• For example, the pr command leverages pkg/clients and pkg/github to fetch pull request data.
• The view command may optionally log the review actions through pkg/db, indicating an interaction with the database layer.
• The auth command specifically configures and interacts with the database settings by taking user input and updating/storing credentials.
• GitHub API – for fetching pull request details, filtering by author/reviewer.
• Turso/LibSQL – for persisting review logs as defined in the database schema provided in the README.
• The logging system is cross-cutting, capturing activities from all commands. The pkg/logger should have drawn connections to all parts that support the --debug functionality.
Architectural Patterns and Design Principles
• Modular design: Split into command handlers (in cmd/) and underlying business logic (in pkg/) for easier testing and maintenance.
• Separation of concerns: Distinct layers exist with CLI (command parsing and user interface), a client layer (API calls), data processing, and persistence (database).
• Extensibility: The design supports additional commands or external integrations (such as additional branches for GitHub data retrieval) without major rework.
Relevant Technologies and Frameworks
• Go as the programming language.
• GitHub API as the external web service.
• Turso/LibSQL as a local database solution for review logging.
• YAML for configuration files.
• GitHub Actions (visible in the .github/workflows directory) to handle CI/CD.