GitHub_Bot / README.md
Devin AI
resolve merge conflict in README.md β€” combine Digital Factory + legacy bot docs
02325cd
---
title: Digital Factory
emoji: 🏭
colorFrom: purple
colorTo: blue
sdk: docker
pinned: false
---
# 🏭 Digital Factory
AI-powered autonomous software development platform, controlled via Telegram.
The Digital Factory takes a natural-language project description and autonomously plans, codes, validates, and delivers complete software β€” powered by a team of specialised AI agents and deterministic validation tools.
## Architecture
```
User (Telegram) β†’ Project Manager β†’ SDLC Orchestrator β†’ [Developer, Prompt Engineer]
↕ ↕
Memory System Tool Registry
(SQLite + STM) (Linter, Validator, GitHub, Files)
```
### Agents (Phase 1 MVP)
| Agent | Role |
|-------|------|
| **SDLC Orchestrator** | Plans projects, dispatches tasks, validates outputs |
| **Project Manager** | Telegram interface, requirement clarification, progress tracking |
| **Software Developer** | Code generation, syntax checking, linting |
| **Prompt Engineer** | Crafts and optimises prompts for other agents |
### Deterministic Tools
- **Pydantic Validator** β€” Schema validation for all inter-agent contracts (replaces ZOD)
- **Python Linter** β€” Code quality via `ruff`
- **Syntax Checker** β€” `py_compile` validation
- **Code Executor** β€” Sandboxed Python execution
- **File Manager** β€” Project file I/O
- **GitHub Client** β€” Repository operations via REST API
### Memory System (4-tier)
| Tier | Implementation | Purpose |
|------|---------------|---------|
| Short-Term | In-memory dict + TTL | Session context, active conversations |
| Project | SQLite | Project specs, plans, code artifacts, task logs |
| Knowledge | (Phase 2) | Vector-based retrieval of best practices |
| User LTM | SQLite | User preferences and feedback |
### Communication
All inter-agent communication uses validated Pydantic models (`TaskRequest` / `TaskResponse`) dispatched through an async in-process message bus.
## Setup
Add these secrets in **Settings β†’ Secrets** (HuggingFace Spaces) or as environment variables:
| Secret | Required | Description |
|--------|----------|-------------|
| `BOT_TOKEN` | Yes | Telegram bot token from @BotFather |
| `ADMIN_ID` | Yes | Your Telegram numeric ID |
| `GROQ_KEY` | Recommended | Groq API key (primary AI provider) |
| `DEEPSEEK_KEY` | Optional | DeepSeek API key (fallback) |
| `HF_TOKEN` | Optional | HuggingFace API token (fallback) |
| `MISTRAL_KEY` | Optional | Mistral API key (fallback) |
| `GH_TOKEN` | Optional | GitHub PAT for repo operations (scope: `repo`, `workflow`) |
| `GH_USER` | Optional | GitHub username |
| `GH_REPO` | Optional | Default repository name |
## Telegram Commands
| Command | Description |
|---------|-------------|
| `/start` | Main menu |
| `/factory` | Start a new project (guided flow) |
| `/projects` | List existing projects |
| `/help` | Feature documentation |
| `/cancel` | Cancel current operation |
Or just send a message β€” the AI chat mode responds to any text.
## How It Works
1. **You describe a project** β€” "Build a REST API with FastAPI and SQLite"
2. **Project Manager** clarifies requirements (asks questions if needed)
3. **SDLC Orchestrator** creates a structured plan with tasks
4. **Software Developer** generates and validates code for each task
5. **Files are delivered** as Telegram documents you can download
## Project Structure
```
digital_factory/
β”œβ”€β”€ main.py # Entry point, Telegram bot setup
β”œβ”€β”€ config.py # Environment & settings
β”œβ”€β”€ models/ # Pydantic contracts (TaskRequest, ProjectSpec, etc.)
β”œβ”€β”€ agents/ # AI agents (Orchestrator, Developer, PM, Prompt Engineer)
β”œβ”€β”€ tools/ # Deterministic tools (linter, validator, GitHub, files)
β”œβ”€β”€ memory/ # 4-tier memory (short-term, project, knowledge, user LTM)
β”œβ”€β”€ bus/ # Async message bus
β”œβ”€β”€ telegram_ui/ # Telegram handlers & keyboards
└── utils/ # Helpers (safe_send, truncate)
```
## Legacy GitHub Manager
The original GitHub Manager bot is preserved in `githubbot.py` and includes:
### Repository Management
- πŸ“ Browse, view, edit, delete & download files
- πŸ“‹ View commits with diff details (files changed, additions/deletions)
- 🌿 Create & delete branches
- πŸ”€ Create PRs with branch selection & merge PRs
- πŸ”– Create & close issues
- πŸš€ Create releases
- πŸ“Š Repository stats (stars, forks, traffic, clones)
- πŸ” Search across your repositories
- πŸ“€ Upload multiple files via JSON
- ⚑ View GitHub Actions workflow runs & re-run failed workflows
### AI Assistant
- πŸ€– Multi-provider AI: Groq, DeepSeek, HuggingFace, Mistral
- πŸ’¬ Chat in Arabic & English β€” just type your message
- 🎀 Voice messages with Whisper transcription + Arabic TTS
- πŸ› οΈ AI can autonomously: read/create/delete files, create PRs, close issues, manage branches, search repos, view workflows
## Deployment
Runs on HuggingFace Spaces as a Docker container. Health check endpoint on port 7860.
```bash
# Local development
pip install -r requirements.txt
python -m digital_factory.main
```
## Roadmap
- **Phase 2**: Additional agents (ML Engineer, Data Analyst, Security, UI/UX Designer)
- **Phase 3**: RAG-based knowledge memory, external database support
- **Phase 4**: Self-Improvement cycle, Board of Directors governance
- **Phase 5**: Full 14-agent deployment with Kafka message bus