# slackapi/slack-cli architecture

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

- Interactive diagram: https://gitdiagram.com/slackapi/slack-cli
- Repository: https://github.com/slackapi/slack-cli

## Overview

##### Project type and purpose
- This is an open-source command-line interface (CLI) tool, written in Go, for building and managing Slack apps.
- The README describes it as “Command-line interface for building apps on the Slack Platform.”

##### File structure
- Top-level “cmd/” directory holds subcommands implemented with Cobra (e.g., cmd/app, cmd/auth, cmd/project, etc.).
- “internal/” packages implement core logic and infrastructure:
- internal/api – HTTP clients and wrappers for Slack’s REST APIs (apps, auth, channels, datastore, uploads, etc.).
- internal/app, internal/config, internal/cache, internal/runtime, internal/hooks, etc., each encapsulating a distinct layer.
- “runtime/” subdirs for each function runtime (Node, Deno, Python).
- “docs/” and “test/” hold documentation and test fixtures.
- CI/CD and release configurations (.circleci, .github/, goreleaser.yml, Makefile) automate builds, tests, and multi-OS releases.

##### Extract architectural insights from the README
- The CLI is the primary entrypoint (main.go → Cobra root + subcommands).
- Each command drives a sequence: parse flags, read config/manifest, call business logic, then call HTTP API or manipulate files.
- Supports local development workflows (e.g., local server for Slack functions).

##### Diagramming conventions
- CLI commands (e.g., blue rectangles)
- Internal layers (e.g., green rectangles for application, yellow for infrastructure)
- User → CLI frontend → application layer → infrastructure layer → external services
- CI pipeline → build scripts → release artifacts

## Diagram (Mermaid)

