How shashank-133/under-study works
Purpose and Entry Points
Understudy is an internal AI pair-debugger that turns team incident history into searchable troubleshooting guidance. Users submit an error through the React UI; FastAPI retrieves similar incidents, synthesizes an answer, and can translate it. Main runtime entry points are frontend/src/main.jsx, frontend/src/App.jsx, and backend/app/main.py. Batch ingestion is designed to run separately from ingestion/ingest_job.py.
Client Experience
The Vite/React frontend provides two primary flows: querying prior incidents and demonstrating ingestion. frontend/src/pages/HomePage.jsx composes chat input, answer display, confidence, similar incidents, and language selection. frontend/src/pages/IngestionDemoPage.jsx submits raw incident material for immediate indexing. API access is centralized in frontend/src/utils/api.js, creating a boundary between UI state/presentation and backend contracts.
API and Request Orchestration
FastAPI exposes query and ingest routes under backend/app/api/query.py and backend/app/api/ingest.py, mounted by backend/app/main.py. Query handling coordinates incident matching, answer construction, and language handling; backend/app/answers.py and backend/app/ai_bridge.py isolate response assembly and calls into the shared AI layer. The API returns structured incident context rather than making the frontend interact with Neo4j or AI providers directly.
Incident Ingestion Pipeline
Raw stack traces or code/alert inputs are normalized into the incident graph schema by backend/app/services/ingest.py and ai/extraction.py. The ingestion API supports interactive creation, while ingestion/ingest_job.py is the background/Render-workflow path for bulk or scheduled processing. Domain shape is anchored by backend/app/models/incident.py, representing incident signatures, causes, affected files, fixes, people, and PR references.
Graph Retrieval and Storage Boundary
The graph layer abstracts persistence and similarity lookup. backend/app/graph/connection.py manages Neo4j connectivity; backend/app/graph/queries.py traverses incident relationships; and backend/app/graph/writer.py persists extracted incidents. Neo4j AuraDB is the primary store, modeling connected Incident, ErrorSignature, RootCause, File, FixPattern, Person, and PR entities. When credentials are absent, backend/app/graph/runtime_store.py supplies in-memory/local fallback behavior seeded from backend/seed_data/incidents.json.
Matching and Answer Generation
A query moves from user error text to similarity scoring and graph-context retrieval through backend/app/graph/similarity.py and graph queries. ai/embeddings.py supports semantic matching, while ai/answer_generation.py turns matched incidents into a supportive, senior-engineer-style answer with code locations, fixes, PR context, and relevant people. Sarvam AI is the external model provider; the backend bridge prevents provider details from leaking into routes or UI.
Multilingual and Deployment Dependencies
ai/multilingual.py translates completed answers into Hindi, Tamil, or Telugu while preserving technical tokens and code references. The frontend language control is frontend/src/components/LanguageToggle.jsx. Material infrastructure is FastAPI/Python, React/Vite/Node, Sarvam AI APIs, Neo4j AuraDB, and optional Render scheduled workflows. Environment configuration in .env.example selects Sarvam, Neo4j, and frontend-to-backend endpoint connectivity.
Main entry points: ai_bridge.py AI bridge · App.jsx App shell · HomePage.jsx Incident query UI · main.py FastAPI application
Components 26
React client
- Vite entry
frontend/src/main.jsx - App shell
frontend/src/App.jsx - Incident query UI · Composes chat, answers, confidence, similar incidents, and language selection.
frontend/src/pages/HomePage.jsx - Ingestion demo UI
frontend/src/pages/IngestionDemoPage.jsx - Language control
frontend/src/components/LanguageToggle.jsx - API client
frontend/src/utils/api.js
FastAPI service
- FastAPI application
backend/app/main.py - Query route · Coordinates matching, answer construction, and language handling.
backend/app/api/query.py - Ingest route
backend/app/api/ingest.py - Answer assembly
backend/app/answers.py - AI bridge · Keeps model-provider details out of routes and UI.
backend/app/ai_bridge.py
Incident knowledge pipeline
- Incident schema · Captures signatures, causes, files, fixes, people, and PRs.
backend/app/models/incident.py - Incident normalization
backend/app/services/ingest.py - Batch ingestion · Bulk or scheduled ingestion path.
ingestion/ingest_job.py - Incident extraction
ai/extraction.py - Similarity matching
backend/app/graph/similarity.py - Graph traversal
backend/app/graph/queries.py - Graph writer
backend/app/graph/writer.py - Semantic embeddings
ai/embeddings.py - Answer generation
ai/answer_generation.py - Answer translation · Translates answers while preserving technical tokens and code references.
ai/multilingual.py - Neo4j connection
backend/app/graph/connection.py - Local fallback store · Uses seeded incidents when Neo4j credentials are unavailable.
backend/app/graph/runtime_store.py - Seed incidents
backend/seed_data/incidents.json
External services
- Neo4j AuraDB · Primary connected incident store.
- Sarvam AI
Connections 27
- Vite entry → App shell: boots
- App shell → Incident query UI: serves
- App shell → Ingestion demo UI: serves
- Incident query UI → Language control: uses
- Incident query UI → API client: submits query
- Ingestion demo UI → API client: submits material
- API client → FastAPI application: HTTP
- FastAPI application → Query route: mounts
- FastAPI application → Ingest route: mounts
- Query route → Similarity matching: matches incidents
- Query route → Answer assembly: builds response
- Answer assembly → AI bridge: uses
- AI bridge → Answer generation: generates answer
- AI bridge → Answer translation: translates
- AI bridge → Sarvam AI: calls
- Similarity matching → Semantic embeddings: semantic score
- Similarity matching → Graph traversal: retrieves context
- Ingest route → Incident normalization: normalizes
- Batch ingestion → Incident normalization: bulk input
- Incident normalization → Incident extraction: extracts structure
- Incident extraction → Incident schema: produces
- Incident schema → Graph writer: persists
- Graph writer → Neo4j connection: uses
- Graph traversal → Neo4j connection: uses
- Neo4j connection → Neo4j AuraDB: connects
- Local fallback store → Seed incidents: seeds from
- Local fallback store → Neo4j AuraDB: fallback when unavailable