How muandane/goji works
Project Type and Purpose
• goji is a command-line tool that streamlines the git-commit process by providing an interactive text UI (TUI) for selecting commit types, scopes, and descriptions.
• Its purpose is to enforce conventional commit message formats with a playful twist (using emojis) and integrate seamlessly with git workflows and pre-commit hooks.
File Structure
• Top-level Directories and Files:
• .github: Contains configurations for CI workflows (e.g., release process, code coverage, pull requests, issue templates) which hints at robust development and release practices.
• cmd: Houses the main command-line entrypoints (like check.go, completion.go, init.go, man.go, root.go) – this is the interactive CLI layer.
• pkg: Divided into sub-directories such as config (for configuration initialization, reading and tests) and models (for commit type definitions), as well as utils (a helper for interactive questions).
• public: Contains assets (a GIF and logo) for the README/demo.
• Other files like go.mod, main.go, and build scripts (default.nix, scripts for generating completions and manpages) point to standard Go practices.
• Architectural Implications:
• The separation between the cmd directory and the pkg (with its submodules) suggests modular design. The cmd layer handles CLI command routing and the pkg layer contains the business logic (configuration, commit message models, and utilities).
Readme Insights
• The README explains the tool’s interactive mode vs. non-interactive command-line options, pre-commit integration (especially the “check” command) and customization via a JSON config file (.goji.json).
• You find clear instructions for users on how to install, build, and run the tool, but also how the tool integrates with git, which is essential for representing the system’s external interactions.
a. Main Components:
• CLI/TUI Interface Component:
• Represents the interactive command line interface (cmd/* source files).
• Handles user input, menu selection (commit type, scope, description), and option flags.
• Core Logic/Business Layer:
• Aggregates functionality from pkg/config, pkg/models, and pkg/utils.
• Manages reading and parsing of configuration files (.goji.json), initializing default settings, and controlling the commit message formatting process.
• Git Integration Component:
• Involves commands like “check” in cmd/check.go which validate commit messages against conventional commit rules.
• Integration instructions in the README for using goji with pre-commit hooks.
• External Interfaces:
• Pre-commit hooks integration (embedded in .github workflows and in the usage examples).
• System calls for git operations (based on flags like --add, --amend, etc.)
b. Relationships and Interactions:
• The CLI component (command handlers) receives user input and routes commands.
• It invokes the Core Logic which, using configurations (from pkg/config), the commit message models (pkg/models), and utility functions (pkg/utils), builds and formats the commit message.
• The final commit message is then passed to git (or checked when running the “check” command).
• There are interactions between the configuration component (which reads .goji.json) and the TUI (which uses the configuration to display options).
• The system also interacts with the file system (for config file management) and the git process (for commit message verification and creation).
c. Architectural Patterns and Design Principles:
• Separation of Concerns:
• The design clearly separates the user interface (cmd) from business logic (pkg).
• Modular Design:
• Each package (config, models, utils) encapsulates a specific part of the functionality.
• Testability:
• Presence of test files (e.g., *_test.go in both cmd and pkg folders) indicates a design aimed at unit testing.
• Extensibility:
• The configuration-driven approach (custom JSON file) enables easy customization and future extensibility.
d. Relevant Technologies, Frameworks, or Libraries:
• Go Programming Language: Used to build the CLI.
• Git: External dependency for commit management.
• GitHub Actions: For CI/CD and release processes (as seen in .github workflows).
• Pre-commit hooks: For validating commit messages.
Elements
• From the user to the CLI.
• From the CLI to the underlying configuration and logic layers.
• From those layers to the git interface.