# shashank-133/under-study architecture

> Architecture diagram of the GitHub repository shashank-133/under-study, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shashank-133/under-study
- Repository: https://github.com/shashank-133/under-study

## Overview

#### 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: [`backend/app/ai_bridge.py`](https://github.com/shashank-133/under-study/blob/main/backend/app/ai_bridge.py) (AI bridge), [`frontend/src/App.jsx`](https://github.com/shashank-133/under-study/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/pages/HomePage.jsx`](https://github.com/shashank-133/under-study/blob/main/frontend/src/pages/HomePage.jsx) (Incident query UI), [`backend/app/main.py`](https://github.com/shashank-133/under-study/blob/main/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React client"]
  node_client_entry["Vite entry<br/>React bootstrap<br/>[main.jsx]"]
  node_client_app["App shell<br/>React routing<br/>[App.jsx]"]
  node_home["Incident query UI<br/>React page<br/>[HomePage.jsx]"]
  node_ingest_demo["Ingestion demo UI<br/>React page"]
  node_language_toggle["Language control<br/>React component<br/>[LanguageToggle.jsx]"]
  node_client_api["API client<br/>frontend boundary<br/>[api.js]"]
end

subgraph group_api["FastAPI service"]
  node_api_main["FastAPI application<br/>service entry<br/>[main.py]"]
  node_query_route["Query route<br/>FastAPI endpoint<br/>[query.py]"]
  node_ingest_route["Ingest route<br/>FastAPI endpoint<br/>[ingest.py]"]
  node_answer_orchestrator["Answer assembly<br/>response service<br/>[answers.py]"]
  node_ai_bridge["AI bridge<br/>provider boundary<br/>[ai_bridge.py]"]
end

subgraph group_knowledge["Incident knowledge pipeline"]
  node_incident_model["Incident schema<br/>domain model<br/>[incident.py]"]
  node_ingest_service["Incident normalization<br/>ingestion service<br/>[ingest.py]"]
  node_batch_job["Batch ingestion<br/>scheduled job<br/>[ingest_job.py]"]
  node_extraction["Incident extraction<br/>AI extraction<br/>[extraction.py]"]
  node_similarity["Similarity matching<br/>retrieval service<br/>[similarity.py]"]
  node_graph_queries["Graph traversal<br/>query repository<br/>[queries.py]"]
  node_graph_writer["Graph writer<br/>persistence repository<br/>[writer.py]"]
  node_embeddings["Semantic embeddings<br/>AI capability<br/>[embeddings.py]"]
  node_answer_generation["Answer generation<br/>AI capability"]
  node_translation["Answer translation<br/>AI capability<br/>[multilingual.py]"]
  node_graph_connection["Neo4j connection<br/>storage adapter<br/>[connection.py]"]
  node_runtime_store[("Local fallback store<br/>storage fallback<br/>[runtime_store.py]")]
  node_seed_incidents["Seed incidents<br/>incident dataset<br/>[incidents.json]"]
end

subgraph group_external["External services"]
  node_neo4j[("Neo4j AuraDB<br/>graph database")]
  node_sarvam{{"Sarvam AI<br/>model provider"}}
end

node_client_entry -->|"boots"| node_client_app
node_client_app -->|"serves"| node_home
node_client_app -->|"serves"| node_ingest_demo
node_home -->|"uses"| node_language_toggle
node_home -->|"submits query"| node_client_api
node_ingest_demo -->|"submits material"| node_client_api
node_client_api -->|"HTTP"| node_api_main
node_api_main -->|"mounts"| node_query_route
node_api_main -->|"mounts"| node_ingest_route
node_query_route -->|"matches incidents"| node_similarity
node_query_route -->|"builds response"| node_answer_orchestrator
node_answer_orchestrator -->|"uses"| node_ai_bridge
node_ai_bridge -->|"generates answer"| node_answer_generation
node_ai_bridge -->|"translates"| node_translation
node_ai_bridge -->|"calls"| node_sarvam
node_similarity -->|"semantic score"| node_embeddings
node_similarity -->|"retrieves context"| node_graph_queries
node_ingest_route -->|"normalizes"| node_ingest_service
node_batch_job -->|"bulk input"| node_ingest_service
node_ingest_service -->|"extracts structure"| node_extraction
node_extraction -->|"produces"| node_incident_model
node_incident_model -->|"persists"| node_graph_writer
node_graph_writer -->|"uses"| node_graph_connection
node_graph_queries -->|"uses"| node_graph_connection
node_graph_connection -->|"connects"| node_neo4j
node_runtime_store -->|"seeds from"| node_seed_incidents
node_runtime_store -.->|"fallback when unavailable"| node_neo4j

