How stahir80td/incident-management works
Project Type & Purpose
• This is a backend‐centric, serverless RAG (Retrieval-Augmented Generation) service for automatic incident triage and enrichment.
• Offline: a Python ingestion pipeline builds a vector “knowledge base” from markdown incident reports.
• Online: Go‐based Vercel serverless functions receive PagerDuty webhooks, perform embedding→search→generation→notification, and expose a health endpoint.
File Structure Analysis
Top Level
• api/
– webhook.go (POST handler for PagerDuty webhooks)
– health.go (GET health check)
• create_incident.go, create_incidents.bat (CLI for generating dummy incidents)
• localserver.go, test_webhook.go (local dev & testing harness)
• services/ (abstractions over external APIs)
– gemini.go (Google Gemini embedding & LLM calls)
– qdrant.go (vector DB interactions)
– pagerduty.go (PagerDuty REST calls)
– rag.go (pipeline orchestration)
• incidents/ (raw Markdown incident history)
• ingest_incidents.py (+ requirements.txt) (Python RAG ingestion pipeline)
• go.mod / go.sum, env.example, vercel.json
Key Architecture Insights from README
• Offline “Phase 1”: ingest Markdown → chunk → embed via Gemini → store vectors in Qdrant
• Online “Phase 2”: PagerDuty → webhook → embed new incident → search top-k in Qdrant → generate triage note via Gemini LLM → post note back to PagerDuty
• Tech Stack: Go1.21 serverless on Vercel; Python3.11 ingestion; Qdrant Cloud; Google Gemini (embeddings + LLM)
Main Components
1. PagerDuty (Incident Trigger → Generic Webhook v3)
2. Vercel Serverless Platform (hosting Go functions)
3. Google Gemini API (embeddings & LLM)
4. Qdrant Cloud Vector DB
B. Internal Compute
1. /api/webhook function (Go): parses payload, returns 202 immediately
2. RAG Pipeline orchestrator (services/rag.go)
– Embedding Generation (services/gemini.go → Gemini REST)
– Semantic Search (services/qdrant.go → Qdrant REST)
– Contextual Prompt Building
– LLM Generation (services/gemini.go → Gemini LLM)
3. /api/health function (Go)
C. Offline Ingestion Pipeline
– ingest_incidents.py (Python): reads incidents/*.md, chunks, calls Gemini embeddings, writes to Qdrant
D. Data Stores & Artifacts
– incidents/*.md (source corpus)
– Qdrant collection (vector store)
E. Notification Target
– PagerDuty API (POST note to incident)
Relationships & Data Flow
1. PagerDuty fires webhook → HTTP POST to /api/webhook
2. Go function immediately 202s, enqueues or directly invokes RAG steps
3. Generate embedding via Gemini → send vector to Qdrant → receive top-3 matches
4. Build prompt with new incident + matched incident context → send to Gemini LLM → receive triage note
5. Call PagerDuty API to attach note
6. Meanwhile, offline ingestion script periodically updates Qdrant with new incident vectors
Architectural Patterns & Principles
• Serverless microservice decomposition (each endpoint is a separate function)
• Asynchronous/Non-blocking response for inbound webhook
• RAG pattern: Retrieval (vector search) + Generation (LLM)
• Clear separation: offline vs online pipelines
• Single responsibility modules (services/*)