Files

1 line
34 KiB
JSON

{"repo": "athaxv/codeturtle", "files": {"README.md": {"ed61c197964759e8ad73fb8f45a0c1db39053f85": {"t": 1785747206.782274, "n": 13741, "h": "c728fed9d395681d", "c": "# 🐇 AI Code Review & Build Agent (CodeRabbit-like)\n\n> An event-driven, GitHub-native AI system that automatically reviews pull requests, suggests improvements, fixes issues, and scaffolds projects — all powered by LLMs and controlled via chat interfaces.\n\n[![Status](https://img.shields.io/badge/status-active%20development-orange)]()\n[![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue)]()\n[![Monorepo](https://img.shields.io/badge/monorepo-Turborepo-blueviolet)]()\n\n---\n\n## 🎯 What We're Building\n\nAn intelligent code review system that can:\n\n- ✅ **Automatically review GitHub Pull Requests** with inline, line-accurate comments\n- 🏗️ **Perform multi-file & architectural reasoning** across your codebase\n- 🔧 **Auto-fix PRs** by pushing commits directly\n- 🚀 **Generate repositories** from a chat command\n- 💬 **Be controlled via Telegram** for easy access\n- 🧠 **Learn repo-specific context** over time\n\n> **Note:** This is NOT GitHub Copilot. It's an autonomous review agent powered by LLM APIs (Claude/OpenAI/DeepSeek) and GitHub APIs.\n\n---\n\n## 🧠 Core Design Principles\n\n```mermaid\nmindmap\n root((AI Code Review Agent))\n Event-Driven\n GitHub Webhooks\n Async Jobs\n Real-time Processing\n Diff-First Reasoning\n Never dump full repos\n Focus on changes\n Token efficient\n Strong Separation\n Modular packages\n Clear boundaries\n Composable design\n LLM-Agnostic\n Multi-model routing\n Cost-aware\n Task-specific models\n```\n\n---\n\n## 🏗️ System Architecture\n\n### High-Level Component Diagram\n\n```mermaid\ngraph TB\n subgraph \"External Triggers\"\n GH[GitHub Webhook]\n TG[Telegram Bot]\n DASH[Dashboard UI]\n end\n \n subgraph \"Entry Points\"\n GHAPP[github-app<br/>Webhook Receiver]\n API[api<br/>Orchestration Layer]\n TGBOT[telegram-bot<br/>Chat Interface]\n end\n \n subgraph \"Processing Layer\"\n QUEUE[queue<br/>Async Jobs + BullMQ]\n REVIEW[review-engine<br/>PR Review Logic]\n BUILD[build-engine<br/>Repo Generation]\n end\n \n subgraph \"Intelligence Layer\"\n LLM[llm<br/>Model Routing]\n CONTEXT[context<br/>Repo Memory]\n end\n \n subgraph \"Data & Integration\"\n DB[(Database<br/>PostgreSQL)]\n GHAPI[github<br/>GitHub API Client]\n REDIS[(Redis)]\n end\n \n GH --> GHAPP\n TG --> TGBOT\n DASH -.-> API\n \n GHAPP --> QUEUE\n TGBOT --> API\n API --> QUEUE\n \n QUEUE --> REVIEW\n QUEUE --> BUILD\n \n REVIEW --> LLM\n BUILD --> LLM\n \n REVIEW --> CONTEXT\n BUILD --> CONTEXT\n \n LLM --> GHAPI\n REVIEW --> GHAPI\n BUILD --> GHAPI\n \n QUEUE --> REDIS\n REVIEW --> DB\n BUILD --> DB\n CONTEXT --> DB\n \n style REVIEW fill:#4CAF50\n style BUILD fill:#2196F3\n style LLM fill:#FF9800\n style QUEUE fill:#9C27B0\n```\n\n---\n\n## 📂 Monorepo Structure (Turborepo)\n\n```\n.\n├── apps/\n│ ├── api/ # Central orchestration API\n│ ├── github-app/ # GitHub App & webhook receiver\n│ ├── telegram-bot/ # Telegram chat interface\n│ └── dashboard/ # (Later) Admin & analytics UI\n│\n├── packages/\n│ ├── review-engine/ # PR review pipeline (core logic)\n│ ├── build-engine/ # Repo generation & auto-fix engine\n│ ├── llm/ # LLM routing, prompts, adapters\n│ ├── github/ # Typed GitHub API client\n│ ├── context/ # Repo memory & context management\n│ ├── queue/ # Async jobs & workers\n│ ├── db/ # Database schema & client\n│ ├── shared/ # Types, constants, utilities\n│ └── config/ # Env, feature flags, limits\n│\n├── infra/\n│ ├── docker/\n│ ├── migrations/\n│ └── workers/\n│\n└── tooling/\n ├── eslint/\n └── tsconfig/\n```\n\n---\n\n## 🔁 End-to-End Workflows\n\n### Workflow 1: Pull Request Review\n\n```mermaid\nsequenceDiagram\n participant GitHub\n participant WebhookApp as github-app\n participant Queue as queue (BullMQ)\n participant ReviewEngine as review-engine\n participant LLM as llm (Claude/GPT)\n participant GitHubAPI as GitHub API\n participant DB as Database\n\n GitHub->>WebhookApp: PR opened/updated event\n WebhookApp->>WebhookApp: Validate signature\n WebhookApp->>Queue: Enqueue review job\n Queue->>ReviewEngine: Process job\n ReviewEngine->>DB: Fetch repo context\n ReviewEngine->>GitHub: Get PR diff\n ReviewEngine->>LLM: Analyze diff + context\n LLM-->>ReviewEngine: Review suggestions\n ReviewEngine->>ReviewEngine: Map to line numbers\n ReviewEngine->>GitHubAPI: Post inline comments\n ReviewEngine->>DB: Save review metadata\n GitHubAPI-->>GitHub: Comments appear on PR\n```\n\n### Workflow 2: Telegram Command\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot as telegram-bot\n participant API as api\n participant Queue as queue\n participant ReviewEngine as review-engine\n participant GitHub as GitHub API\n\n User->>TelegramBot: /review pr=42\n TelegramBot->>TelegramBot: Parse command\n TelegramBot->>API: POST /review\n API->>API: Validate & auth\n API->>Queue: Enqueue job\n Queue->>ReviewEngine: Process review\n ReviewEngine->>GitHub: Fetch PR & post comments\n GitHub-->>TelegramBot: Success notification\n TelegramBot-->>User: ✅ Review completed\n```\n\n### Workflow 3: Auto-Fix PR\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot\n participant BuildEngine as build-engine\n participant LLM\n participant GitHub\n\n User->>TelegramBot: /fix pr=42\n TelegramBot->>BuildEngine: Trigger auto-fix\n BuildEngine->>GitHub: Fetch PR diff\n BuildEngine->>LLM: Generate fix patches\n LLM-->>BuildEngine: Code patches\n BuildEngine->>BuildEngine: Validate patches\n BuildEngine->>GitHub: Create commit\n BuildEngine->>GitHub: Push to PR branch\n GitHub-->>User: PR updated with fixes\n```\n\n### Workflow 4: Repository Scaffolding\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot\n participant BuildEngine as build-engine\n participant LLM\n participant GitHub\n\n User->>TelegramBot: /build \"Next.js SaaS with auth\"\n TelegramBot->>BuildEngine: Initiate repo generation\n BuildEngine->>LLM: Generate project structure\n LLM-->>BuildEngine: File tree + templates\n BuildEngine->>BuildEngine: Generate files incrementally\n BuildEngine->>GitHub: Create repository\n BuildEngine->>GitHub: Push initial commit\n GitHub-->>User: Repository created\n TelegramBot-->>User: 🎉 Project ready!\n```\n\n---\n\n## 📦 Package Responsibilities\n\n### Apps Layer\n\n| Package | Responsibility | Tech Stack |\n|---------|---------------|------------|\n| **github-app** | Receive webhooks, validate signatures, enqueue jobs | Node.js, Fastify, GitHub App Auth |\n| **api** | Orchestration, job dispatching, auth & rate limits | Node.js, Fastify, Zod |\n| **telegram-bot** | Chat interface, command parsing | node-telegram-bot-api |\n| **dashboard** | Admin UI, analytics (future) | Next.js |\n\n### Core Packages\n\n| Package | Purpose | Key Features |\n|---------|---------|--------------|\n| **review-engine** | PR review intelligence | File-level reasoning, comment normalization |\n| **build-engine** | Repo scaffolding & auto-fixing | Folder generation, LLM patch application |\n| **llm** | Model abstraction & routing | Prompt management, cost control, multi-model |\n| **github** | Typed GitHub API wrapper | PR diffs, inline comments, commits |\n| **context** | Repo-specific memory | Rules, preferences, learning over time |\n| **queue** | Async processing | Retries, backoff, rate-limit protection (BullMQ) |\n| **db** | Data persistence | Review jobs, repo metadata (PostgreSQL) |\n\n### LLM Routing Logic\n\n```mermaid\nflowchart TD\n Start{Task Type?}\n Start -->|Quick Review| DeepSeek[DeepSeek<br/>Fast & Cheap]\n Start -->|Security Analysis| Claude[Claude<br/>Deep Reasoning]\n Start -->|Architecture Review| GPT4[GPT-4<br/>Complex Logic]\n Start -->|Code Generation| Claude\n \n DeepSeek --> Cost[💰 Low Cost]\n Claude --> Quality[⭐ High Quality]\n GPT4 --> Complex[🧠 Complex Tasks]\n \n style DeepSeek fill:#4CAF50\n style Claude fill:#2196F3\n style GPT4 fill:#FF9800\n```\n\n---\n\n## 🗄️ Data Models\n\n```mermaid\nerDiagram\n Repo ||--o{ PullRequest : contains\n PullRequest ||--o{ ReviewJob : triggers\n ReviewJob ||--o{ ReviewComment : produces\n Repo ||--o{ Context : has\n \n Repo {\n uuid id\n string owner\n string name\n string language\n string framework\n }\n \n PullRequest {\n uuid id\n uuid repoId\n int number\n string baseSha\n string headSha\n datetime createdAt\n }\n \n ReviewJob {\n uuid id\n uuid prId\n enum trigger\n enum status\n string modelUsed\n datetime startedAt\n datetime completedAt\n }\n \n ReviewComment {\n uuid id\n uuid jobId\n string filePath\n int line\n text body\n enum severity\n }\n \n Context {\n uuid id\n uuid repoId\n json rules\n json preferences\n json previousFeedback\n }\n```\n\n---\n\n## 🛠️ Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| **Backend** | Node.js, TypeScript, Fastify |\n| **Monorepo** | Turborepo |\n| **Queue** | BullMQ + Redis |\n| **Database** | PostgreSQL |\n| **ORM** | Prisma / Drizzle |\n| **LLMs** | Claude, OpenAI, DeepSeek |\n| **Bots** | Telegram Bot API |\n| **Auth** | GitHub App |\n| **Infrastructure** | Docker, Docker Compose |\n\n---\n\n## 🚧 Development Phases\n\n```mermaid\ngantt\n title Development Roadmap\n dateFormat YYYY-MM-DD\n section Phase 1 - MVP\n GitHub App Setup :a1, 2024-01-01, 30d\n PR Reviews via Webhook :a2, after a1, 30d\n Inline Comments :a3, after a2, 20d\n Single LLM Integration :a4, after a2, 20d\n \n section Phase 2\n Telegram Commands :b1, after a4, 30d\n Manual Triggers :b2, after b1, 15d\n Repo Context Memory :b3, after b1, 30d\n \n section Phase 3\n Auto-fix PRs :c1, after b3, 45d\n Commit Patches :c2, after c1, 30d\n Multi-model Routing :c3, after c1, 30d\n \n section Phase 4\n Repo Scaffolding :d1, after c3, 45d\n Dashboard UI :d2, after c3, 60d\n Org-level Support :d3, after d2, 30d\n```\n\n### Phase Breakdown\n\n| Phase | Features | Status |\n|-------|----------|--------|\n| **Phase 1 - MVP** | GitHub App, PR reviews, inline comments, single LLM | 🚧 In Progress |\n| **Phase 2** | Telegram commands, manual triggers, repo memory | 📋 Planned |\n| **Phase 3** | Auto-fix PRs, multi-model routing, commit patches | 📋 Planned |\n| **Phase 4** | Repo scaffolding, dashboard, org support | 📋 Planned |\n\n---\n\n## 🧠 LLM Guidelines & Best Practices\n\n```mermaid\nmindmap\n root((Review<br/>Guidelines))\n Efficiency\n Never review entire repos\n Always reason from diffs\n Token-efficient prompts\n Quality\n Fewer, higher-quality comments\n Architecture over style nitpicks\n Valid diff line mapping\n Priority\n Security First\n Then Performance\n Then Readability\n```\n\n### Priority Hierarchy\n\n1. **Security** → Vulnerabilities, injection risks, auth issues\n2. **Performance** → N+1 queries, memory leaks, inefficient algorithms\n3. **Readability** → Naming, structure, maintainability\n\n---\n\n## ❗ Non-Goals\n\n- ❌ **Not GitHub Copilot** - We don't provide inline code completion\n- ❌ **No background repo scanning** - Event-driven only\n- ❌ **No direct code execution** - Reviews only, no arbitrary code running\n- ❌ **No auto-merge approvals** - Human oversight required\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n```bash\n# Required\n- Node.js 18+\n- PostgreSQL 14+\n- Redis 7+\n- GitHub App credentials\n- LLM API keys (Claude/OpenAI/DeepSeek)\n```\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone <repo-url>\ncd <repo-name>\n\n# Install dependencies\nnpm install\n\n# Set up environment variables\ncp .env.example .env\n\n# Run database migrations\nnpm run db:migrate\n\n# Start development servers\nnpm run dev\n```\n\n### Configuration\n\n```bash\n# .env file\nGITHUB_APP_ID=your_app_id\nGITHUB_APP_PRIVATE_KEY=your_private_key\nGITHUB_WEBHOOK_SECRET=your_webhook_secret\n\nANTHROPIC_API_KEY=your_claude_key\nOPENAI_API_KEY=your_openai_key\nDEEPSEEK_API_KEY=your_deepseek_key\n\nDATABASE_URL=postgresql://user:pass@localhost:5432/db\nREDIS_URL=redis://localhost:6379\n\nTELEGRAM_BOT_TOKEN=your_bot_token\n```\n\n---\n\n## 📊 System Flow Summary\n\n```mermaid\nflowchart LR\n A[External Event] --> B{Event Type?}\n B -->|GitHub Webhook| C[github-app]\n B -->|Telegram Command| D[telegram-bot]\n B -->|API Call| E[api]\n \n C --> F[Queue Job]\n D --> E\n E --> F\n \n F --> G{Job Type?}\n G -->|Review| H[review-engine]\n G -->|Build| I[build-engine]\n G -->|Fix| I\n \n H --> J[LLM Processing]\n I --> J\n \n J --> K[GitHub API]\n K --> L[Result Posted]\n \n H --> M[(Database)]\n I --> M\n \n style H fill:#4CAF50\n style I fill:#2196F3\n style J fill:#FF9800\n style F fill:#9C27B0\n```\n\n---\n\n## 📌 Project Status\n\n🚧 **Early active development** - This is a research-grade → production-grade system under construction.\n\n### Current Focus\n- Setting up core infrastructure\n- Implementing Phase 1 features\n- Building MVP with basic PR review capabilities\n\n### Contributing\nContributions are welcome! Please check the issues tab for open tasks.\n\n---\n\n## 📝 License\n\n[Your License Here]\n\n---\n\n## 🙏 Acknowledgments\n\nInspired by [CodeRabbit](https://coderabbit.ai) and other AI code review tools.\n\n---\n\n**Built with ❤️ using TypeScript, LLMs, and GitHub APIs**"}, "fed11991e97094844824101e01320e1057fc1ec9": {"t": 1785771373.8846662, "n": 13741, "h": "c728fed9d395681d", "c": "# 🐇 AI Code Review & Build Agent (CodeRabbit-like)\n\n> An event-driven, GitHub-native AI system that automatically reviews pull requests, suggests improvements, fixes issues, and scaffolds projects — all powered by LLMs and controlled via chat interfaces.\n\n[![Status](https://img.shields.io/badge/status-active%20development-orange)]()\n[![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue)]()\n[![Monorepo](https://img.shields.io/badge/monorepo-Turborepo-blueviolet)]()\n\n---\n\n## 🎯 What We're Building\n\nAn intelligent code review system that can:\n\n- ✅ **Automatically review GitHub Pull Requests** with inline, line-accurate comments\n- 🏗️ **Perform multi-file & architectural reasoning** across your codebase\n- 🔧 **Auto-fix PRs** by pushing commits directly\n- 🚀 **Generate repositories** from a chat command\n- 💬 **Be controlled via Telegram** for easy access\n- 🧠 **Learn repo-specific context** over time\n\n> **Note:** This is NOT GitHub Copilot. It's an autonomous review agent powered by LLM APIs (Claude/OpenAI/DeepSeek) and GitHub APIs.\n\n---\n\n## 🧠 Core Design Principles\n\n```mermaid\nmindmap\n root((AI Code Review Agent))\n Event-Driven\n GitHub Webhooks\n Async Jobs\n Real-time Processing\n Diff-First Reasoning\n Never dump full repos\n Focus on changes\n Token efficient\n Strong Separation\n Modular packages\n Clear boundaries\n Composable design\n LLM-Agnostic\n Multi-model routing\n Cost-aware\n Task-specific models\n```\n\n---\n\n## 🏗️ System Architecture\n\n### High-Level Component Diagram\n\n```mermaid\ngraph TB\n subgraph \"External Triggers\"\n GH[GitHub Webhook]\n TG[Telegram Bot]\n DASH[Dashboard UI]\n end\n \n subgraph \"Entry Points\"\n GHAPP[github-app<br/>Webhook Receiver]\n API[api<br/>Orchestration Layer]\n TGBOT[telegram-bot<br/>Chat Interface]\n end\n \n subgraph \"Processing Layer\"\n QUEUE[queue<br/>Async Jobs + BullMQ]\n REVIEW[review-engine<br/>PR Review Logic]\n BUILD[build-engine<br/>Repo Generation]\n end\n \n subgraph \"Intelligence Layer\"\n LLM[llm<br/>Model Routing]\n CONTEXT[context<br/>Repo Memory]\n end\n \n subgraph \"Data & Integration\"\n DB[(Database<br/>PostgreSQL)]\n GHAPI[github<br/>GitHub API Client]\n REDIS[(Redis)]\n end\n \n GH --> GHAPP\n TG --> TGBOT\n DASH -.-> API\n \n GHAPP --> QUEUE\n TGBOT --> API\n API --> QUEUE\n \n QUEUE --> REVIEW\n QUEUE --> BUILD\n \n REVIEW --> LLM\n BUILD --> LLM\n \n REVIEW --> CONTEXT\n BUILD --> CONTEXT\n \n LLM --> GHAPI\n REVIEW --> GHAPI\n BUILD --> GHAPI\n \n QUEUE --> REDIS\n REVIEW --> DB\n BUILD --> DB\n CONTEXT --> DB\n \n style REVIEW fill:#4CAF50\n style BUILD fill:#2196F3\n style LLM fill:#FF9800\n style QUEUE fill:#9C27B0\n```\n\n---\n\n## 📂 Monorepo Structure (Turborepo)\n\n```\n.\n├── apps/\n│ ├── api/ # Central orchestration API\n│ ├── github-app/ # GitHub App & webhook receiver\n│ ├── telegram-bot/ # Telegram chat interface\n│ └── dashboard/ # (Later) Admin & analytics UI\n│\n├── packages/\n│ ├── review-engine/ # PR review pipeline (core logic)\n│ ├── build-engine/ # Repo generation & auto-fix engine\n│ ├── llm/ # LLM routing, prompts, adapters\n│ ├── github/ # Typed GitHub API client\n│ ├── context/ # Repo memory & context management\n│ ├── queue/ # Async jobs & workers\n│ ├── db/ # Database schema & client\n│ ├── shared/ # Types, constants, utilities\n│ └── config/ # Env, feature flags, limits\n│\n├── infra/\n│ ├── docker/\n│ ├── migrations/\n│ └── workers/\n│\n└── tooling/\n ├── eslint/\n └── tsconfig/\n```\n\n---\n\n## 🔁 End-to-End Workflows\n\n### Workflow 1: Pull Request Review\n\n```mermaid\nsequenceDiagram\n participant GitHub\n participant WebhookApp as github-app\n participant Queue as queue (BullMQ)\n participant ReviewEngine as review-engine\n participant LLM as llm (Claude/GPT)\n participant GitHubAPI as GitHub API\n participant DB as Database\n\n GitHub->>WebhookApp: PR opened/updated event\n WebhookApp->>WebhookApp: Validate signature\n WebhookApp->>Queue: Enqueue review job\n Queue->>ReviewEngine: Process job\n ReviewEngine->>DB: Fetch repo context\n ReviewEngine->>GitHub: Get PR diff\n ReviewEngine->>LLM: Analyze diff + context\n LLM-->>ReviewEngine: Review suggestions\n ReviewEngine->>ReviewEngine: Map to line numbers\n ReviewEngine->>GitHubAPI: Post inline comments\n ReviewEngine->>DB: Save review metadata\n GitHubAPI-->>GitHub: Comments appear on PR\n```\n\n### Workflow 2: Telegram Command\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot as telegram-bot\n participant API as api\n participant Queue as queue\n participant ReviewEngine as review-engine\n participant GitHub as GitHub API\n\n User->>TelegramBot: /review pr=42\n TelegramBot->>TelegramBot: Parse command\n TelegramBot->>API: POST /review\n API->>API: Validate & auth\n API->>Queue: Enqueue job\n Queue->>ReviewEngine: Process review\n ReviewEngine->>GitHub: Fetch PR & post comments\n GitHub-->>TelegramBot: Success notification\n TelegramBot-->>User: ✅ Review completed\n```\n\n### Workflow 3: Auto-Fix PR\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot\n participant BuildEngine as build-engine\n participant LLM\n participant GitHub\n\n User->>TelegramBot: /fix pr=42\n TelegramBot->>BuildEngine: Trigger auto-fix\n BuildEngine->>GitHub: Fetch PR diff\n BuildEngine->>LLM: Generate fix patches\n LLM-->>BuildEngine: Code patches\n BuildEngine->>BuildEngine: Validate patches\n BuildEngine->>GitHub: Create commit\n BuildEngine->>GitHub: Push to PR branch\n GitHub-->>User: PR updated with fixes\n```\n\n### Workflow 4: Repository Scaffolding\n\n```mermaid\nsequenceDiagram\n participant User\n participant TelegramBot\n participant BuildEngine as build-engine\n participant LLM\n participant GitHub\n\n User->>TelegramBot: /build \"Next.js SaaS with auth\"\n TelegramBot->>BuildEngine: Initiate repo generation\n BuildEngine->>LLM: Generate project structure\n LLM-->>BuildEngine: File tree + templates\n BuildEngine->>BuildEngine: Generate files incrementally\n BuildEngine->>GitHub: Create repository\n BuildEngine->>GitHub: Push initial commit\n GitHub-->>User: Repository created\n TelegramBot-->>User: 🎉 Project ready!\n```\n\n---\n\n## 📦 Package Responsibilities\n\n### Apps Layer\n\n| Package | Responsibility | Tech Stack |\n|---------|---------------|------------|\n| **github-app** | Receive webhooks, validate signatures, enqueue jobs | Node.js, Fastify, GitHub App Auth |\n| **api** | Orchestration, job dispatching, auth & rate limits | Node.js, Fastify, Zod |\n| **telegram-bot** | Chat interface, command parsing | node-telegram-bot-api |\n| **dashboard** | Admin UI, analytics (future) | Next.js |\n\n### Core Packages\n\n| Package | Purpose | Key Features |\n|---------|---------|--------------|\n| **review-engine** | PR review intelligence | File-level reasoning, comment normalization |\n| **build-engine** | Repo scaffolding & auto-fixing | Folder generation, LLM patch application |\n| **llm** | Model abstraction & routing | Prompt management, cost control, multi-model |\n| **github** | Typed GitHub API wrapper | PR diffs, inline comments, commits |\n| **context** | Repo-specific memory | Rules, preferences, learning over time |\n| **queue** | Async processing | Retries, backoff, rate-limit protection (BullMQ) |\n| **db** | Data persistence | Review jobs, repo metadata (PostgreSQL) |\n\n### LLM Routing Logic\n\n```mermaid\nflowchart TD\n Start{Task Type?}\n Start -->|Quick Review| DeepSeek[DeepSeek<br/>Fast & Cheap]\n Start -->|Security Analysis| Claude[Claude<br/>Deep Reasoning]\n Start -->|Architecture Review| GPT4[GPT-4<br/>Complex Logic]\n Start -->|Code Generation| Claude\n \n DeepSeek --> Cost[💰 Low Cost]\n Claude --> Quality[⭐ High Quality]\n GPT4 --> Complex[🧠 Complex Tasks]\n \n style DeepSeek fill:#4CAF50\n style Claude fill:#2196F3\n style GPT4 fill:#FF9800\n```\n\n---\n\n## 🗄️ Data Models\n\n```mermaid\nerDiagram\n Repo ||--o{ PullRequest : contains\n PullRequest ||--o{ ReviewJob : triggers\n ReviewJob ||--o{ ReviewComment : produces\n Repo ||--o{ Context : has\n \n Repo {\n uuid id\n string owner\n string name\n string language\n string framework\n }\n \n PullRequest {\n uuid id\n uuid repoId\n int number\n string baseSha\n string headSha\n datetime createdAt\n }\n \n ReviewJob {\n uuid id\n uuid prId\n enum trigger\n enum status\n string modelUsed\n datetime startedAt\n datetime completedAt\n }\n \n ReviewComment {\n uuid id\n uuid jobId\n string filePath\n int line\n text body\n enum severity\n }\n \n Context {\n uuid id\n uuid repoId\n json rules\n json preferences\n json previousFeedback\n }\n```\n\n---\n\n## 🛠️ Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| **Backend** | Node.js, TypeScript, Fastify |\n| **Monorepo** | Turborepo |\n| **Queue** | BullMQ + Redis |\n| **Database** | PostgreSQL |\n| **ORM** | Prisma / Drizzle |\n| **LLMs** | Claude, OpenAI, DeepSeek |\n| **Bots** | Telegram Bot API |\n| **Auth** | GitHub App |\n| **Infrastructure** | Docker, Docker Compose |\n\n---\n\n## 🚧 Development Phases\n\n```mermaid\ngantt\n title Development Roadmap\n dateFormat YYYY-MM-DD\n section Phase 1 - MVP\n GitHub App Setup :a1, 2024-01-01, 30d\n PR Reviews via Webhook :a2, after a1, 30d\n Inline Comments :a3, after a2, 20d\n Single LLM Integration :a4, after a2, 20d\n \n section Phase 2\n Telegram Commands :b1, after a4, 30d\n Manual Triggers :b2, after b1, 15d\n Repo Context Memory :b3, after b1, 30d\n \n section Phase 3\n Auto-fix PRs :c1, after b3, 45d\n Commit Patches :c2, after c1, 30d\n Multi-model Routing :c3, after c1, 30d\n \n section Phase 4\n Repo Scaffolding :d1, after c3, 45d\n Dashboard UI :d2, after c3, 60d\n Org-level Support :d3, after d2, 30d\n```\n\n### Phase Breakdown\n\n| Phase | Features | Status |\n|-------|----------|--------|\n| **Phase 1 - MVP** | GitHub App, PR reviews, inline comments, single LLM | 🚧 In Progress |\n| **Phase 2** | Telegram commands, manual triggers, repo memory | 📋 Planned |\n| **Phase 3** | Auto-fix PRs, multi-model routing, commit patches | 📋 Planned |\n| **Phase 4** | Repo scaffolding, dashboard, org support | 📋 Planned |\n\n---\n\n## 🧠 LLM Guidelines & Best Practices\n\n```mermaid\nmindmap\n root((Review<br/>Guidelines))\n Efficiency\n Never review entire repos\n Always reason from diffs\n Token-efficient prompts\n Quality\n Fewer, higher-quality comments\n Architecture over style nitpicks\n Valid diff line mapping\n Priority\n Security First\n Then Performance\n Then Readability\n```\n\n### Priority Hierarchy\n\n1. **Security** → Vulnerabilities, injection risks, auth issues\n2. **Performance** → N+1 queries, memory leaks, inefficient algorithms\n3. **Readability** → Naming, structure, maintainability\n\n---\n\n## ❗ Non-Goals\n\n- ❌ **Not GitHub Copilot** - We don't provide inline code completion\n- ❌ **No background repo scanning** - Event-driven only\n- ❌ **No direct code execution** - Reviews only, no arbitrary code running\n- ❌ **No auto-merge approvals** - Human oversight required\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n```bash\n# Required\n- Node.js 18+\n- PostgreSQL 14+\n- Redis 7+\n- GitHub App credentials\n- LLM API keys (Claude/OpenAI/DeepSeek)\n```\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone <repo-url>\ncd <repo-name>\n\n# Install dependencies\nnpm install\n\n# Set up environment variables\ncp .env.example .env\n\n# Run database migrations\nnpm run db:migrate\n\n# Start development servers\nnpm run dev\n```\n\n### Configuration\n\n```bash\n# .env file\nGITHUB_APP_ID=your_app_id\nGITHUB_APP_PRIVATE_KEY=your_private_key\nGITHUB_WEBHOOK_SECRET=your_webhook_secret\n\nANTHROPIC_API_KEY=your_claude_key\nOPENAI_API_KEY=your_openai_key\nDEEPSEEK_API_KEY=your_deepseek_key\n\nDATABASE_URL=postgresql://user:pass@localhost:5432/db\nREDIS_URL=redis://localhost:6379\n\nTELEGRAM_BOT_TOKEN=your_bot_token\n```\n\n---\n\n## 📊 System Flow Summary\n\n```mermaid\nflowchart LR\n A[External Event] --> B{Event Type?}\n B -->|GitHub Webhook| C[github-app]\n B -->|Telegram Command| D[telegram-bot]\n B -->|API Call| E[api]\n \n C --> F[Queue Job]\n D --> E\n E --> F\n \n F --> G{Job Type?}\n G -->|Review| H[review-engine]\n G -->|Build| I[build-engine]\n G -->|Fix| I\n \n H --> J[LLM Processing]\n I --> J\n \n J --> K[GitHub API]\n K --> L[Result Posted]\n \n H --> M[(Database)]\n I --> M\n \n style H fill:#4CAF50\n style I fill:#2196F3\n style J fill:#FF9800\n style F fill:#9C27B0\n```\n\n---\n\n## 📌 Project Status\n\n🚧 **Early active development** - This is a research-grade → production-grade system under construction.\n\n### Current Focus\n- Setting up core infrastructure\n- Implementing Phase 1 features\n- Building MVP with basic PR review capabilities\n\n### Contributing\nContributions are welcome! Please check the issues tab for open tasks.\n\n---\n\n## 📝 License\n\n[Your License Here]\n\n---\n\n## 🙏 Acknowledgments\n\nInspired by [CodeRabbit](https://coderabbit.ai) and other AI code review tools.\n\n---\n\n**Built with ❤️ using TypeScript, LLMs, and GitHub APIs**"}, "df428696e8c0b33b3124319b05214cf94ac88d77": {"t": 1785771375.3071573, "n": 5020, "h": "ab75820cbaf7a9ab", "c": "# Turborepo starter\n\nThis Turborepo starter is maintained by the Turborepo core team.\n\n## Using this example\n\nRun the following command:\n\n```sh\nnpx create-turbo@latest\n```\n\n## What's inside?\n\nThis Turborepo includes the following packages/apps:\n\n### Apps and Packages\n\n- `docs`: a [Next.js](https://nextjs.org/) app\n- `web`: another [Next.js](https://nextjs.org/) app\n- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications\n- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)\n- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo\n\nEach package/app is 100% [TypeScript](https://www.typescriptlang.org/).\n\n### Utilities\n\nThis Turborepo has some additional tools already setup for you:\n\n- [TypeScript](https://www.typescriptlang.org/) for static type checking\n- [ESLint](https://eslint.org/) for code linting\n- [Prettier](https://prettier.io) for code formatting\n\n### Build\n\nTo build all apps and packages, run the following command:\n\n```\ncd my-turborepo\n\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo build\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo build\nyarn dlx turbo build\npnpm exec turbo build\n```\n\nYou can build a specific package by using a [filter](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters):\n\n```\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo build --filter=docs\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo build --filter=docs\nyarn exec turbo build --filter=docs\npnpm exec turbo build --filter=docs\n```\n\n### Develop\n\nTo develop all apps and packages, run the following command:\n\n```\ncd my-turborepo\n\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo dev\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo dev\nyarn exec turbo dev\npnpm exec turbo dev\n```\n\nYou can develop a specific package by using a [filter](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters):\n\n```\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo dev --filter=web\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo dev --filter=web\nyarn exec turbo dev --filter=web\npnpm exec turbo dev --filter=web\n```\n\n### Remote Caching\n\n> [!TIP]\n> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache).\n\nTurborepo can use a technique known as [Remote Caching](https://turborepo.dev/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.\n\nBy default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands:\n\n```\ncd my-turborepo\n\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo login\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo login\nyarn exec turbo login\npnpm exec turbo login\n```\n\nThis will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).\n\nNext, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:\n\n```\n# With [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation) installed (recommended)\nturbo link\n\n# Without [global `turbo`](https://turborepo.dev/docs/getting-started/installation#global-installation), use your package manager\nnpx turbo link\nyarn exec turbo link\npnpm exec turbo link\n```\n\n## Useful Links\n\nLearn more about the power of Turborepo:\n\n- [Tasks](https://turborepo.dev/docs/crafting-your-repository/running-tasks)\n- [Caching](https://turborepo.dev/docs/crafting-your-repository/caching)\n- [Remote Caching](https://turborepo.dev/docs/core-concepts/remote-caching)\n- [Filtering](https://turborepo.dev/docs/crafting-your-repository/running-tasks#using-filters)\n- [Configuration Options](https://turborepo.dev/docs/reference/configuration)\n- [CLI Usage](https://turborepo.dev/docs/reference/command-line-reference)\n"}}}}