# vinayaksharma1853-a11y/relay_caspian_hackathon architecture

> Architecture diagram of the GitHub repository vinayaksharma1853-a11y/relay_caspian_hackathon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinayaksharma1853-a11y/relay_caspian_hackathon
- Repository: https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon

## Overview

RELAY receives incidents and commands through one Caspian message handler, analyzes incidents, records their state, and replies with status or a severity-based communication plan. Telegram and Discord are connected at runtime; email appears in the plan but is not dispatched by the sampled code. The source excerpt is partial, so the graph omits uncertain details of command handling and persistence beyond the visible JSON state operations.

Main entry points: [`relay_agent.py`](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py) (Relay agent), [`main.py`](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/main.py) (Message handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and channels"]
  node_main["Runtime setup<br/>[main.py]"]
  node_caspian["Caspian client"]
  node_telegram["Telegram"]
  node_discord["Discord"]
  node_handler["Message handler<br/>[main.py]"]
end

subgraph group_decision["Incident decisions"]
  node_agent["Relay agent<br/>[relay_agent.py]"]
  node_commands["Command handling<br/>[relay_agent.py]"]
  node_analysis["Incident analysis<br/>[relay_agent.py]"]
  node_openai["OpenAI API"]
  node_fallback["Fallback classifier<br/>[relay_agent.py]"]
  node_plan["Communication plan<br/>[relay_agent.py]"]
end

subgraph group_state["Incident state"]
  node_incident_ids["Incident IDs<br/>[relay_agent.py]"]
  node_status["Status tracking<br/>[relay_agent.py]"]
  node_state_file[("Incident state file<br/>[relay_agent.py]")]
end

node_sender(("Incident sender"))

node_main -->|"creates and listens"| node_caspian
node_main -->|"connects when configured"| node_telegram
node_main -->|"connects when configured"| node_discord
node_sender -->|"sends message"| node_caspian
node_caspian -->|"dispatches message"| node_handler
node_handler -->|"handles text"| node_agent
node_agent -->|"checks commands"| node_commands
node_agent -->|"analyzes incident"| node_analysis
node_analysis -.->|"requests analysis"| node_openai
node_analysis -->|"uses without key or on error"| node_fallback
node_analysis -->|"returns severity and channels"| node_plan
node_agent -->|"creates incident ID"| node_incident_ids
node_agent -->|"updates incident"| node_status
node_commands -->|"reads and updates"| node_status
node_incident_ids -->|"persists counter"| node_state_file
node_status -->|"loads and saves"| node_state_file
node_agent -->|"includes plan in response"| node_plan
node_agent -->|"returns response"| node_handler
node_handler -->|"replies to message"| node_caspian

click node_main "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/main.py"
click node_handler "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/main.py"
click node_agent "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_commands "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_analysis "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_fallback "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_plan "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_incident_ids "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_status "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py"
click node_state_file "https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.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_main,node_caspian,node_telegram,node_discord,node_handler toneBlue
class node_agent,node_commands,node_analysis,node_openai,node_fallback,node_plan toneAmber
class node_incident_ids,node_status,node_state_file toneMint
class node_sender toneIndigo
```

## Components

### Runtime and channels

- [Runtime setup](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/main.py): `main.py`
- **Caspian client**
- **Telegram**
- **Discord**
- [Message handler](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/main.py): `main.py`

### Incident decisions

- [Relay agent](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- [Command handling](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- [Incident analysis](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- **OpenAI API**
- [Fallback classifier](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- [Communication plan](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`

### Incident state

- [Incident IDs](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- [Status tracking](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`
- [Incident state file](https://github.com/vinayaksharma1853-a11y/relay_caspian_hackathon/blob/main/relay_agent.py): `relay_agent.py`

### Other components

- **Incident sender**

## Connections

- Runtime setup → Caspian client: creates and listens
- Runtime setup → Telegram: connects when configured
- Runtime setup → Discord: connects when configured
- Incident sender → Caspian client: sends message
- Caspian client → Message handler: dispatches message
- Message handler → Relay agent: handles text
- Relay agent → Command handling: checks commands
- Relay agent → Incident analysis: analyzes incident
- Incident analysis → OpenAI API: requests analysis
- Incident analysis → Fallback classifier: uses without key or on error
- Incident analysis → Communication plan: returns severity and channels
- Relay agent → Incident IDs: creates incident ID
- Relay agent → Status tracking: updates incident
- Command handling → Status tracking: reads and updates
- Incident IDs → Incident state file: persists counter
- Status tracking → Incident state file: loads and saves
- Relay agent → Communication plan: includes plan in response
- Relay agent → Message handler: returns response
- Message handler → Caspian client: replies to message
