Developer Documentation & Architecture¶
- Developer Documentation & Architecture
- 1. System Overview
- 2. Directory Structure
- 3. Main Logic Flow
- 4. Development Setup
1. System Overview¶
LeetCodeBot is a Python-based Discord bot designed to make discussion for LeetCode problems easier in discord. It uses discord.py (or similar) and organizes features into modular extensions ("cogs").
2. Directory Structure¶
main.py: The entry point. Initializes the bot, loads environment variables, and starts the event loop.core/: Contains the core bot logic, likely including the custom Bot class subclass and global error handling.cogs/: Modular features. Each file here represents a specific category of commands (e.g.,leetcode.py,admin.py).db/: Database interactions and ORM models.models: Data models representing entities. E.g., ProblemDifficulty.utils/: Helper functions used across multiple cogs..env.example: Template for environment variables.config/: Configuration files for different environments (development, production).
3. Main Logic Flow¶
Startup Sequence¶
config/secrets.pyloads variables from.env.- The Bot instance created in
main.py. - Extensions from
cogs/are loaded when the bot instance is initializing. - The classes in
core/are setup, including cache loading.
LeetCode Commands¶
See Main Features
4. Development Setup¶
- Install dependencies:
uv sync. - Setup variables: Copy
.env.exampleto.env. - Run the bot:
python main.py.