# anshm42/slangify architecture

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

- Interactive diagram: https://gitdiagram.com/anshm42/slangify
- Repository: https://github.com/anshm42/slangify

## Overview

Slangify is a Discord bot that defines slang in a referenced message. Users trigger it either by mentioning the bot in a reply or by selecting a message context-menu command; the bot obtains the target text, chooses a lookup source, and returns definitions as a Discord embed. Lookup has three modes: Gemini definitions, Urban Dictionary token lookups, and a hybrid that uses Gemini to identify terms before querying Urban. The graph reflects sampled runtime code and README-documented interaction modes.

Main entry points: [`src/slangify/bot.py`](https://github.com/anshm42/slangify/blob/main/src/slangify/bot.py) (Bot handlers), [`src/slangify/sources/hybrid.py`](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/hybrid.py) (Hybrid lookup), [`src/slangify/sources/gemini.py`](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/gemini.py) (Gemini lookup), [`src/slangify/sources/urban.py`](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/urban.py) (Urban lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Discord Interaction"]
  node_bot["Bot handlers<br/>[bot.py]"]
  node_trigger["Mention parser<br/>[trigger.py]"]
end

subgraph group_lookup["Definition Lookup"]
  node_hybrid["Hybrid lookup<br/>[hybrid.py]"]
  node_gemini["Gemini lookup<br/>[gemini.py]"]
  node_urban["Urban lookup<br/>[urban.py]"]
end

subgraph group_presentation["Response"]
  node_formatter["Embed builder<br/>[format.py]"]
end

node_user(("Discord user"))
node_discord["Discord platform"]
node_gemini_api["Gemini API"]
node_urban_api["Urban Dictionary API"]

node_user -->|"submits message"| node_discord
node_discord -->|"dispatches events"| node_bot
node_bot -->|"fetches replied message"| node_discord
node_bot -->|"parses mention"| node_trigger
node_bot -->|"selects source"| node_hybrid
node_bot -->|"selects source"| node_gemini
node_bot -->|"selects source"| node_urban
node_hybrid -->|"extracts terms"| node_gemini
node_hybrid -->|"fetches definitions"| node_urban
node_gemini -->|"requests generation"| node_gemini_api
node_urban -->|"queries terms"| node_urban_api
node_bot -->|"builds embed"| node_formatter
node_bot -->|"sends response"| node_discord
node_discord -->|"delivers response"| node_user

click node_bot "https://github.com/anshm42/slangify/blob/main/src/slangify/bot.py"
click node_trigger "https://github.com/anshm42/slangify/blob/main/src/slangify/trigger.py"
click node_hybrid "https://github.com/anshm42/slangify/blob/main/src/slangify/sources/hybrid.py"
click node_gemini "https://github.com/anshm42/slangify/blob/main/src/slangify/sources/gemini.py"
click node_urban "https://github.com/anshm42/slangify/blob/main/src/slangify/sources/urban.py"
click node_formatter "https://github.com/anshm42/slangify/blob/main/src/slangify/format.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_bot,node_trigger,node_user toneBlue
class node_hybrid,node_gemini,node_urban toneAmber
class node_formatter,node_gemini_api,node_urban_api toneMint
class node_discord toneIndigo
```

## Components

### Discord Interaction

- [Bot handlers](https://github.com/anshm42/slangify/blob/main/src/slangify/bot.py): `src/slangify/bot.py`
- [Mention parser](https://github.com/anshm42/slangify/blob/main/src/slangify/trigger.py): `src/slangify/trigger.py`

### Definition Lookup

- [Hybrid lookup](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/hybrid.py): `src/slangify/sources/hybrid.py`
- [Gemini lookup](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/gemini.py): `src/slangify/sources/gemini.py`
- [Urban lookup](https://github.com/anshm42/slangify/blob/main/src/slangify/sources/urban.py): `src/slangify/sources/urban.py`

### Response

- [Embed builder](https://github.com/anshm42/slangify/blob/main/src/slangify/format.py): `src/slangify/format.py`

### Other components

- **Discord user**
- **Discord platform**
- **Gemini API**
- **Urban Dictionary API**

## Connections

- Discord user → Discord platform: submits message
- Discord platform → Bot handlers: dispatches events
- Bot handlers → Discord platform: fetches replied message
- Bot handlers → Mention parser: parses mention
- Bot handlers → Hybrid lookup: selects source
- Bot handlers → Gemini lookup: selects source
- Bot handlers → Urban lookup: selects source
- Hybrid lookup → Gemini lookup: extracts terms
- Hybrid lookup → Urban lookup: fetches definitions
- Gemini lookup → Gemini API: requests generation
- Urban lookup → Urban Dictionary API: queries terms
- Bot handlers → Embed builder: builds embed
- Bot handlers → Discord platform: sends response
- Discord platform → Discord user: delivers response