click node_client_entry "https://github.com/shashank-133/under-study/blob/main/frontend/src/main.jsx"
click node_client_app "https://github.com/shashank-133/under-study/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/shashank-133/under-study/blob/main/frontend/src/pages/HomePage.jsx"
click node_ingest_demo "https://github.com/shashank-133/under-study/blob/main/frontend/src/pages/IngestionDemoPage.jsx"
click node_language_toggle "https://github.com/shashank-133/under-study/blob/main/frontend/src/components/LanguageToggle.jsx"
click node_client_api "https://github.com/shashank-133/under-study/blob/main/frontend/src/utils/api.js"
click node_api_main "https://github.com/shashank-133/under-study/blob/main/backend/app/main.py"
click node_query_route "https://github.com/shashank-133/under-study/blob/main/backend/app/api/query.py"
click node_ingest_route "https://github.com/shashank-133/under-study/blob/main/backend/app/api/ingest.py"
click node_answer_orchestrator "https://github.com/shashank-133/under-study/blob/main/backend/app/answers.py"
click node_ai_bridge "https://github.com/shashank-133/under-study/blob/main/backend/app/ai_bridge.py"
click node_incident_model "https://github.com/shashank-133/under-study/blob/main/backend/app/models/incident.py"
click node_ingest_service "https://github.com/shashank-133/under-study/blob/main/backend/app/services/ingest.py"
click node_batch_job "https://github.com/shashank-133/under-study/blob/main/ingestion/ingest_job.py"
click node_extraction "https://github.com/shashank-133/under-study/blob/main/ai/extraction.py"
click node_similarity "https://github.com/shashank-133/under-study/blob/main/backend/app/graph/similarity.py"
click node_graph_queries "https://github.com/shashank-133/under-study/blob/main/backend/app/graph/queries.py"
click node_graph_writer "https://github.com/shashank-133/under-study/blob/main/backend/app/graph/writer.py"
click node_embeddings "https://github.com/shashank-133/under-study/blob/main/ai/embeddings.py"
click node_answer_generation "https://github.com/shashank-133/under-study/blob/main/ai/answer_generation.py"
click node_translation "https://github.com/shashank-133/under-study/blob/main/ai/multilingual.py"
click node_graph_connection "https://github.com/shashank-133/under-study/blob/main/backend/app/graph/connection.py"
click node_runtime_store "https://github.com/shashank-133/under-study/blob/main/backend/app/graph/runtime_store.py"
click node_seed_incidents "https://github.com/shashank-133/under-study/blob/main/backend/seed_data/incidents.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_entry,node_client_app,node_home,node_ingest_demo,node_language_toggle,node_client_api toneBlue
class node_api_main,node_query_route,node_ingest_route,node_answer_orchestrator,node_ai_bridge toneAmber
class node_incident_model,node_ingest_service,node_batch_job,node_extraction,node_similarity,node_graph_queries,node_graph_writer,node_embeddings,node_answer_generation,node_translation,node_graph_connection,node_runtime_store,node_seed_incidents toneMint
class node_neo4j,node_sarvam toneRose
```

## Components

### React client

- [Vite entry](https://github.com/shashank-133/under-study/blob/main/frontend/src/main.jsx): React bootstrap · `frontend/src/main.jsx`
- [App shell](https://github.com/shashank-133/under-study/blob/main/frontend/src/App.jsx): React routing · `frontend/src/App.jsx`
- [Incident query UI](https://github.com/shashank-133/under-study/blob/main/frontend/src/pages/HomePage.jsx): React page · Composes chat, answers, confidence, similar incidents, and language selection. · `frontend/src/pages/HomePage.jsx`
- [Ingestion demo UI](https://github.com/shashank-133/under-study/blob/main/frontend/src/pages/IngestionDemoPage.jsx): React page · `frontend/src/pages/IngestionDemoPage.jsx`
- [Language control](https://github.com/shashank-133/under-study/blob/main/frontend/src/components/LanguageToggle.jsx): React component · `frontend/src/components/LanguageToggle.jsx`
- [API client](https://github.com/shashank-133/under-study/blob/main/frontend/src/utils/api.js): frontend boundary · `frontend/src/utils/api.js`

### FastAPI service

- [FastAPI application](https://github.com/shashank-133/under-study/blob/main/backend/app/main.py): service entry · `backend/app/main.py`
- [Query route](https://github.com/shashank-133/under-study/blob/main/backend/app/api/query.py): FastAPI endpoint · Coordinates matching, answer construction, and language handling. · `backend/app/api/query.py`
- [Ingest route](https://github.com/shashank-133/under-study/blob/main/backend/app/api/ingest.py): FastAPI endpoint · `backend/app/api/ingest.py`
- [Answer assembly](https://github.com/shashank-133/under-study/blob/main/backend/app/answers.py): response service · `backend/app/answers.py`
- [AI bridge](https://github.com/shashank-133/under-study/blob/main/backend/app/ai_bridge.py): provider boundary · Keeps model-provider details out of routes and UI. · `backend/app/ai_bridge.py`

### Incident knowledge pipeline

- [Incident schema](https://github.com/shashank-133/under-study/blob/main/backend/app/models/incident.py): domain model · Captures signatures, causes, files, fixes, people, and PRs. · `backend/app/models/incident.py`
- [Incident normalization](https://github.com/shashank-133/under-study/blob/main/backend/app/services/ingest.py): ingestion service · `backend/app/services/ingest.py`
- [Batch ingestion](https://github.com/shashank-133/under-study/blob/main/ingestion/ingest_job.py): scheduled job · Bulk or scheduled ingestion path. · `ingestion/ingest_job.py`
- [Incident extraction](https://github.com/shashank-133/under-study/blob/main/ai/extraction.py): AI extraction · `ai/extraction.py`
- [Similarity matching](https://github.com/shashank-133/under-study/blob/main/backend/app/graph/similarity.py): retrieval service · `backend/app/graph/similarity.py`
- [Graph traversal](https://github.com/shashank-133/under-study/blob/main/backend/app/graph/queries.py): query repository · `backend/app/graph/queries.py`
- [Graph writer](https://github.com/shashank-133/under-study/blob/main/backend/app/graph/writer.py): persistence repository · `backend/app/graph/writer.py`
- [Semantic embeddings](https://github.com/shashank-133/under-study/blob/main/ai/embeddings.py): AI capability · `ai/embeddings.py`
- [Answer generation](https://github.com/shashank-133/under-study/blob/main/ai/answer_generation.py): AI capability · `ai/answer_generation.py`
- [Answer translation](https://github.com/shashank-133/under-study/blob/main/ai/multilingual.py): AI capability · Translates answers while preserving technical tokens and code references. · `ai/multilingual.py`
- [Neo4j connection](https://github.com/shashank-133/under-study/blob/main/backend/app/graph/connection.py): storage adapter · `backend/app/graph/connection.py`
- [Local fallback store](https://github.com/shashank-133/under-study/blob/main/backend/app/graph/runtime_store.py): storage fallback · Uses seeded incidents when Neo4j credentials are unavailable. · `backend/app/graph/runtime_store.py`
- [Seed incidents](https://github.com/shashank-133/under-study/blob/main/backend/seed_data/incidents.json): incident dataset · `backend/seed_data/incidents.json`

### External services

- **Neo4j AuraDB**: graph database · Primary connected incident store.
- **Sarvam AI**: model provider

## Connections

- 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
