# cluedtke/discord-bot-once-human-codes architecture

> Architecture diagram of the GitHub repository cluedtke/discord-bot-once-human-codes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cluedtke/discord-bot-once-human-codes
- Repository: https://github.com/cluedtke/discord-bot-once-human-codes

## Overview

##### AWS Services Layer
- AWS Lambda (Primary compute service)
- CloudWatch Events/EventBridge (Trigger mechanism)
- S3 (likely used for Lambda deployment)

##### External Services Layer
- Steam Discussions (Data source)
- Discord Webhook (Output destination)

##### Component Relationships
- CloudWatch Event → Lambda (triggering)
- Lambda → Steam Discussions (scraping)
- Lambda → Discord Webhook (posting)

##### Additional Details
Annotations for:
- CloudWatch cron schedule (daily trigger)
- Lambda function name and runtime (Python)

**[CloudWatch Events] --triggers--> [Lambda Function]**

- scrapes
- v
- [Steam Discussions]

- extracts codes
- v
- [Discord Webhook]

Important Considerations:

##### Infrastructure as Code
- A note that the infrastructure is managed via Terraform
- Configuration files (terraform/*.tf) influence on resource creation

##### Security and Access
- IAM roles and permissions if applicable
- Secure webhook communication

##### State Management
- If any state needs to be maintained between runs, indicate storage mechanism

Level of Detail:
- Timing indicators for the scheduled execution

Remember to:
- Use clear labels for all components
- A title and brief description
- Deployment method (Terraform)
- Document any environment variables or configuration requirements

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AWS["AWS Cloud"]
        direction TB
        subgraph Terraform["Infrastructure as Code (Terraform)"]
            direction TB
            TF_MAIN["Main Configuration"]
            TF_LAMBDA["Lambda Configuration"]
            TF_S3["S3 Configuration"]
        end

        CW[("CloudWatch Events<br/>Daily Trigger")]
        LAMBDA["AWS Lambda Function<br/>(Python Runtime)"]
        S3["S3 Bucket"]
    end

    STEAM["Steam Discussions<br/>(Data Source)"]
    DISCORD["Discord Webhook<br/>(Notification Destination)"]

    %% Relationships
    CW -->|"Triggers"| LAMBDA
    LAMBDA -->|"Scrapes"| STEAM
    LAMBDA -->|"Posts Updates"| DISCORD
    S3 -.->|"Stores"| LAMBDA

    %% Infrastructure Relationships
    TF_MAIN -.->|"Configures"| AWS
    TF_LAMBDA -.->|"Defines"| LAMBDA
    TF_S3 -.->|"Provisions"| S3

    %% Click Events
    click LAMBDA "https://github.com/cluedtke/discord-bot-once-human-codes/blob/main/lambda.py"
    click TF_LAMBDA "https://github.com/cluedtke/discord-bot-once-human-codes/blob/main/terraform/lambda.tf"
    click TF_S3 "https://github.com/cluedtke/discord-bot-once-human-codes/blob/main/terraform/s3.tf"
    click TF_MAIN "https://github.com/cluedtke/discord-bot-once-human-codes/blob/main/terraform/main.tf"

    %% Styling
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef external fill:#gray,stroke:#333,color:black
    classDef terraform fill:#844FBA,stroke:#333,color:white
    
    class CW,LAMBDA,S3 aws
    class STEAM,DISCORD external
    class TF_MAIN,TF_LAMBDA,TF_S3 terraform

    %% Legend
    subgraph Legend
        L1["AWS Service"]:::aws
        L2["External Service"]:::external
        L3["Terraform Config"]:::terraform
    end
```
