# zahassanyum/raycast-slack-summaries architecture

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

- Interactive diagram: https://gitdiagram.com/zahassanyum/raycast-slack-summaries
- Repository: https://github.com/zahassanyum/raycast-slack-summaries

## Overview

##### Project type and purpose
- This is a Raycast extension (“Slack Summarizer”) written in TypeScript/React that lives entirely on the client (inside Raycast).
- Its job is to let a user pick a Slack channel or thread, fetch the text, send it to OpenAI, and render a bullet-point summary—all without any custom server.

##### File structure
- Top level: configuration files (.gitignore, tsconfig.json, package.json), asset folders (assets, metadata).
- src/ contains all the code:
- Two command entry points: summarize-channel.tsx and summarize-thread.tsx
- A components folder with SummaryDisplay.tsx for rendering results
- A utils folder with:
– slackAuth.js: handles PKCE OAuth flow and stores tokens in Raycast secure storage
– slackApi.js: calls Slack REST endpoints to fetch channels, threads, messages
– openaiApi.js: wraps OpenAI HTTP calls
– summarizer.js: coordinates fetching Slack data + calling OpenAI
– useToast.ts: UI notifications

##### README for additional insights
- Two Raycast commands (channel and thread)
- Uses Slack OAuth with no server, stores tokens locally
- Requires OpenAI API key and Slack scopes
- Describes features, limitations, and custom-prompt support

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Raycast host environment
    RAY["Raycast Host"]:::external

    %% Commands layer
    subgraph "Commands"  
        direction TB
        SC["Summarize Channel"]:::commands
        ST["Summarize Thread"]:::commands
    end

    %% Auth Module
    subgraph "Auth Module"  
        direction TB
        SAU["slackAuth.js\n(PKCE OAuth)"]:::auth
        STORAGE[(Secure Storage)]:::storage
        BROWSER["Browser PKCE Flow"]:::external
    end

    %% Orchestrator
    SUM["summarizer.js\n(Orchestrator)"]:::orchestrator

    %% API Clients
    subgraph "API Clients"
        direction TB
        SAPI["slackApi.js\n(Slack Web API)"]:::client
        OAPI["openaiApi.js\n(OpenAI REST)"]:::client
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        SD["SummaryDisplay.tsx"]:::ui
        UT["useToast.ts"]:::ui
    end

    %% External services
    SLACK["Slack Service"]:::external
    OPENAI["OpenAI Service"]:::external

    %% Flows
    RAY -->|invokes| SC
    RAY -->|invokes| ST

    SC -->|check token| SAU
    ST -->|check token| SAU
    SAU -->|read/write| STORAGE
    SAU -->|initiate if no token| BROWSER
    BROWSER -->|OAuth code| SAU

    SC -->|start summary| SUM
    ST -->|start summary| SUM

    SUM -->|fetch messages| SAPI
    SAPI -->|calls Slack API\nwith retry/back-off| SLACK

    SUM -->|generate summary| OAPI
    OAPI -->|calls generate endpoint| OPENAI

    OAPI -->|return summary| SUM
    SAPI -->|return messages| SUM

    SUM -->|output summary| SC
    SUM -->|output summary| ST

    SC -->|render| SD
    ST -->|render| SD

    SC -->|notify status| UT
    ST -->|notify status| UT

    %% Click events
    click SC "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/summarize-channel.tsx"
    click ST "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/summarize-thread.tsx"
    click SD "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/components/SummaryDisplay.tsx"
    click UT "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/utils/useToast.ts"
    click SAU "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/utils/slackAuth.js"
    click SAPI "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/utils/slackApi.js"
    click SUM "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/utils/summarizer.js"
    click OAPI "https://github.com/zahassanyum/raycast-slack-summaries/blob/main/src/utils/openaiApi.js"

    %% Styles
    classDef commands fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef ui fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef auth fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef orchestrator fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef client fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef storage fill:#ffe0b2,stroke:#ef6c00,color:#e65100,shape:cylinder;
    classDef external fill:#ffe0b2,stroke:#ef6c00,color:#e65100,shape:cloud;
```
