A lightweight asynchronous ChatOps microservice architecture designed to route, evaluate, and fulfill operational infrastructure commands directly from Discord utilizing dynamic multi-model LLM orchestration (OpenAI and Gemini).
-
Orchestration Mesh: Built on a completely decoupled microservice architecture consisting of an asynchronous
discord.pybot client layer and a high-performance FastAPI backend API. -
Dynamic Model Routing: Features an adaptive inference broker utilizing LiteLLM to seamlessly hot-swap and route incoming requests between multiple upstream providers (OpenAI gpt-4o-mini, Google Gemini 2.5 Flash) based on runtime channel overrides.
-
Production Observability: Implements custom operational telemetry middleware that intercepts raw application traffic and structures logging payloads into flat JSON schemas outputted directly to
stdoutfor modern log-aggregators.
Clone the repository and instantiate your environment variables from the configuration profile template:
cp .env.example .envOpen .env and populate your secure infrastructure tokens:
OPENAI_API_KEY=sk-proj-...
GEMINI_API_KEY=AIzaSy...
DISCORD_BOT_TOKEN=MTIy...
Ensure you navigate to the Discord Developer Portal under your application's "Bot" tab and toggle the Message Content Intent security switch to
ON.
The repository provides a centralized automation task runner interface via GNU Make to abstract and standardize developer setup workflows:
# Init virtual environments, pull configurations, and install pre-commit hooks
make initCompile and launch your decoupled application containers simultaneously in detached mode leveraging localized BuildKit caching layers:
# Build and run the service architecture mesh
make up
# Stream unified stdout application logs from all running services
make logs| Command | Action |
|---|---|
make init |
Provisions local python virtual environments and registers local pre-commit tracking hooks. |
make up |
Compiles application container layers and launches the service overlay network. |
make down |
Demolishes container topologies, prunes virtual interfaces, and removes orphan layers. |
make restart |
Executes a clean sequence tear down followed by an immediate structural rebuild. |
make logs |
Attaching to unified standard output log streams. |
The repository implements a comprehensive, multi-track GitHub Actions continuous integration workflow to guarantee software supply chain integrity before merging code:
-
Static Analysis: Uses
Ruffto validate Python linting, code quality, style uniformity, and syntax formatting rules. -
Security & Vulnerability Scanning: Integrates
Trivyto scan filesystem dependencies for high/critical CVE risks and accidental credential exposures. -
Compilation Integrity: Executes a structural dry-run build of the Docker configurations to ensure the infrastructure layout compiles safely before deployment.
To transition Opsie from an interactive chatbot into a hardened infrastructure controller, the following milestones are actively being engineered:
-
Secure Tool Execution (Function Calling): Extend the FastAPI backend to support JSON tool definitions. This allows the bot-driven AI to safely run read-only terminal commands (e.g.,
kubectl get pods) directly from chat. -
Stateful Session Layer (Redis): Move chat history out of volatile application memory and into a local Redis service. This lets you horizontally scale your backend API nodes without losing conversational context.
-
Secret Configuration Management: Migrate sensitive credentials out of plain
.envfiles and integrate a secure injection pattern using tools like HashiCorp Vault or AWS Secrets Manager. -
Kubernetes Orchestration & Deployment: Migrate the containerized services from Docker Compose into a managed Kubernetes cluster, creating declarative manifest layouts (Deployments, Services, and ConfigMaps) for automated, scalable hosting.
