# idkhowtocodefr/code-bot architecture

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

- Interactive diagram: https://gitdiagram.com/idkhowtocodefr/code-bot
- Repository: https://github.com/idkhowtocodefr/code-bot

## Overview

CodeBot is a Discord coding-assistant bot. Users invoke slash commands for public or private help, debugging, learning resources, tips, and command help; the bot calls response logic, sends results back through Discord, and stores or retrieves per-user history for personalized answers. Source confirms these calls and the SQLite/Cohere integrations. README also documents response chunking and DM privacy handling; implementation details beyond the sampled source are not inferred.

Main entry points: [`codebot.py`](https://github.com/idkhowtocodefr/code-bot/blob/main/codebot.py) (Command handlers), [`response.py`](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py) (Code help), [`db.py`](https://github.com/idkhowtocodefr/code-bot/blob/main/db.py) (User history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["Discord Commands"]
  node_handlers["Command handlers<br/>[codebot.py]"]
  node_delivery["Response delivery<br/>[codebot.py]"]
  node_help["Help menu<br/>[response.py]"]
  node_strict["Strictness control<br/>[response.py]"]
end

subgraph group_assistant["Assistant Services"]
  node_query["Code help<br/>[response.py]"]
  node_debug["Code debugging<br/>[response.py]"]
  node_resources["Learning resources<br/>[response.py]"]
  node_tips["Coding tips<br/>[response.py]"]
end

subgraph group_state["History Storage"]
  node_history["History access<br/>[response.py]"]
  node_sqlite[("User history<br/>[db.py]")]
end

node_user(("Discord user"))
node_discord{{"Discord API"}}
node_cohere{{"Cohere AI"}}

node_user -->|"invokes commands"| node_discord
node_discord -->|"dispatches interactions"| node_handlers
node_handlers -->|"calls help"| node_query
node_handlers -->|"calls debug"| node_debug
node_handlers -->|"calls resources"| node_resources
node_handlers -->|"calls tips"| node_tips
node_handlers -->|"requests help"| node_help
node_handlers -->|"sets strictness"| node_strict
node_query -->|"builds prompt"| node_history
node_debug -->|"builds prompt"| node_history
node_history -->|"reads history"| node_sqlite
node_handlers -->|"stores exchanges"| node_sqlite
node_handlers -->|"initializes store"| node_sqlite
node_query -->|"requests answer"| node_cohere
node_debug -->|"requests review"| node_cohere
node_resources -->|"requests links"| node_cohere
node_tips -->|"requests tips"| node_cohere
node_handlers -->|"passes results"| node_delivery
node_delivery -->|"sends messages"| node_discord
node_discord -->|"delivers replies"| node_user

click node_handlers "https://github.com/idkhowtocodefr/code-bot/blob/main/codebot.py"
click node_delivery "https://github.com/idkhowtocodefr/code-bot/blob/main/codebot.py"
click node_help "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_strict "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_query "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_debug "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_resources "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_tips "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_history "https://github.com/idkhowtocodefr/code-bot/blob/main/response.py"
click node_sqlite "https://github.com/idkhowtocodefr/code-bot/blob/main/db.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_handlers,node_delivery,node_help,node_strict,node_user toneBlue
class node_query,node_debug,node_resources,node_tips toneAmber
class node_history,node_sqlite,node_discord toneMint
class node_cohere toneIndigo
```

## Components

### Discord Commands

- [Command handlers](https://github.com/idkhowtocodefr/code-bot/blob/main/codebot.py): `codebot.py`
- [Response delivery](https://github.com/idkhowtocodefr/code-bot/blob/main/codebot.py): `codebot.py`
- [Help menu](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`
- [Strictness control](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`

### Assistant Services

- [Code help](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`
- [Code debugging](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`
- [Learning resources](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`
- [Coding tips](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`

### History Storage

- [History access](https://github.com/idkhowtocodefr/code-bot/blob/main/response.py): `response.py`
- [User history](https://github.com/idkhowtocodefr/code-bot/blob/main/db.py): `db.py`

### Other components

- **Discord user**
- **Discord API**
- **Cohere AI**

## Connections

- Discord user → Discord API: invokes commands
- Discord API → Command handlers: dispatches interactions
- Command handlers → Code help: calls help
- Command handlers → Code debugging: calls debug
- Command handlers → Learning resources: calls resources
- Command handlers → Coding tips: calls tips
- Command handlers → Help menu: requests help
- Command handlers → Strictness control: sets strictness
- Code help → History access: builds prompt
- Code debugging → History access: builds prompt
- History access → User history: reads history
- Command handlers → User history: stores exchanges
- Command handlers → User history: initializes store
- Code help → Cohere AI: requests answer
- Code debugging → Cohere AI: requests review
- Learning resources → Cohere AI: requests links
- Coding tips → Cohere AI: requests tips
- Command handlers → Response delivery: passes results
- Response delivery → Discord API: sends messages
- Discord API → Discord user: delivers replies
