# vitwit/authz-apps architecture

> Architecture diagram of the GitHub repository vitwit/authz-apps, 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/vitwit/authz-apps
- Repository: https://github.com/vitwit/authz-apps

## Overview

##### Project Type and Purpose
- This is a multi-component suite:
- governance-ui: a static React single-page-app for displaying “Authz” content.
- voting-bot: a backend service (Slack bot) in Go for automating on-chain governance tasks (proposals, balances, withdraw rewards) and posting to Slack.

##### File Structure
- Top level splits into two subprojects:
├ governance-ui/ …standard React folder layout (public, src, package.json)
└ voting-bot/ …Go modules: config, database, endpoints, handler, jobs, keyring, voting, utils, main.go, tests
- Config & secrets: governance-ui/.env; voting-bot/example.config.toml & .env for tests
- Build/CI: governance-ui uses npm/yarn; voting-bot has Makefile + GitHub Actions pipeline

##### Extract Additional Insights from README
- The root README simply says “Authz applications” but each subproject has its own README documenting how to run it.

a. Frontend:
- governance-ui (React app)
- Static hosting or CDN layer
b. Backend Service:
- voting-bot (Go application)
– Config & keyring module
– Database (SQLite)
– Jobs scheduler (authz, proposals, balances, withdraw_rewards)
– HTTP API endpoints & handler
– Slack client integration
c. External Systems:
- Slack API (for sending messages)
- Blockchain RPC/GRPC endpoint (Cosmos chain)
- GitHub Actions (CI/CD)

##### Relationships & Data Flows
- governance-ui → (HTTP/REST or direct static assets) ←– user’s browser
- voting-bot jobs → poll Blockchain → write/read SQLite → produce Slack notifications → Slack API
- voting-bot HTTP endpoints (apiHandler) can serve data to UIs or other services (optional)
- CI/CD workflow pushes new versions of both governance-ui and voting-bot

##### Architectural Patterns & Design Principles
- Clear separation of concerns: UI vs. backend vs. data store
- Modular Go code:
– config-driven design (example.config.toml)
– dependency injection via custom config structs
– database layer abstracted behind authz.go/sqlite.go
– job scheduler triggering at intervals
- Frontend: component-based React (TopSection, CustomCard, CardList, etc.)

##### Technologies & Frameworks
- Frontend: React, Create React App toolchain, CSS modules
- Backend: Go modules, SQLite, TOML config, Slack SDK
- DevOps: GitHub Actions, Makefile, .env

