How coreinch/duecoach works
Duecoach is a Telegram-based ADHD coaching bot. A message enters through Telegram, is gated and routed by the channel-independent core, then receives a command, safety response, or model-generated coaching reply; the bot also runs reminders and proactive check-ins. SQLite holds consent, conversations, coaching state, and scheduled items. The README documents the playbook, bilingual support, privacy controls, and safety behavior. Edges follow the excerpts and SOURCE INDEX; links involving unsampled implementation details are omitted.
Main entry points: llm.py Model and tools loop · core.py Message router · chat.py Reply handling · db.py SQLite state
Components 16
Conversation handling
- Telegram channel
duecoach/channels/telegram.py - Message router
duecoach/core.py - Slash commands
duecoach/commands.py - Crisis detection
duecoach/crisis.py
Coaching engine
- Reply handling
duecoach/chat.py - Model and tools loop
duecoach/llm.py - Coaching prompts
duecoach/prompts.py - Strategy playbook
duecoach/playbook.py - Coaching tools
duecoach/tools.py - Bilingual text
duecoach/strings.py
User state
- Runtime configuration
duecoach/config.py - SQLite state
duecoach/db.py
Proactive operations
- Reminders and check-ins
duecoach/bot.py - Conversation eval cases
evals/cases.py
Other components
- Telegram user
- Language model provider
Connections 22
- Telegram user → Telegram channel: sends message
duecoach/channels/telegram.py - Telegram channel → Message router: routes text
duecoach/channels/telegram.py - Message router → Runtime configuration: checks access
duecoach/core.py - Message router → SQLite state: loads user
duecoach/core.py - Message router → Crisis detection: checks crisis
duecoach/core.py - Message router → Slash commands: dispatches command
duecoach/core.py - Message router → Reply handling: routes coaching
duecoach/core.py - Slash commands → Reply handling: invokes coaching
duecoach/commands.py - Slash commands → SQLite state: reads and updates
duecoach/commands.py - Slash commands → Coaching prompts: uses instructions
duecoach/commands.py - Reply handling → Model and tools loop: requests reply
duecoach/chat.py - Reply handling → SQLite state: stores crisis exchange
duecoach/chat.py - Reply handling → Bilingual text: formats fixed text
duecoach/chat.py - Model and tools loop → Language model provider: calls model
- Model and tools loop → SQLite state: loads and saves context
duecoach/llm.py - Model and tools loop → Coaching prompts: uses prompts
duecoach/llm.py - Model and tools loop → Strategy playbook: uses strategies
duecoach/llm.py - Model and tools loop → Coaching tools: runs tool calls
duecoach/llm.py - Model and tools loop → Bilingual text: uses language text
duecoach/llm.py - Reminders and check-ins → SQLite state: reads schedules
duecoach/bot.py - Reminders and check-ins → Model and tools loop: generates check-ins
duecoach/bot.py - Reminders and check-ins → Telegram channel: delivers messages
duecoach/bot.py