How mochisuna/slack-reaction-award works
This project is a Go-based utility that calculates Slack reaction metrics and posts awards across four categories in your Slack workspace. The purpose is clearly outlined in the README, and the file tree reinforces a layered architecture that separates concerns into domain logic, application coordination, request handling, and configuration.
Main components
• Entry Point: The project entry is in cmd/app/main.go, which initializes and orchestrates the application.
• Application Layer: Located in the “application” directory, with files such as app.go, ranking.go, and slack.go. This layer acts as a coordinator between higher-level application flows and lower-level domain logic.
• Domain Layer: Found in the “domain” directory with files ranking.go and slack.go. This is where the core business logic resides – the rules and computations related to Slack reaction rankings.
• Handler Layer: The “handler” directory contains ranking.go and slack.go, which likely serve as adapters to handle incoming requests or events (for instance, formatting data from Slack or for posting messages).
• Configuration: The “config” directory (with config/config.go) is responsible for holding configuration data that the app uses, likely loaded at startup.
• Tools and Local Config: The _tools/local folder contains additional configuration (config.toml) needed to set Slack tokens, channels, and other runtime settings.
• External Service: Slack is a major external dependency, as the script interacts with Slack APIs (reading channels, posting messages, reading reactions, etc.).
Relationships and interactions
• The Entry Point (cmd/app/main.go) boots the application, reads configuration, and wires together the components.
• The Application Layer orchestrates the ranking calculations and Slack notifications by invoking methods from the Domain Layer.
• The Domain Layer encapsulates rules for computing awards based on Slack reaction counts (laughter, variety, amount, and thanks).
• The Handler Layer formats inputs and outputs. Although not a web server per se, handlers abstract input data from Slack and potentially convert responses for output into Slack messaging.
• The Config component is used by multiple layers to obtain necessary settings (like Slack token, channel IDs, and year) to call the Slack API.
• External Slack API is integrated via calls from both the Application and Domain layers (wrapped in “slack.go” files) to read reaction counts and to post messages.
Architectural patterns and design principles
• Layered Architecture: There is a clear separation into entry layer, application logic, domain business rules, and handlers.
• Separation of Concerns: Each directory or package handles distinct tasks (configuration, business logic, CLI tools, etc.).
• External Integration: The system uses clearly defined adapters to interact with external services (i.e., Slack API), respecting a separation between internal logic and external communication.