Bot - Event Router
📚 Module: Understanding the ADLC Multi-Tenant Bot System Architecture
Target Audience: Beginner Engineers, AI builders, and Community Learners
Estimated Reading Time: 8–10 minutes
Goal: Understand how an automated, AI-powered multi-tenant chatbot works from the moment a user types a message to running real-world tools and creating GitHub PRs.
🎯 High-Level Overview: What is this system?
Imagine you run an automated AI developer/assistant named ADLC Bot.
  • "Multi-Tenant" means many different teams or channels ("tenants") can use the exact same server instance, each having their own custom rules, memory, and settings without interfering with each other.
  • Whenever a user talks to the bot in Google Chat, the bot wakes up, verifies who you are, loads your specific channel's rules, thinks using an LLM (Large Language Model), browses the web if needed, and can even automatically push code fixes to GitHub!
🗺️ The Architecture at a Glance (The 4 Main Zones)
Looking at the diagram, the architecture is divided into 4 distinct color-coded zones:
  1. 🟩 Google Chat (The Frontend / User Interface): Where users interact with the bot.
  2. 🟦 Fly.io Machine + Volume (The Core Engine): The lightweight server where the routing, security, database, and browser automation live.
  3. ⬛ LLM & Peer Agents (The Brains & Network): The AI models (Gemini / Claude / DeepSeek) and other bots communicating agent-to-agent.
  4. 🟧 GitHub Org (The Code Factory): Where the bot creates repositories, tests code, and submits pull requests.
🔄 Step-by-Step Walkthrough: What Happens When You Send a Message?
Step 1: The Trigger (Google Chat 🟩)
  • Action: A user in a Google Chat space types @bot help me fix this bug.
  • Webhook: Google Chat packages this event into an HTTP POST request and shoots it over to the bot server at /api/chat-event.
Step 2: The Gateway & Security Check (Fly.io 🟦)
Before doing anything expensive or dangerous, the server performs a two-step security check:
  1. Proxy & Router: The request hits Fly Proxy (:3000) and enters the Express server (server.js).
  2. Bearer JWT Validation 🔐:
  • Is this request actually coming from Google, or is it an attacker?
  • If the JWT token is invalid ➡️ 401 Reject ❌ (Denied!).
  • Database Check (SQLite on Volume) 💾:
  • Is this specific space_id registered and allowed to use the bot?
  • If yes, the server pulls that channel's specific configuration:
  • System prompts & behavior rules
  • Associated GitHub repository info
Step 3: Thinking & Agent-to-Agent (A2A) Routing 🤖🧠
Now that the server knows who you are:
  • Load Prompts & Rules: It prepares the context for the AI.
  • LLM Call: It asks models like Gemini, Claude, or DeepSeek what to do next.
  • Agent-to-Agent (A2A Handler):
  • The bot supports an A2A Endpoint (/.well-known/agent.json).
  • If a task requires collaboration with other specialized bots ("Peer Channel Agents"), it communicates with them via standardized JSON-RPC messages.
Step 4: Tool Execution (Browsing & Automation 🎭)
Does the user's request require looking something up online or scraping data?
  • "Needs browser?" Check:
  • If No ➡️ It replies directly.
  • If Yes ➡️ URL Allowlist Check 🔗 (Security measure: prevents the bot from visiting unsafe or internal URLs).
  • Playwright Chromium: A headless browser spins up in an isolated context (newContext) to fetch the needed web page safely.
Step 5: Autonomous Code Fixes & GitHub Integration (GitHub Org 🟧)
If the user asks the bot to create a project or fix an issue:
  1. Repository Generation: Using Octokit (GitHub's API client), the bot duplicates an adlc-channel-template into a custom repo (e.g., bot-channel-AAAA).
  2. Proposed Patch & PR: The bot writes the fix and creates a Pull Request (Fix PR) for a human developer to review.
  3. Automated CI: GitHub Actions runs unit tests (npm test) on the PR automatically to verify nothing is broken.
Step 6: Closing the Loop (Async Reply 💬)
Once the task or PR is complete:
  • The Fly.io server sends an Async reply via Chat API straight back into the user's Google Chat space:
  • "Done! I've opened PR #12 with the fix and all tests passed."
📝 Quick Check / Discussion Prompt (For the Skool Comments)
Question for the community:
Notice how the bot checks an "Allowlist" before opening a URL with Playwright Chromium. What could go wrong if an AI bot was allowed to browse ANY URL a user gave it?
👇 Drop your answers in the comments below!
2
3 comments
Rifat Erdem Sahin
4
Bot - Event Router
powered by
Delivery Pilot
skool.com/delivery-pilot-8938
🚀 AI is raising the bar faster than people can keep up. Ship real AI work and turn it into a job or a business.
Build your own community
Bring people together around your passion and get paid.
Powered by