-The bot responds to user commands with real-time GitHub contribution data
-
-## What We Built
-
-Disgitbot is a comprehensive Discord bot that integrates GitHub activity with Discord communities. It's not just another botβit's a complete workflow automation system that handles everything from contribution tracking to AI-powered code review.
-
-The project was completed as part of Google Summer of Code 2025, working with Uramaki LAB to create something that would actually make developers' lives easier.
-
-
-The complete data collection and processing pipeline
-
-## The Core Architecture
-
-At its heart, Disgitbot runs on a clean, modular architecture. We built it using dependency injection, design patterns, and single responsibility principles. Each component has one clear job, making the system easy to test, maintain, and extend.
-
-The bot connects to GitHub's API, processes the data through a custom pipeline, stores everything in Firestore, and then updates Discord automatically. It's like having a personal assistant that never sleeps.
-
-
-GitHub Actions workflow that powers the entire system
-
-## Six Major Features, One Bot
-
-### 1. Real-Time Contribution Tracking
-
-The bot collects data from all your GitHub repositoriesβevery pull request, issue, and commit. It processes this information to calculate rankings, streaks, and activity patterns.
-
-```mermaid
-graph TD
- A["GitHub Repositories
-Automatic role assignment based on GitHub contributions
-
-```mermaid
-graph TD
- A["GitHub Actions Trigger
-AI-powered PR review and automation
-
-```mermaid
-graph TD
- A["Pull Request Event
-AI-powered automatic label assignment
-
-```mermaid
-graph TD
- A["Pull Request Trigger
-Real-time repository metrics displayed in Discord
-
-```mermaid
-graph TD
- A["Daily Pipeline Trigger
-Interactive analytics and contributor insights
-
-
-Top contributors leaderboard
-
-```mermaid
-graph TD
- A["Contribution Data
-Data processing and transformation pipeline
-
-### AI Integration
-
-We use Google's Gemini API for intelligent analysis. The AI examines code changes, understands context, and makes informed decisions about labeling and review assignments. It's trained on your specific repository structure, so it gets better over time.
-
-### Discord Integration
-
-The bot connects to Discord using their official API and manages everything from role assignments to channel updates. It handles authentication, permissions, and user management automatically.
-
-## Deployment and Cost Optimization
-
-The bot runs on Google Cloud Run with request-based billing, meaning it only costs money when it's actually processing requests. During idle time, it scales to zero instances, keeping costs minimal.
-
-We've optimized the deployment process with a comprehensive script that handles everything from environment setup to service deployment. The bot automatically manages its own scaling and resource allocation.
-
-
-Cloud deployment and monitoring logs
-
-## Real-World Impact
-
-Since deploying Disgitbot, we've seen some real improvements:
-- **Faster PR reviews** thanks to automatic labeling and reviewer assignment
-- **Increased engagement** as contributors see their progress reflected in real-time
-- **Better project visibility** through live metrics and analytics
-- **Reduced administrative overhead** as the bot handles routine tasks automatically
-
-## What's Next
-
-The project is designed to be extensible. We can easily add new features like:
-- Integration with other project management tools
-- More sophisticated AI analysis
-- Custom analytics dashboards
-- Integration with CI/CD pipelines
-
-## Conclusion
-
-Disgitbot shows what happens when you combine modern cloud infrastructure, AI capabilities, and thoughtful design. It's not just a botβit's a complete workflow automation system that makes development teams more productive and engaged.
-
-The project demonstrates how AI can be used to solve real problems in software development, not just generate code or answer questions. By automating the routine aspects of project management, it frees developers to focus on what they do best: building great software.
-
-You can try the bot yourself in the [RUXAILAB Discord Server](https://discord.gg/VAxzZxVV), or explore the code on [GitHub](https://github.com/ruxailab/disgitbot).
-
----
-
-*This project was completed as part of Google Summer of Code 2025 with Uramaki LAB. Special thanks to the mentors and community members who provided guidance and feedback throughout the development process.*
diff --git a/discord_bot/ARCHITECTURE.md b/discord_bot/ARCHITECTURE.md
index 229d943..ce23a5c 100644
--- a/discord_bot/ARCHITECTURE.md
+++ b/discord_bot/ARCHITECTURE.md
@@ -61,25 +61,25 @@ discord_bot/src/
## Design Principles Enforced
-### Single Responsibility Principle β
+### Single Responsibility Principle
- Each class/module has **one clear purpose**
- `UserCommands` only handles user interactions
- `FirestoreService` only manages database operations
- `ContributionProcessor` only processes contribution data
-### Open/Closed Principle β
+### Open/Closed Principle
- **Extensible without modification**
- Add new pipeline stages without changing orchestrator
- Add new chart types without modifying existing generators
- Add new Discord commands without touching existing ones
-### Dependency Inversion β
+### Dependency Inversion
- **Depend on abstractions, not concretions**
- Services depend on `IStorageService` interface
- Pipeline stages inject dependencies via constructor
- Clear interface boundaries
-### Interface Segregation β
+### Interface Segregation
- **Small, focused interfaces**
- `IStorageService` only database operations
- `IDiscordService` only Discord operations
@@ -114,22 +114,22 @@ user_commands.register_commands()
## Benefits Achieved
-### π§ͺ **Testability**
+###**Testability**
- **Dependency injection** enables clean testing
- **Small, focused methods** are simple to test
- **Interface-based design** allows test doubles
-### π§ **Maintainability**
+###**Maintainability**
- **Single responsibility** makes changes predictable
- **Loose coupling** prevents cascading changes
- **Clear interfaces** document expected behavior
-### π **Scalability**
+###**Scalability**
- **Add new pipeline stages** without touching existing code
- **Add new Discord commands** via new command modules
- **Add new storage backends** by implementing interfaces
-### π **Reusability**
+###**Reusability**
- **Services can be used independently** across modules
- **Processors are composable** and reusable
- **Chart generators follow consistent patterns**
diff --git a/discord_bot/README.md b/discord_bot/README.md
index 08923cc..6ed7753 100644
--- a/discord_bot/README.md
+++ b/discord_bot/README.md
@@ -1,5 +1,24 @@
# Discord Bot Setup Guide
+# Quick Start (Hosted Bot Users)
+
+Use this section if you only want to invite the hosted bot and use it in your Discord server.
+
+1. **Invite the bot** using the link provided by the maintainers.
+2. In your Discord server, run: `/setup`
+3. Click **Install GitHub App** and select the org/repo(s) to track.
+4. Each user links their GitHub account with: `/link`
+5. (Optional) Configure role rules:
+ ```
+ /configure roles action:add metric:commits threshold:1 role:@Contributor
+ /configure roles action:add metric:prs threshold:10 role:@ActiveContributor
+ /configure roles action:add metric:prs threshold:50 role:@CoreTeam
+ ```
+
+Thatβs it. No local setup, no tokens, no config files.
+
+**Note:** This section is for maintainers (RUXAILAB) or anyone who wants to run/modify the code themselves. If you only want to use the hosted bot, use the **Quick Start (Hosted Bot Users)** section above and skip the prerequisites.
+
# 1. Prerequisites
### Python 3.13 Setup
@@ -105,11 +124,14 @@ cp discord_bot/config/.env.example discord_bot/config/.env
**Your `.env` file needs these values:**
- `DISCORD_BOT_TOKEN=` (Discord bot authentication)
-- `GITHUB_TOKEN=` (GitHub API access)
+- `GITHUB_TOKEN=` (Github API access)
- `GITHUB_CLIENT_ID=` (GitHub OAuth app ID)
- `GITHUB_CLIENT_SECRET=` (GitHub OAuth app secret)
-- `REPO_OWNER=` (Your GitHub organization name)
+- `GITHUB_APP_ID=` (GitHub App ID)
+- `GITHUB_APP_PRIVATE_KEY_B64=` (GitHub App private key, base64)
+- `GITHUB_APP_SLUG=` (GitHub App slug)
- `OAUTH_BASE_URL=` (Your Cloud Run URL - set in Step 4)
+- `REPO_OWNER=` (Owner of the Disgitbot repo that hosts the workflow dispatch. Ex: ruxailab)
**Additional files you need:**
- `discord_bot/config/credentials.json` (Firebase/Google Cloud credentials)
@@ -117,10 +139,18 @@ cp discord_bot/config/.env.example discord_bot/config/.env
**GitHub repository secrets you need to configure:**
Go to your GitHub repository β Settings β Secrets and variables β Actions β Click "New repository secret" for each:
- `DISCORD_BOT_TOKEN`
-- `GH_TOKEN`
+- `GH_TOKEN`
- `GOOGLE_CREDENTIALS_JSON`
- `REPO_OWNER`
- `CLOUD_RUN_URL`
+- `GH_APP_ID`
+- `GH_APP_PRIVATE_KEY_B64`
+
+If you plan to run GitHub Actions from branches other than `main`, also add the matching development secrets so the workflows can deploy correctly:
+- `DEV_GOOGLE_CREDENTIALS_JSON`
+- `DEV_CLOUD_RUN_URL`
+
+> The workflows only reference `GH_TOKEN`, so you can reuse the same PAT for all branches.
---
@@ -167,6 +197,10 @@ Go to your GitHub repository β Settings β Secrets and variables β Actions
- Click "Reset Token" β Copy the token
- **Add to `.env`:** `DISCORD_BOT_TOKEN=your_token_here`
- **Add to GitHub Secrets:** Create secret named `DISCORD_BOT_TOKEN`
+8. **Grab the Discord bot client ID:**
+ - Stay in the same Discord application and open the **General Information** tab
+ - Copy the **Application ID** (this is sometimes labeled "Client ID")
+ - **Add to `.env`:** `DISCORD_BOT_CLIENT_ID=your_application_id`
### Step 2: Get credentials.json (config file) + GOOGLE_CREDENTIALS_JSON (GitHub Secret)
@@ -214,6 +248,7 @@ Go to your GitHub repository β Settings β Secrets and variables β Actions
- Paste the JSON content and encode it to base64
- Copy the base64 string
- **Add to GitHub Secrets:** Create secret named `GOOGLE_CREDENTIALS_JSON` with the base64 string
+ - *(Do this for non-main branches)* Create another secret named `DEV_GOOGLE_CREDENTIALS_JSON` with the same base64 string so development branches can run GitHub Actions.
### Step 3: Get GITHUB_TOKEN (.env) + GH_TOKEN (GitHub Secret)
@@ -221,7 +256,7 @@ Go to your GitHub repository β Settings β Secrets and variables β Actions
- `.env` file: `GITHUB_TOKEN=your_token_here`
- GitHub Secret: `GH_TOKEN`
-**What this does:** Allows the bot to access GitHub API to fetch repository and contribution data.
+**What this does:** Allows the bot to access dispatch the Github Actions Workflow
1. **Go to GitHub Token Settings:** https://github.com/settings/tokens
2. **Create New Token:**
@@ -259,6 +294,16 @@ Go to your GitHub repository β Settings β Secrets and variables β Actions
- **Add to `.env`:** `OAUTH_BASE_URL=YOUR_CLOUD_RUN_URL`
- **Example:** `OAUTH_BASE_URL=https://discord-bot-abcd1234-uc.a.run.app`
- **Add to GitHub Secrets:** Create secret named `CLOUD_RUN_URL` with the same URL
+ - *(Do this for non-main branches)* Create a `DEV_CLOUD_RUN_URL` pointing to the staging/test Cloud Run service so development workflows continue to function. (You may reuse CLOUD_RUN_URL if you are not deploying production from main.)
+
+3. **Configure Discord OAuth Redirect URI:**
+ - Go to [Discord Developer Portal](https://discord.com/developers/applications)
+ - Select your bot application (same one from Step 1)
+ - Go to **OAuth2** β **General**
+ - In the **Redirects** section, click **Add Redirect**
+ - Add: `YOUR_CLOUD_RUN_URL/setup`
+ - **Example:** `https://discord-bot-abcd1234-uc.a.run.app/setup`
+ - Click **Save Changes**
### Step 5: Get GITHUB_CLIENT_ID (.env) + GITHUB_CLIENT_SECRET (.env)
@@ -279,25 +324,63 @@ Go to your GitHub repository β Settings β Secrets and variables β Actions
**Example URLs:** If your Cloud Run URL is `https://discord-bot-abcd1234-uc.a.run.app`, then:
- Homepage URL: `https://discord-bot-abcd1234-uc.a.run.app`
- Callback URL: `https://discord-bot-abcd1234-uc.a.run.app/login/github/authorized`
+ - After OAuth completes, the app will redirect users to `/auth/callback` for the success page.
4. **Get Credentials:**
- Click "Register application"
- Copy the "Client ID" β **Add to `.env`:** `GITHUB_CLIENT_ID=your_client_id`
- Click "Generate a new client secret" β Copy it β **Add to `.env`:** `GITHUB_CLIENT_SECRET=your_secret`
+### Step 5b: Create GitHub App (GITHUB_APP_ID / PRIVATE_KEY / SLUG)
+
+**What this configures:**
+- `.env` file: `GITHUB_APP_ID=...`, `GITHUB_APP_PRIVATE_KEY_B64=...`, `GITHUB_APP_SLUG=...`
+- GitHub Secrets: `GH_APP_ID`, `GH_APP_PRIVATE_KEY_B64`
+
+**What this does:** Allows DisgitBot to read repository data without user PATs.
+
+**Where these values come from:**
+- `GITHUB_APP_ID`: shown on the GitHub App settings page (App ID field).
+- `GITHUB_APP_PRIVATE_KEY_B64`: base64 of the downloaded `.pem` private key.
+- `GITHUB_APP_SLUG`: the URL slug of your GitHub App (shown in the app page URL).
+
+1. **Create the GitHub App (org or personal):**
+ - For org: `https://github.com/organizations/Track GitHub contributions and manage roles automatically in your Discord server.
+ ++ Compatible with any GitHub organization. Setup takes 30 seconds. +
+