# daviddudun/ieka-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/daviddudun/ieka-v2
- Repository: https://github.com/daviddudun/ieka-v2

## Overview

This repository contains a Discord chatbot and a separate user-writing-style profile workflow. In the active bot path, a channel message is queued, combined with per-channel history, sent to the chatbot client, and replied to on Discord. The agent and its research, transport, statistics, finance, and calculation tools exist, but the bot’s agent invocation is commented out. The profile workflow is implemented as separate cleaning, filtering, and style-generation scripts; their staged data handoffs are indicated by the filenames in source, not by a shared orchestrator.

Main entry points: [`src/bot.py`](https://github.com/daviddudun/ieka-v2/blob/main/src/bot.py) (Bot runtime), [`src/agent/agent_tools.py`](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_tools.py) (Tool executor), [`profile_maker/generate_user_prompt.py`](https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/generate_user_prompt.py) (Style analyzer), [`src/agent/agent_client.py`](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_client.py) (Agent client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord_runtime["Discord chatbot"]
  node_bot["Bot runtime<br/>[bot.py]"]
  node_queue["Request queue<br/>[bot.py]"]
  node_history["Channel history"]
  node_chatbot["Chatbot client<br/>[chatbot_client.py]"]
end

subgraph group_agent_tools["Agent and tools"]
  node_agent["Agent client<br/>[agent_client.py]"]
  node_tool_defs["Tool parser<br/>[agent_tools.py]"]
  node_executor["Tool executor<br/>[agent_tools.py]"]
  node_scraper["Web and weather<br/>[web_scraper.py]"]
  node_tfl["TfL client<br/>[api_clients.py]"]
  node_ons["ONS client<br/>[api_clients.py]"]
  node_yahoo["Finance client<br/>[api_clients.py]"]
end

subgraph group_profile_workflow["Profile workflow"]
  node_chat_export["Chat export"]
  node_cleaner["Chat cleaner<br/>[clean_data.py]"]
  node_cleaned_data["Cleaned chat data"]
  node_filter["User filter<br/>[filter_user.py]"]
  node_user_messages["Filtered messages"]
  node_analyzer["Style analyzer"]
  node_style_output["Style description"]
end

subgraph group_integrations["External services"]
  node_discord(("Discord"))
  node_llm(("LLM API"))
  node_web_services(("Web and weather services"))
  node_tfl_service(("TfL API"))
  node_ons_service(("ONS API"))
  node_yahoo_service(("Yahoo Finance"))
end

node_user(("Discord user"))

node_user -->|"sends command"| node_discord
node_discord -->|"delivers message"| node_bot
node_bot -->|"enqueues request"| node_queue
node_bot -->|"reads and updates"| node_history
node_bot -->|"requests response"| node_chatbot
node_chatbot -->|"sends prompt"| node_llm
node_llm -->|"returns response"| node_chatbot
node_bot -->|"replies"| node_discord
node_agent -->|"requests tool choice"| node_llm
node_agent -->|"parses response"| node_tool_defs
node_agent -->|"executes tool"| node_executor
node_executor -->|"calls web tools"| node_scraper
node_executor -->|"calls transport tools"| node_tfl
node_executor -->|"calls statistics tools"| node_ons
node_executor -->|"calls finance tools"| node_yahoo
node_scraper -->|"fetches information"| node_web_services
node_tfl -->|"queries journeys and status"| node_tfl_service
node_ons -->|"searches datasets"| node_ons_service
node_yahoo -->|"queries market data"| node_yahoo_service
node_chat_export -->|"reads export"| node_cleaner
node_cleaner -->|"writes cleaned messages"| node_cleaned_data
node_cleaned_data -->|"reads cleaned text"| node_filter
node_filter -->|"writes selected messages"| node_user_messages
node_user_messages -->|"reads and chunks"| node_analyzer
node_analyzer -->|"requests style analysis"| node_llm
node_llm -->|"returns style description"| node_analyzer
node_analyzer -->|"writes description"| node_style_output

click node_bot "https://github.com/daviddudun/ieka-v2/blob/main/src/bot.py"
click node_queue "https://github.com/daviddudun/ieka-v2/blob/main/src/bot.py"
click node_history "https://github.com/daviddudun/ieka-v2/blob/main/src/conversation_history.py"
click node_chatbot "https://github.com/daviddudun/ieka-v2/blob/main/src/chatbot/chatbot_client.py"
click node_agent "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_client.py"
click node_tool_defs "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_tools.py"
click node_executor "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_tools.py"
click node_scraper "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/web_scraper.py"
click node_tfl "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py"
click node_ons "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py"
click node_yahoo "https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py"
click node_cleaner "https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/clean_data.py"
click node_filter "https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/filter_user.py"
click node_analyzer "https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/generate_user_prompt.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_queue,node_history,node_chatbot,node_user toneBlue
class node_agent,node_tool_defs,node_executor,node_scraper,node_tfl,node_ons,node_yahoo toneAmber
class node_chat_export,node_cleaner,node_cleaned_data,node_filter,node_user_messages,node_analyzer,node_style_output toneMint
class node_discord,node_llm,node_web_services,node_tfl_service,node_ons_service,node_yahoo_service toneRose
```

## Components

### Discord chatbot

- [Bot runtime](https://github.com/daviddudun/ieka-v2/blob/main/src/bot.py): `src/bot.py`
- [Request queue](https://github.com/daviddudun/ieka-v2/blob/main/src/bot.py): `src/bot.py`
- [Channel history](https://github.com/daviddudun/ieka-v2/blob/main/src/conversation_history.py): `src/conversation_history.py`
- [Chatbot client](https://github.com/daviddudun/ieka-v2/blob/main/src/chatbot/chatbot_client.py): `src/chatbot/chatbot_client.py`

### Agent and tools

- [Agent client](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_client.py): `src/agent/agent_client.py`
- [Tool parser](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_tools.py): `src/agent/agent_tools.py`
- [Tool executor](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/agent_tools.py): `src/agent/agent_tools.py`
- [Web and weather](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/web_scraper.py): `src/agent/web_scraper.py`
- [TfL client](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py): `src/agent/api_clients.py`
- [ONS client](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py): `src/agent/api_clients.py`
- [Finance client](https://github.com/daviddudun/ieka-v2/blob/main/src/agent/api_clients.py): `src/agent/api_clients.py`

### Profile workflow

- **Chat export**
- [Chat cleaner](https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/clean_data.py): `profile_maker/clean_data.py`
- **Cleaned chat data**
- [User filter](https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/filter_user.py): `profile_maker/filter_user.py`
- **Filtered messages**
- [Style analyzer](https://github.com/daviddudun/ieka-v2/blob/main/profile_maker/generate_user_prompt.py): `profile_maker/generate_user_prompt.py`
- **Style description**

### External services

- **Discord**
- **LLM API**
- **Web and weather services**
- **TfL API**
- **ONS API**
- **Yahoo Finance**

### Other components

- **Discord user**

## Connections

- Discord user → Discord: sends command
- Discord → Bot runtime: delivers message
- Bot runtime → Request queue: enqueues request
- Bot runtime → Channel history: reads and updates
- Bot runtime → Chatbot client: requests response
- Chatbot client → LLM API: sends prompt
- LLM API → Chatbot client: returns response
- Bot runtime → Discord: replies
- Agent client → LLM API: requests tool choice
- Agent client → Tool parser: parses response
- Agent client → Tool executor: executes tool
- Tool executor → Web and weather: calls web tools
- Tool executor → TfL client: calls transport tools
- Tool executor → ONS client: calls statistics tools
- Tool executor → Finance client: calls finance tools
- Web and weather → Web and weather services: fetches information
- TfL client → TfL API: queries journeys and status
- ONS client → ONS API: searches datasets
- Finance client → Yahoo Finance: queries market data
- Chat export → Chat cleaner: reads export
- Chat cleaner → Cleaned chat data: writes cleaned messages
- Cleaned chat data → User filter: reads cleaned text
- User filter → Filtered messages: writes selected messages
- Filtered messages → Style analyzer: reads and chunks
- Style analyzer → LLM API: requests style analysis
- LLM API → Style analyzer: returns style description
- Style analyzer → Style description: writes description
