# nezumisannn/goemon architecture

> Architecture diagram of the GitHub repository nezumisannn/goemon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nezumisannn/goemon
- Repository: https://github.com/nezumisannn/goemon

## Overview

##### Project Type and Purpose
- Project Type: A standalone command-line application.
- Purpose: To monitor AWS maintenance events using specified AWS credentials/configurations and notify a chat (like Chatwork) when events occur. The functionality is invoked via CLI commands (e.g., “check” and “help”) with a YAML configuration guiding its behavior.

##### File Structure
- Key Files and Directories:
- main.go – The main entry point of the application.
- cmd directory – Contains command implementations (e.g., check.go and root.go) where command-line parsing and execution is handled.
- goemon directory – Likely includes core logic (e.g., goemon/check.go) that performs the AWS event checking and notification work.
- example.config.yaml – Provides an example configuration to illustrate required fields like notification mechanism, AWS region, profiles, and chat settings.
- The structure reveals a separation between command line interface code and core business logic, which is typical for a CLI tool.

##### Main Components
a. CLI Interface Component
- Represented by the main.go entry point and the cmd package.
- Handles parsing of commands and flags (including the “help” and “check” commands).
b. Configuration Loader/Parser
- Reads the YAML configuration file (example.config.yaml) that specifies details for AWS connections, role assumptions, and notification methods.
c. AWS Maintenance Events Checker
- Core logic (in goemon package or within “cmd/check.go”) that interacts with AWS APIs to retrieve maintenance events.
- Handles AWS-specific components such as region, profile, and role assumptions.
d. Notification Module
- Deals with notifying external chat services such as Chatwork as defined in the configuration file.
- It encapsulates the logic to format and send notifications based on the retrieved events.
e. External Services/Dependencies
- AWS API (for both EC2 and RDS maintenance events).
- Chat Service API (Chatwork API) used for sending out notifications.

##### Interactions and Data Flow
- Once loaded, the configuration is provided to the AWS Maintenance Events Checker, which communicates with the AWS API (annotate this external dependency).
- After checking for maintenance events, the AWS Checker forwards relevant event data to the Notification Module.
- The Notification Module then sends the notifications to the external chat service (e.g., Chatwork), which is another external component.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Different components (CLI parsing, configuration, AWS interaction, and notification) discretely handle responsibilities.
- Modularity: Each component is loosely coupled, facilitating potential future extensions (e.g., adding more notification channels or additional AWS resource checks).
- Clear Data Flow: The pathway from command invocation to configuration loading, event checking, and notification dispatch is straightforward and easy to follow.

- CLI Interface Component (main.go and cmd package)
- Configuration Loader/Parser
- AWS Maintenance Event Checker
- Notification Module (with Chatwork specifics)
- External dependencies marked for AWS and Chat service
- CLI Command → Config Loader → AWS Checker → Notification Module → External Chat Service
- Optional: Error handling or feedback loops (if such components exist in the code)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Interface Subgraph
    subgraph "CLI Interface"
        A["main.go"]:::internal
        B["cmd/root.go"]:::internal
        C["cmd/check.go"]:::internal
    end

    %% Other Internal Components
    D["Config Loader (example.config.yaml)"]:::internal
    E["AWS Event Checker"]:::internal
    F["Notification Module"]:::internal

    %% External Dependencies
    G["AWS API"]:::external
    H["Chat Service (Chatwork)"]:::external

    %% Data Flow Connections
    C -->|"invokes"| D
    D -->|"loads-config"| E
    E -->|"checks-events"| F
    E -->|"calls"| G
    F -->|"sends notification"| H
    G -- "error-feedback" --> E
    H -- "response-feedback" --> F

    %% Click Events
    click A "https://github.com/nezumisannn/goemon/blob/master/main.go"
    click B "https://github.com/nezumisannn/goemon/blob/master/cmd/root.go"
    click C "https://github.com/nezumisannn/goemon/blob/master/cmd/check.go"
    click D "https://github.com/nezumisannn/goemon/blob/master/example.config.yaml"
    click E "https://github.com/nezumisannn/goemon/blob/master/goemon/check.go"
    click F "https://github.com/nezumisannn/goemon/blob/master/cmd/check.go"

    %% Styles
    classDef internal fill:#BBE1FA,stroke:#1B75BB,stroke-width:2px;
    classDef external fill:#FAD4D4,stroke:#BB1B1B,stroke-width:2px;
```
