# armdng/kiyohime_go architecture

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

- Interactive diagram: https://gitdiagram.com/armdng/kiyohime_go
- Repository: https://github.com/armdng/kiyohime_go

## Overview

##### Project type and purpose
- This is a single‐service, monolithic Go application (“kiyohime_go”) that implements a Discord Bot using the discordgo library.
- It connects to Discord’s Gateway via WebSockets, listens for incoming events, and responds (for example, by fetching and displaying user avatars).
- It is containerized via a multi‐stage Docker build and has a GitHub Actions workflow for building/publishing.

##### File structure
- Top‐level Go module files (go.mod, go.sum) and main.go: the entire source code lives in main.go (no nested “src/” or “cmd/” folders).
- Dockerfile and .dockerignore: defines how to build and containerize the bot using a multi‐stage build.
- .github/workflows/docker.yml: CI pipeline that builds and pushes the Docker image.
- README.md: describes usage, environment variables, and build steps.

##### README for additional insights
- Dependencies: only discordgo (github.com/bwmarrin/discordgo).
- Runtime configuration via two environment variables: DISCORD_TOKEN and RMCMD.
- Docker usage and build instructions are provided.

##### Detail without over‐fragmentation
- Interactions: user → gateway → bot → gateway → user, plus build/deploy via CI → registry → container host.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    Users["Discord Users"]:::external
    DiscordGateway["Discord Gateway/API"]:::external

    %% Internal Service
    subgraph "Kiyohime Bot Service" 
        direction TB
        BotConfig["Configuration Loader\n(env: DISCORD_TOKEN, RMCMD)"]:::internal
        EventLoop["Event Handling Loop"]:::internal
        RestClient["Discord REST Client"]:::internal
        MainGo["main.go"]:::internal
        GoMod["go.mod"]:::internal
        GoSum["go.sum"]:::internal
    end

    %% Infrastructure
    subgraph "Docker Container" 
        direction TB
        DockerfileNode["Dockerfile\n(multi-stage build)"]:::infra
        Dockerignore[".dockerignore"]:::infra
    end

    subgraph "CI/CD Pipeline" 
        direction TB
        GitHubActions["GitHub Actions\n(docker.yml)"]:::infra
    end

    Documentation["README.md"]:::infra

    %% Data Flows
    Users -->|"User Message / Slash Command"| DiscordGateway
    DiscordGateway -->|"WebSocket Event"| EventLoop
    EventLoop -->|"Process Event"| RestClient
    RestClient -->|"FetchAvatar REST Call"| DiscordGateway
    DiscordGateway -->|"Event Response"| Users

    %% Deployment Flows
    GitHubActions -->|"Trigger on Push"| DockerfileNode
    DockerfileNode -->|"Build & Publish Image"| DockerContainer
    DockerContainer -->|"Runs Bot Service"| BotConfig

    Documentation -.->|"Docs & Usage"| BotConfig

    %% Click Events
    click MainGo "https://github.com/armdng/kiyohime_go/blob/master/main.go"
    click GoMod "https://github.com/armdng/kiyohime_go/blob/master/go.mod"
    click GoSum "https://github.com/armdng/kiyohime_go/blob/master/go.sum"
    click DockerfileNode "https://github.com/armdng/kiyohime_go/tree/master/Dockerfile"
    click Dockerignore "https://github.com/armdng/kiyohime_go/blob/master/.dockerignore"
    click GitHubActions "https://github.com/armdng/kiyohime_go/blob/master/.github/workflows/docker.yml"
    click Documentation "https://github.com/armdng/kiyohime_go/blob/master/README.md"

    %% Styles
    classDef external fill:#D0EFFF,stroke:#036,stroke-width:1px
    classDef internal fill:#DFF5E1,stroke:#27632A,stroke-width:1px
    classDef infra fill:#F0F0F0,stroke:#666,stroke-width:1px
```