```mermaid
graph TD
    %% User
    User["User"]:::user

    %% CLI Frontend
    subgraph "CLI Frontend"
        CLI_main["main.go"]:::cli
        CLI_cmd["Cobra Commands (cmd/)"]:::cli
    end

    %% Application Layer
    subgraph "Application Layer"
        App_app["internal/app/app.go"]:::app
        App_manifest["internal/app/manifest.go"]:::app
        Cmdutil_flags["internal/cmdutil/flags.go"]:::app
        Cmdutil_process["internal/cmdutil/process.go"]:::app
        Cmdutil_project["internal/cmdutil/project.go"]:::app
        Prompts_app["internal/prompts/app_select.go"]:::app
        Prompts_func["internal/prompts/function_permissions.go"]:::app
        Prompts_trig["internal/prompts/trigger_permissions.go"]:::app
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        API_client["internal/api/client.go"]:::infra
        API_app["internal/api/app.go"]:::infra
        API_auth["internal/api/auth.go"]:::infra
        API_s3["internal/api/s3_upload.go"]:::infra
        Config_core["internal/config/config.go"]:::infra
        Config_manifest["internal/config/manifest.go"]:::infra
        Config_flags["internal/config/flags.go"]:::infra
        Cache_core["internal/cache/cache.go"]:::infra
        Cache_manifest["internal/cache/manifest.go"]:::infra
        IO_streams["internal/iostreams/iostreams.go"]:::infra
        IO_printer["internal/iostreams/printer.go"]:::infra
        IO_host["internal/ioutils/host.go"]:::infra
    end

    %% Runtime Hosts
    subgraph "Runtime Hosts"
        Runtime_base["internal/runtime/runtime.go"]:::runtime
        Runtime_node["internal/runtime/node/node.go"]:::runtime
        Runtime_deno["internal/runtime/deno/deno.go"]:::runtime
        Runtime_python["internal/runtime/python/python.go"]:::runtime
    end

    %% External Services
    subgraph "External Services"
        SlackAPI["Slack REST API"]:::external
        AWSS3["AWS S3"]:::external
    end

    %% Packaging & CI/CD
    subgraph "Packaging & CI/CD"
        CD_Makefile["Makefile"]:::cicd
        CD_Circle[".circleci/config.yml"]:::cicd
        CD_Releaser["goreleaser.yml"]:::cicd
        CD_GHA[".github/workflows/"]:::cicd
        CD_Runner["ci/circleci/runner/"]:::cicd
    end

    %% Flows
    User -->|runs `slack <command>`| CLI_main
    CLI_main -->|invokes| CLI_cmd
    CLI_cmd -->|calls handlers| App_app
    App_app -->|uses| App_manifest
    App_app -->|uses| Cmdutil_flags
    App_app -->|uses| Cmdutil_process
    App_app -->|uses| Cmdutil_project
    App_app -->|prompts| Prompts_app
    App_app -->|prompts| Prompts_func
    App_app -->|prompts| Prompts_trig
    App_app -->|calls| API_client
    API_client -->|wraps| API_app
    API_client -->|wraps| API_auth
    API_client -->|wraps| API_s3
    App_app -->|reads| Config_core
    App_app -->|reads| Config_manifest
    App_app -->|reads| Config_flags
    App_app -->|caches| Cache_core
    App_app -->|caches| Cache_manifest
    App_app -->|outputs via| IO_streams
    App_app -->|prints via| IO_printer
    App_app -->|I/O via| IO_host
    App_app -->|for functions| Runtime_base
    Runtime_base -->|node impl| Runtime_node
    Runtime_base -->|deno impl| Runtime_deno
    Runtime_base -->|python impl| Runtime_python
    API_client -->|HTTP/JSON| SlackAPI
    API_s3 -->|uploads| AWSS3
    CD_Makefile -->|builds/tests| CLI_main
    CD_Circle -->|CI pipeline| CLI_main
    CD_Releaser -->|packages| CLI_main
    CD_GHA -->|CI pipeline| CLI_main
    CD_Runner -->|custom runner| CLI_main

    %% Click Events
    click CLI_main "https://github.com/slackapi/slack-cli/blob/main/main.go"
    click CLI_cmd "https://github.com/slackapi/slack-cli/tree/main/cmd/"
    click App_app "https://github.com/slackapi/slack-cli/blob/main/internal/app/app.go"
    click App_manifest "https://github.com/slackapi/slack-cli/blob/main/internal/app/manifest.go"
    click Cmdutil_flags "https://github.com/slackapi/slack-cli/blob/main/internal/cmdutil/flags.go"
    click Cmdutil_process "https://github.com/slackapi/slack-cli/blob/main/internal/cmdutil/process.go"
    click Cmdutil_project "https://github.com/slackapi/slack-cli/blob/main/internal/cmdutil/project.go"
    click Prompts_app "https://github.com/slackapi/slack-cli/blob/main/internal/prompts/app_select.go"
    click Prompts_func "https://github.com/slackapi/slack-cli/blob/main/internal/prompts/function_permissions.go"
    click Prompts_trig "https://github.com/slackapi/slack-cli/blob/main/internal/prompts/trigger_permissions.go"
    click API_client "https://github.com/slackapi/slack-cli/blob/main/internal/api/client.go"
    click API_app "https://github.com/slackapi/slack-cli/blob/main/internal/api/app.go"
    click API_auth "https://github.com/slackapi/slack-cli/blob/main/internal/api/auth.go"
    click API_s3 "https://github.com/slackapi/slack-cli/blob/main/internal/api/s3_upload.go"
    click Config_core "https://github.com/slackapi/slack-cli/blob/main/internal/config/config.go"
    click Config_manifest "https://github.com/slackapi/slack-cli/blob/main/internal/config/manifest.go"
    click Config_flags "https://github.com/slackapi/slack-cli/blob/main/internal/config/flags.go"
    click Cache_core "https://github.com/slackapi/slack-cli/blob/main/internal/cache/cache.go"
    click Cache_manifest "https://github.com/slackapi/slack-cli/blob/main/internal/cache/manifest.go"
    click IO_streams "https://github.com/slackapi/slack-cli/blob/main/internal/iostreams/iostreams.go"
    click IO_printer "https://github.com/slackapi/slack-cli/blob/main/internal/iostreams/printer.go"
    click IO_host "https://github.com/slackapi/slack-cli/blob/main/internal/ioutils/host.go"
    click Runtime_base "https://github.com/slackapi/slack-cli/blob/main/internal/runtime/runtime.go"
    click Runtime_node "https://github.com/slackapi/slack-cli/blob/main/internal/runtime/node/node.go"
    click Runtime_deno "https://github.com/slackapi/slack-cli/blob/main/internal/runtime/deno/deno.go"
    click Runtime_python "https://github.com/slackapi/slack-cli/blob/main/internal/runtime/python/python.go"
    click CD_Makefile "https://github.com/slackapi/slack-cli/tree/main/Makefile"
    click CD_Circle "https://github.com/slackapi/slack-cli/blob/main/.circleci/config.yml"
    click CD_Releaser "https://github.com/slackapi/slack-cli/blob/main/goreleaser.yml"
    click CD_GHA "https://github.com/slackapi/slack-cli/tree/main/.github/workflows/"
    click CD_Runner "https://github.com/slackapi/slack-cli/tree/main/ci/circleci/runner/"

    %% Styles
    classDef user fill:#CCCCFF,stroke:#000;
    classDef cli fill:#ACE7EF,stroke:#028090;
    classDef app fill:#C0FDFB,stroke:#05668D;
    classDef infra fill:#FFF4B2,stroke:#D9B44A;
    classDef runtime fill:#FFD6A5,stroke:#FC7A1E;
    classDef external fill:#FFB2A6,stroke:#D7263D;
    classDef cicd fill:#E0E0E0,stroke:#757575;
```
