# rie03p/discord-weather-notification architecture

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

- Interactive diagram: https://gitdiagram.com/rie03p/discord-weather-notification
- Repository: https://github.com/rie03p/discord-weather-notification

## Overview

##### Components Identification
- AWS Infrastructure: Show AWS Lambda as the core compute component, and AWS EventBridge as the scheduler that triggers the Lambda function.
- Application Modules: Within the Lambda, illustrate separate internal packages:
– Weather Module (lambda/internal/weather/weather.go) to fetch/process weather forecast data.
– Discord Module (lambda/internal/discord/discord.go) to handle notification sending through the Discord Webhook.
- External Systems: Represent Discord as an external system receiving webhook notifications.
- Infrastructure Management: Include Terraform (with its main.tf and variables.tf files) as the provisioning and configuration tool that sets up the Lambda, EventBridge, and potentially other AWS resources.
- Build & Deployment: Optionally mention the make.sh script used for build, package, and deployment processes.

##### Interactions and Data Flow
- Within Lambda, show a flow where the entry point (lambda/main.go) calls the handler (lambda/handler/handler.go) which then selectively invokes:
- The Weather component (for data retrieval) and then,
- The Discord component (for sending notifications) if rain is forecast.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        EB["AWS EventBridge<br/>(Triggered at 7:00AM JST)"]:::aws
    end

    %% AWS Lambda Function with internal processing
    subgraph "AWS Lambda Function"
        direction TB
        Main["Entry Point: main.go"]:::internal
        Handler["Handler: handler.go"]:::internal
        Weather["Weather Module"]:::internal
        Discord["Discord Module"]:::internal
    end

    %% External Systems
    subgraph "External Systems"
        DiscordEndpoint["Discord Webhook"]:::external
    end

    %% Infrastructure Management using Terraform
    subgraph "Infrastructure Management"
        direction TB
        TMain["Terraform: main.tf"]:::terraform
        TVariables["Terraform: variables.tf"]:::terraform
    end

    %% Build & Deployment Pipeline
    BuildPipeline["Build Pipeline: make.sh"]:::build

    %% Connections
    EB -->|"triggers"| Main
    Main -->|"calls"| Handler
    Handler -->|"invokes"| Weather
    Weather -->|"ifRainForecast"| Discord
    Discord -->|"sendsNotification"| DiscordEndpoint

    TMain -->|"configures"| EB
    TMain -->|"configures"| Main
    TVariables -->|"configures"| EB
    TVariables -->|"configures"| Main

    BuildPipeline -->|"deploys"| Main

    %% Click Events
    click Main "https://github.com/rie03p/discord-weather-notification/blob/master/lambda/main.go"
    click Handler "https://github.com/rie03p/discord-weather-notification/blob/master/lambda/handler/handler.go"
    click Weather "https://github.com/rie03p/discord-weather-notification/blob/master/lambda/internal/weather/weather.go"
    click Discord "https://github.com/rie03p/discord-weather-notification/blob/master/lambda/internal/discord/discord.go"
    click TMain "https://github.com/rie03p/discord-weather-notification/blob/master/terraform/main.tf"
    click TVariables "https://github.com/rie03p/discord-weather-notification/blob/master/terraform/variables.tf"
    click BuildPipeline "https://github.com/rie03p/discord-weather-notification/blob/master/make.sh"

    %% Styles
    classDef aws fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef internal fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef external fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef terraform fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
    classDef build fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
```
