# sathiya-mit/go-slack-interactive architecture

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

- Interactive diagram: https://gitdiagram.com/sathiya-mit/go-slack-interactive
- Repository: https://github.com/sathiya-mit/go-slack-interactive

## Overview

##### Project type and purpose
- This is a small, single-binary Slack interactive‐message bot written in Go.
- It listens for Slack interactive message callbacks, processes the payload, and posts or updates messages back to Slack via the Slack Web API.
- It can run locally (with ngrok tunneling) or be containerized (Docker) and deployed via Cloud Build (cloudbuild.yaml).

##### File structure
- Top‐level files:
- main.go – entry point, starts HTTP server
- handler.go – HTTP handler for Slack events
- slack.go – wrapper functions for calling Slack Web API
- Dockerfile & cloudbuild.yaml – container build and CI/CD
- Gopkg.toml / Gopkg.lock – dependency management
- handler.go, slack.go, main.go – comprise the core application
- README.md – usage instructions
- No database or persistent store—state is ephemeral or encoded in messages.
- Configuration is via environment variables (BOT_ID, BOT_TOKEN, VERIFICATION_TOKEN, CHANNEL_ID).

##### README for additional insights
- Environment variables required for Slack authentication and channel scoping.
- Local development via ngrok for public HTTP endpoint.
- Production deployment implied by Docker and cloudbuild.yaml (likely to GCP services such as Cloud Run or GKE).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Code Repository
    subgraph "Code Repository"
        direction TB
        RepoCode["Git Repository"]:::code
        MainGo["main.go"]:::code
        HandlerGo["handler.go"]:::code
        SlackGo["slack.go"]:::code
        Dockerfile["Dockerfile"]:::code
        Cloudbuild["cloudbuild.yaml"]:::code
        GopkgToml["Gopkg.toml"]:::code
        GopkgLock["Gopkg.lock"]:::code
        Readme["README.md"]:::code
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        CloudBuild["Cloud Build"]:::ci
    end

    %% Container Registry
    ContainerRegistry["Container Registry"]:::registry

    %% Production Hosting
    DeployedService["Cloud Run / GKE Service\n(Env Vars: BOT_ID, BOT_TOKEN,\nVERIFICATION_TOKEN, CHANNEL_ID)"]:::service

    %% Local Development
    subgraph "Local Development"
        direction TB
        DevMachine["Developer Machine"]:::local
        Ngrok["ngrok Tunnel"]:::local
        LocalServer["Local HTTP Server\n(main.go → handler.go)"]:::local
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SlackInteractive["Slack Interactive Messages"]:::external
        SlackAPI["Slack Web API"]:::external
    end

    %% Relationships
    RepoCode -->|push code| CloudBuild
    CloudBuild -->|build Docker image| ContainerRegistry
    ContainerRegistry -->|deploy image| DeployedService
    SlackInteractive -->|HTTP POST Callback| DeployedService
    DeployedService -->|verify token, parse payload| HandlerGo
    HandlerGo -->|call wrapper| SlackGo
    SlackGo -->|chat.postMessage/updateMessage| SlackAPI
    SlackAPI -->|response| SlackGo

    %% Local flow (dashed)
    SlackInteractive -.->|HTTP POST to ngrok URL| Ngrok
    Ngrok -->|tunnel to| LocalServer
    LocalServer -->|process same as prod| SlackGo

    %% Code components usage in service
    DeployedService --> MainGo
    DeployedService --> HandlerGo
    DeployedService --> SlackGo

    %% Click Events
    click MainGo "https://github.com/sathiya-mit/go-slack-interactive/blob/master/main.go"
    click HandlerGo "https://github.com/sathiya-mit/go-slack-interactive/blob/master/handler.go"
    click SlackGo "https://github.com/sathiya-mit/go-slack-interactive/blob/master/slack.go"
    click Dockerfile "https://github.com/sathiya-mit/go-slack-interactive/tree/master/Dockerfile"
    click Cloudbuild "https://github.com/sathiya-mit/go-slack-interactive/blob/master/cloudbuild.yaml"
    click GopkgToml "https://github.com/sathiya-mit/go-slack-interactive/blob/master/Gopkg.toml"
    click GopkgLock "https://github.com/sathiya-mit/go-slack-interactive/blob/master/Gopkg.lock"
    click Readme "https://github.com/sathiya-mit/go-slack-interactive/blob/master/README.md"

    %% Styles
    classDef code fill:#D6EAF8,stroke:#3498DB
    classDef ci fill:#FCF3CF,stroke:#F1C40F
    classDef registry fill:#D5F5E3,stroke:#27AE60
    classDef service fill:#EBDEF0,stroke:#8E44AD
    classDef external fill:#FDEBD0,stroke:#E67E22
    classDef local fill:#F2F3F4,stroke:#85929E
```