##### Final Touches
- You capture *all* critical modules (config, keyring, jobs, db, endpoints).
- Left lane: User + governance-ui
- Middle lane: voting-bot internals
- Right lane: External systems

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        user("User's Browser"):::external
        govUI["governance-ui"]:::ui
        user -->|loads UI| govUI
    end

    subgraph "governance-ui"
        App["App.js"]:::ui
        Index["index.js"]:::ui
        HTML["index.html"]:::ui
        Env[".env"]:::ui
        Package["package.json"]:::ui
        subgraph Components
            CardList["CardList.js"]:::ui
            CustomCard["CustomCard.js"]:::ui
            Data["Data.js"]:::ui
            MainPage["MainPage.js"]:::ui
            Screenshot["Screenshot.js"]:::ui
            Text["Text.js"]:::ui
            TopSection["TopSection.js"]:::ui
        end
    end

    subgraph "Backend Service Layer"
        vb["voting-bot"]:::backend
        subgraph "Core Modules"
            main["main.go"]:::backend
            configMod["Config Module"]:::backend
            keyringMod["Keyring Module"]:::backend
            dbLayer["Database Layer"]:::db
            jobsMod["Jobs Scheduler"]:::backend
            apiEndpoints["HTTP Endpoints"]:::backend
            handler["API Handler"]:::backend
            clientMod["Slack Client"]:::backend
            typesMod["Types Definitions"]:::backend
            utilsMod["Utilities"]:::backend
            votingMod["Voting Logic"]:::backend
        end
    end

    subgraph "External Systems"
        SlackAPI["Slack API"]:::external
        Blockchain["Blockchain RPC/GRPC"]:::external
    end

    subgraph "CI/CD Pipeline"
        ci["GitHub Actions / Makefile"]:::cicd
    end

    govUI --- vb
    vb -->|polls| Blockchain
    vb -->|reads/writes| dbLayer
    vb -->|posts messages| SlackAPI
    vb -->|optional API serve| govUI
    ci --> govUI
    ci --> vb

    click govUI "https://github.com/vitwit/authz-apps/tree/main/governance-ui/"
    click App "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/App.js"
    click Index "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/index.js"
    click HTML "https://github.com/vitwit/authz-apps/blob/main/governance-ui/public/index.html"
    click Env "https://github.com/vitwit/authz-apps/blob/main/governance-ui/.env"
    click Package "https://github.com/vitwit/authz-apps/blob/main/governance-ui/package.json"
    click CardList "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/CardList.js"
    click CustomCard "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/CustomCard.js"
    click Data "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/Data.js"
    click MainPage "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/MainPage.js"
    click Screenshot "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/Screenshot.js"
    click Text "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/Text.js"
    click TopSection "https://github.com/vitwit/authz-apps/blob/main/governance-ui/src/components/TopSection.js"

    click vb "https://github.com/vitwit/authz-apps/tree/main/voting-bot/"
    click main "https://github.com/vitwit/authz-apps/blob/main/voting-bot/main.go"
    click configMod "https://github.com/vitwit/authz-apps/blob/main/voting-bot/config/config.go"
    click vb_example "https://github.com/vitwit/authz-apps/blob/main/voting-bot/example.config.toml"
    click test_env "https://github.com/vitwit/authz-apps/blob/main/voting-bot/tests/.env"
    click keyringMod "https://github.com/vitwit/authz-apps/blob/main/voting-bot/keyring/keys.go"
    click dbLayer "https://github.com/vitwit/authz-apps/tree/main/voting-bot/database/"
    click dbAuthz "https://github.com/vitwit/authz-apps/blob/main/voting-bot/database/authz.go"
    click dbSqlite "https://github.com/vitwit/authz-apps/blob/main/voting-bot/database/sqlite.go"
    click jobsMod "https://github.com/vitwit/authz-apps/blob/main/voting-bot/jobs/jobs.go"
    click jobsAuthz "https://github.com/vitwit/authz-apps/blob/main/voting-bot/jobs/authz.go"
    click jobsProp "https://github.com/vitwit/authz-apps/blob/main/voting-bot/jobs/proposals.go"
    click jobsBal "https://github.com/vitwit/authz-apps/blob/main/voting-bot/jobs/balances.go"
    click jobsWithdraw "https://github.com/vitwit/authz-apps/blob/main/voting-bot/jobs/withdraw_rewards.go"
    click apiEndpoints "https://github.com/vitwit/authz-apps/blob/main/voting-bot/endpoints/endpoints.go"
    click handler "https://github.com/vitwit/authz-apps/blob/main/voting-bot/handler/apiHandler.go"
    click clientMod "https://github.com/vitwit/authz-apps/blob/main/voting-bot/client/slack.go"
    click typesMod "https://github.com/vitwit/authz-apps/tree/main/voting-bot/types/"
    click utilsMod "https://github.com/vitwit/authz-apps/tree/main/voting-bot/utils/"
    click votingMod "https://github.com/vitwit/authz-apps/blob/main/voting-bot/voting/voting.go"

    classDef ui fill:#D0E1F9,stroke:#0366d6
    classDef backend fill:#D4F9D4,stroke:#28a745
    classDef db fill:#FFEFD5,stroke:#fb8c00
    classDef external fill:#F0F0F0,stroke:#6a737d,stroke-dasharray:2 2
    classDef cicd fill:#F4E1FF,stroke:#6f42c1
```
