Introduction & Features Overview
Relevant source files
The following files were used as context for generating this wiki page:
The CodeBot project (also referred to as Code Keeper Bot) is an advanced Telegram bot and companion web application designed for the systematic management, sharing, and organization of code snippets. It provides a robust infrastructure for developers to save code, detect programming languages automatically, and integrate with external services like GitHub, Google Drive, and Pastebin. The system is built using a layered architecture to ensure a clean separation of concerns between its Telegram interface, business logic, and MongoDB storage layer.
Sources: package.json, webapp/README.md:1-5, code_review_2025_10/CODE_REVIEW_SUMMARY.md:17-25
System Architecture
The project follows a modular, layered architecture composed of distinct services, handlers, and database components. The core logic is shared between a Telegram bot interface and a Flask-based web application. The backend utilizes a Repository Pattern for data persistence in MongoDB and integrates specialized services for code normalization and language detection.
High-Level Component Flow
The following diagram illustrates the general interaction between the user interfaces and the core backend services.
This diagram shows the flow from user input through specific handlers to the core services and finally to the database.
Sources: PROMPTS_WEBAPP_LAYERING.md:20-35, GUIDES/ARCHITECTURE.md:18-38
Core Features
CodeBot offers a comprehensive suite of features for both the Telegram bot and the Web App, focusing on code management, collaboration, and developer productivity.
Telegram Bot Features
- Code Management: Saving code snippets directly via chat, batch processing, and version control.
- Search Engine: Advanced search capabilities to locate snippets quickly.
- Integrations: Direct links to GitHub, Google Drive, and Pastebin for importing and exporting code.
- Automation: Automatic language detection and code normalization upon saving.
Sources: code_review_2025_10/CODE_REVIEW_SUMMARY.md:27-35, PROMPTS_WEBAPP_LAYERING.md:25-30
Web Application Features
The Web App provides a GUI for tasks that are more complex to perform via chat, including visual code editing and advanced statistics.
| Feature Category | Description | Key Components |
|---|---|---|
| Authentication | Secure login via Telegram Widget or one-time tokens. | login.html, auth/telegram |
| File Management | Full-text and Fuzzy search, syntax highlighting for 100+ languages. | view_file.html, files.html |
| Markdown Support | GFM, Mermaid diagrams, KaTeX formulas, and interactive task lists. | md_preview.html, markdown-it |
| Organization | Bookmarks with line-specific notes and smart collections. | collections_api.py, bookmarks_api.py |
| Collaboration | Publicly shareable collections and community snippet library. | snippets.html, community_library_service.py |
Sources: webapp/README.md:7-95, package.json:28-56
Data and Request Flow
The system manages code snippets through a series of validation and transformation steps. When a request is made (either via Telegram or Web), it passes through a command router and permission handler before reaching the services.
Metrics and Command Execution Flow
This sequence highlights the internal processing steps for a standard code saving command.
Sources: GUIDES/ARCHITECTURE.md:4-15, PROMPTS_WEBAPP_LAYERING.md:85-95
Configuration and Deployment
The project is designed to run in diverse environments, including local development and cloud CI/CD pipelines.
Required Environment Variables
A .env file is required to manage sensitive credentials and operational flags.
| Variable | Scope | Description |
|---|---|---|
BOT_TOKEN | Bot/Web | Telegram bot token from BotFather. |
MONGODB_URL | Bot/Web | Connection string for MongoDB. |
SECRET_KEY | Web | Flask session encryption key. |
ADMIN_USER_IDS | Admin | Comma-separated Telegram IDs for administrative access. |
RATE_LIMIT_ENABLED | Performance | Boolean to enable/disable traffic control. |
Sources: CLOUD.md:42-55, webapp/README.md:158-180
Local Execution
- Create environment file:
cp .env.example .env - Run the bot:
python main.py - Run the webapp:
python webapp/app.pyor./scripts/start_webapp.sh
Sources: CLOUD.md:23-38
Conclusion
CodeBot serves as a high-performance, production-ready solution for managing developer knowledge. By combining the immediacy of a Telegram interface with the rich visualization and management tools of a Web App, it facilitates efficient code storage and retrieval. Its modular architecture, validated by strict layer boundaries and extensive testing (331 test files), ensures long-term maintainability and scalability.
Sources: code_review_2025_10/CODE_REVIEW_SUMMARY.md:105-115, FEATURE_SUGGESTIONS/IMPROVEMENT_SUGGESTIONS.md:7-12