How swapnildahiphale/opensre works
1. Repository shape
- This is a multi-service platform for AI-assisted incident investigation, not a single app.
- The core runtime is split into three application services: config_service (backend control plane), sre-agent (the investigation agent), and web_ui (operator console).
- Around those are infrastructure modules for PostgreSQL, Neo4j, Kubernetes/EKS, and end-to-end test environments.
2. High-level request flow
- Humans interact through the Next.js web UI or Slack.
- The UI talks mostly to config_service for org/team configuration, templates, auth, audits, tokens, and knowledge management.
- For live investigations, the UI streams to sre-agent, which orchestrates the investigation and returns results incrementally.
- The agent reads configuration and stores/retrieves state from PostgreSQL, while consulting Neo4j for topology and dependency context.
3. config_service: control plane and source of truth
- This FastAPI service is the administrative backend.
- It owns configuration models, templates, team/org hierarchy, integrations, security policies, scheduled jobs, visitor sessions, audit logs, and token management.
- Alembic migrations show the service is the canonical owner of persistent schema evolution.
- It also includes encryption support, YAML config handling, dependency validation, and seeded “golden templates” for common incident workflows.
4. sre-agent: autonomous investigation runtime
- This is the LangGraph-based agent runtime.
- Its node graph is organized around init_context, planner, subagent_executor, synthesizer, writeup, plus memory and knowledge-graph enrichment nodes.
- The agent is the execution engine that turns an incident prompt into a plan, tool calls, reasoning steps, evidence synthesis, and a final report.
- It is designed around streamed execution, which is why the UI exposes agent-stream and trace endpoints.
5. Agent memory subsystem
- The agent has a dedicated memory layer under sre-agent/memory.
- This captures episodic memory, strategy generation, lookup, and storage so prior investigations influence future ones.
- Conceptually, this is the “learn from every incident” layer: past incidents, hints, and patterns are retained and surfaced during new runs.
- The web UI also exposes memory browsing/search pages, indicating memory is user-visible, not just internal state.
6. Knowledge graph / topology subsystem
- Neo4j is a first-class architectural dependency, used to model service relationships and blast radius.
- The agent has dedicated graph-related code and a semantic layer for querying service dependencies.
- The web UI exposes topology and knowledge tree views, so topology is not just for agent reasoning; it is also an operational admin surface.
- In diagram terms, Neo4j sits alongside Postgres, with the agent reading both for complementary context.
7. Tooling and integrations boundary
- The platform is integration-heavy: Datadog, Grafana, PagerDuty, Elasticsearch, Kubernetes, AWS, Slack, GitHub, and others are reflected in route names, templates, and tool catalogs.
- config_service manages integration schemas and metadata; sre-agent contains the actual skill/tool execution layer.
- The “golden templates” and templates JSON files define reusable playbooks for specific workflows like Slack incident triage, CI auto-fix, AWS cost reduction, and observability review.
- This separation matters: configuration lives in the control plane, while operational API calls happen inside the agent runtime.
8. UI as a thin product shell
- web_ui is a Next.js application with app-router pages for team, admin, incidents, memory, integrations, settings, learning, and investigation review.
- It includes many route handlers under src/app/api, which act as a BFF/proxy layer to the backend services rather than holding core business logic.
- The UI contains auth/session handling, role/permission gates, visitor flows, and streamed agent interaction components.
- It is the user-facing orchestration layer, but not the system of record.
9. Authentication, roles, and audit
- Auth is multi-mode: admin/token-based access, SSO/OIDC, visitor sessions, and team tokens.
- The backend includes explicit RBAC/admin permission logic and audit logging, which suggests strong governance around configuration changes and sensitive operations.
- The UI mirrors these boundaries with RequireRole, RequirePermission, and sign-in/session components.
- Token audit, revocation, extension, and admin endpoints indicate that access control is a core product concern.
10. Persistence and schema ownership
- PostgreSQL is the durable store for config, tokens, audit records, scheduled jobs, and agent-related state.
- The config_service repository owns the DB models, repositories, and Alembic migrations.
- Encryption support and SQLAlchemy custom types suggest some fields are protected at rest.
- This makes Postgres the operational system of record, while Neo4j is the relationship model.
11. Deployment and infrastructure
- config_service and web_ui each have Dockerfiles and Terraform/Kubernetes deployment assets, showing they are independently deployable services.
- There is Terraform for both application infrastructure and database infrastructure, plus Kubernetes manifests and scripts for EKS setup.
- make-based workflows and scripts indicate local development and production deployment are both first-class.
- The repo supports Docker Compose for local multi-service startup and Kubernetes/EKS for real cluster validation.
12. Test and demo environments
- There are dedicated E2E and fault-injection scripts for Kind and EKS using the OpenTelemetry demo application.
- The test-infra directory contains cluster setup, port-forwarding, SSE parsing, and teardown helpers.
- This is important architecturally because the agent is validated against live service telemetry, not just unit tests.
- The test harness is part of the product story: it exercises the full loop from fault injection to investigation output.
13. What an architecture diagram should emphasize
- Show three primary application boxes: control plane (config_service), reasoning engine (sre-agent), and operator UI (web_ui).
- Put PostgreSQL and Neo4j as the two central data stores with different responsibilities.
- Show external integrations/tool providers on the agent side, and auth/identity providers on the control-plane/UI side.
- Add Slack and EKS/OpenTelemetry demo as important external entry points for real incident workflows and end-to-end validation.
Main entry points: graph.py Agent graph · main.py config_service · route.ts BFF routes · server.py sre-agent
Components 23
Control Plane
Administrative backend and source of truth
- config_service · Administrative service for configuration, auth, templates, audits, tokens, and workflows
config_service/src/api/main.py - Core config · Configuration models, RBAC, validation, YAML handling, and dependency rules
config_service/src/core/config_models.py - DB layer · Repository and model layer for persistent config and operational records
config_service/src/db/config_repository.py - Migrations · Canonical schema evolution for the control-plane database
config_service/alembic/versions/20260312_agent_run_thoughts.py - Golden templates · Seeded incident workflows and reusable agent prompt templates
config_service/golden_templates/01_slack_incident_triage/planner.md
Agent Runtime
Investigation execution, memory, and knowledge-graph context
- sre-agent · Streaming investigation engine that plans, calls tools, synthesizes evidence, and writes reports
sre-agent/server.py - Agent graph · Orchestrates init, planning, subagent execution, synthesis, memory, and writeup
sre-agent/graph.py - Init context · Builds the investigation context before execution
sre-agent/nodes/init_context.py - Planner · Converts the incident prompt into an investigation plan
sre-agent/nodes/planner.py - Subagent exec · Runs investigative tool calls and parallel substeps
sre-agent/nodes/subagent_executor.py - Memory layer · Lookup, strategy generation, hinting, and storage across incidents
sre-agent/memory/integration.py - KG context · Queries service relationships and blast-radius context from Neo4j
sre-agent/nodes/kg_context.py - Writeup · Produces the final incident narrative and structured findings
sre-agent/nodes/writeup.py
Operator UI
Next.js console and BFF routes
- web_ui · Operator console with app-router pages, auth, memory, topology, and investigation review
web_ui/src/app/page.tsx - BFF routes · Proxy and orchestration layer that forwards UI actions to backend services
web_ui/src/app/api/team/agent/stream/route.ts - Auth gates · Sign-in, visitor sessions, role checks, and permission guards
web_ui/src/components/RequireRole.tsx - Memory views · Browsing, search, and stats for incident memory and strategies
web_ui/src/app/team/memory/page.tsx - Topology views · Operational views for service graph and knowledge tree exploration
web_ui/src/app/api/topology/nodes/route.ts
Data Stores
Persistent stores for configuration and topology
- PostgreSQL · System of record for configuration, tokens, audits, jobs, and agent state
database/infra/terraform/main.tf - Neo4j · Dependency and topology model for service relationships and blast radius
scripts/populate_neo4j.py
Infra & Validation
Deployment, local startup, and end-to-end environments
- EKS demo · Kind/EKS OpenTelemetry demo environment used for live incident validation
test-infra/eks/setup.sh - Slack · Human-facing incident intake and workflow surface
config_service/golden_templates/01_slack_incident_triage/aws.md - Deploy infra · Docker, Kubernetes, and Terraform assets for service deployment and local startup
web_ui/infra/terraform/main.tf
Connections 27
- web_ui → BFF routes: uses · UI actions and page data flow through BFF route handlers
- BFF routes → config_service: admin/config · Admin pages and config views proxy to the control plane
- BFF routes → sre-agent: stream/run · Investigation pages stream live runs from the agent runtime
- BFF routes → PostgreSQL: session/state · UI-backed session and team data are persisted through backend services
- Auth gates → web_ui: gates · Role and permission components guard sensitive pages
- Memory views → Memory layer: browse · Memory pages expose investigation memory for operators
- Topology views → Neo4j: explore · Topology and knowledge tree views surface relationship data
- sre-agent → Agent graph: executes · The server hosts the LangGraph workflow runtime
- Agent graph → Init context: starts · Investigation runs begin by constructing context
- Agent graph → Planner: plans · Planning node derives investigation steps
- Agent graph → Subagent exec: calls tools · Executor runs subagents and operational tool calls
- Agent graph → Memory layer: consults · Graph uses memory for recall and strategy reuse
- Agent graph → KG context: enriches · Graph pulls topology context for dependency reasoning
- Agent graph → Writeup: finishes · Final synthesis becomes the incident report
- Memory layer → PostgreSQL: stores/loads · Memory state and investigation artifacts are persisted in Postgres
- KG context → Neo4j: queries · Knowledge-graph context comes from Neo4j
- config_service → Core config: uses · API routes are backed by validation, RBAC, encryption, and YAML logic
- config_service → DB layer: persists · Control-plane resources are written through repository abstractions
- DB layer → PostgreSQL: stores · Canonical configuration and audit data live in PostgreSQL
- Migrations → PostgreSQL: evolves · Alembic migrations define the database schema owned by the control plane
- Golden templates → Core config: seeds · Golden templates feed the template/config management layer
- Slack → web_ui: intake · Slack is a primary external incident entrypoint surfaced through the product
- Slack → config_service: workspace config · Slack app and token metadata are managed in the control plane
- EKS demo → sre-agent: validates · End-to-end validation exercises the agent against live telemetry
- Deploy infra → config_service: deploys · Service deployment assets package the control-plane runtime
- Deploy infra → web_ui: deploys · Infra assets package the UI runtime
- Deploy infra → sre-agent: deploys · Infra assets package the agent runtime