# a-i-p-a/csrassist architecture

> Architecture diagram of the GitHub repository a-i-p-a/csrassist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/a-i-p-a/csrassist
- Repository: https://github.com/a-i-p-a/csrassist

## Overview

CSRAssist is a set of CSR-assistance tools, with a documented Slack-to-Discord proof of concept as its principal workflow: a Slack request to sell a TV can include photos, which are OCR-processed and summarized before the task is published for Discord. The graph also shows the router’s Redis-backed message path and the Discord bot’s polling and reply behavior. The README documents the setup and workflow; unsampled integration details are not inferred.

Main entry points: [`slack_integration/slack_bot.py`](https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py) (Slack bot), [`router/aipa.py`](https://github.com/a-i-p-a/csrassist/blob/main/router/aipa.py) (Channel router), [`discord_integration/discord_bot.py`](https://github.com/a-i-p-a/csrassist/blob/main/discord_integration/discord_bot.py) (Discord bot), [`stringlist_semantics/stringlist.py`](https://github.com/a-i-p-a/csrassist/blob/main/stringlist_semantics/stringlist.py) (TV description)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_slack["Slack Intake"]
  node_slack_bot["Slack bot<br/>[slack_bot.py]"]
  node_task_state["Task state<br/>[slack_bot.py]"]
  node_attachments["Photo downloads<br/>[slack_bot.py]"]
end

subgraph group_analysis["TV Analysis"]
  node_ocr["Image OCR<br/>[ocr.py]"]
  node_tv_description["TV description<br/>[stringlist.py]"]
end

subgraph group_routing["Message Routing"]
  node_router["Channel router<br/>[aipa.py]"]
  node_redis[("Redis pub/sub")]
end

subgraph group_discord["Discord Delivery"]
  node_discord_bot["Discord bot<br/>[discord_bot.py]"]
end

node_user(("CSR / requester"))
node_slack_service["Slack"]
node_openai["OpenAI API"]
node_discord_service["Discord channel"]

node_user -->|"sends request"| node_slack_bot
node_slack_bot -->|"receives events"| node_slack_service
node_slack_bot -->|"updates state"| node_task_state
node_slack_bot -->|"downloads files"| node_attachments
node_attachments -->|"extracts text"| node_ocr
node_slack_bot -->|"requests description"| node_tv_description
node_tv_description -->|"requests completion"| node_openai
node_slack_bot -->|"sends replies"| node_slack_service
node_slack_bot -->|"publishes task"| node_router
node_router -->|"publishes messages"| node_redis
node_router -->|"subscribes channels"| node_redis
node_discord_bot -->|"polls queue"| node_router
node_discord_bot -->|"starts listener"| node_router
node_discord_bot -->|"sends messages"| node_discord_service
node_discord_service -->|"delivers messages"| node_discord_bot

click node_slack_bot "https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py"
click node_task_state "https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py"
click node_attachments "https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py"
click node_ocr "https://github.com/a-i-p-a/csrassist/blob/main/ocr_integration/ocr.py"
click node_tv_description "https://github.com/a-i-p-a/csrassist/blob/main/stringlist_semantics/stringlist.py"
click node_router "https://github.com/a-i-p-a/csrassist/blob/main/router/aipa.py"
click node_discord_bot "https://github.com/a-i-p-a/csrassist/blob/main/discord_integration/discord_bot.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_slack_bot,node_task_state,node_attachments toneBlue
class node_ocr,node_tv_description toneAmber
class node_router,node_redis,node_user,node_openai toneMint
class node_discord_bot toneRose
class node_slack_service,node_discord_service toneIndigo
```

## Components

### Slack Intake

- [Slack bot](https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py): `slack_integration/slack_bot.py`
- [Task state](https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py): `slack_integration/slack_bot.py`
- [Photo downloads](https://github.com/a-i-p-a/csrassist/blob/main/slack_integration/slack_bot.py): `slack_integration/slack_bot.py`

### TV Analysis

- [Image OCR](https://github.com/a-i-p-a/csrassist/blob/main/ocr_integration/ocr.py): `ocr_integration/ocr.py`
- [TV description](https://github.com/a-i-p-a/csrassist/blob/main/stringlist_semantics/stringlist.py): `stringlist_semantics/stringlist.py`

### Message Routing

- [Channel router](https://github.com/a-i-p-a/csrassist/blob/main/router/aipa.py): `router/aipa.py`
- **Redis pub/sub**

### Discord Delivery

- [Discord bot](https://github.com/a-i-p-a/csrassist/blob/main/discord_integration/discord_bot.py): `discord_integration/discord_bot.py`

### Other components

- **CSR / requester**
- **Slack**
- **OpenAI API**
- **Discord channel**

## Connections

- CSR / requester → Slack bot: sends request (evidence: `README.md`)
- Slack bot → Slack: receives events (evidence: `slack_integration/slack_bot.py`)
- Slack bot → Task state: updates state (evidence: `slack_integration/slack_bot.py`)
- Slack bot → Photo downloads: downloads files (evidence: `slack_integration/slack_bot.py`)
- Photo downloads → Image OCR: extracts text (evidence: `slack_integration/slack_bot.py`)
- Slack bot → TV description: requests description (evidence: `slack_integration/slack_bot.py`)
- TV description → OpenAI API: requests completion (evidence: `stringlist_semantics/stringlist.py`)
- Slack bot → Slack: sends replies (evidence: `slack_integration/slack_bot.py`)
- Slack bot → Channel router: publishes task (evidence: `slack_integration/slack_bot.py`)
- Channel router → Redis pub/sub: publishes messages (evidence: `router/aipa.py`)
- Channel router → Redis pub/sub: subscribes channels (evidence: `router/aipa.py`)
- Discord bot → Channel router: polls queue (evidence: `discord_integration/discord_bot.py`)
- Discord bot → Channel router: starts listener (evidence: `discord_integration/discord_bot.py`)
- Discord bot → Discord channel: sends messages (evidence: `discord_integration/discord_bot.py`)
- Discord channel → Discord bot: delivers messages (evidence: `discord_integration/discord_bot.py`)
