# bhagat2678/bedrock architecture

> Architecture diagram of the GitHub repository bhagat2678/bedrock, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhagat2678/bedrock
- Repository: https://github.com/bhagat2678/bedrock

## Overview

Bedrock turns industrial documents into searchable vector and graph knowledge, then serves cited answers, graph exploration, and failure-risk alerts through an operator portal. The graph follows the sampled ingestion and query orchestrators; the README documents graph exploration and scheduled failure scanning, but their internal wiring is not fully sampled, so those links are kept at documented subsystem boundaries.

Main entry points: [`frontend/src/api/services.ts`](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/api/services.ts) (API services), [`backend/app/main.py`](https://github.com/bhagat2678/bedrock/blob/main/backend/app/main.py) (REST application), [`ai_ml/agents/ingestion_agent.py`](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/agents/ingestion_agent.py) (Ingestion workflow), [`ai_ml/interfaces/query_interface.py`](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/interfaces/query_interface.py) (Query interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Operator portal"]
  node_documents["Document workspace<br/>[documents.tsx]"]
  node_upload["Document upload<br/>[upload.tsx]"]
  node_query_ui["Knowledge query UI<br/>[query.tsx]"]
  node_graph_ui["Graph explorer UI<br/>[graph.tsx]"]
  node_alerts_ui["Alerts workspace<br/>[alerts.tsx]"]
  node_api_client["API services<br/>[services.ts]"]
end

subgraph group_backend["API services"]
  node_app["REST application<br/>[main.py]"]
  node_documents_api["Documents API<br/>[documents.py]"]
  node_query_api["Query API<br/>[query.py]"]
  node_graph_api["Graph API<br/>[graph.py]"]
  node_alerts_api["Alerts API<br/>[alerts.py]"]
  node_ingestion_service["Ingestion service"]
  node_query_service["Query service<br/>[query_service.py]"]
  node_scheduler["Risk scheduler<br/>[scheduler.py]"]
end

subgraph group_aiml["Knowledge engine"]
  node_ingestion_interface["Ingestion interface"]
  node_ingestion_agent["Ingestion workflow<br/>[ingestion_agent.py]"]
  node_loader["Document loader<br/>[loader.py]"]
  node_extractor["Knowledge extractor"]
  node_graph_builder["Graph builder<br/>[graph_builder.py]"]
  node_vector_index["Chunk embedding index<br/>[vector_store.py]"]
  node_query_interface["Query interface<br/>[query_interface.py]"]
  node_retriever["Hybrid retrieval"]
  node_model_router["LLM model router<br/>[model_router.py]"]
end

subgraph group_stores["Knowledge stores"]
  node_pgvector[("PostgreSQL pgvector")]
  node_neo4j[("Neo4j graph")]
end

subgraph group_risk["Failure intelligence"]
  node_failure_agent["Failure scanner"]
  node_alert_service["Alert service<br/>[alert_service.py]"]
end

node_operator(("Industrial operator"))

node_operator -->|"uploads document"| node_upload
node_operator -->|"asks question"| node_query_ui
node_operator -->|"explores graph"| node_graph_ui
node_operator -->|"reviews alerts"| node_alerts_ui
node_upload -->|"submits file"| node_api_client
node_query_ui -->|"submits query"| node_api_client
node_documents -->|"requests documents"| node_api_client
node_graph_ui -->|"requests graph"| node_api_client
node_alerts_ui -->|"requests alerts"| node_api_client
node_api_client -->|"REST requests"| node_app
node_app -->|"dispatches"| node_documents_api
node_app -->|"dispatches"| node_query_api
node_app -->|"dispatches"| node_graph_api
node_app -->|"dispatches"| node_alerts_api
node_documents_api -->|"starts ingestion"| node_ingestion_service
node_ingestion_service -->|"ingests file"| node_ingestion_interface
node_ingestion_interface -->|"invokes workflow"| node_ingestion_agent
node_ingestion_agent -->|"loads document"| node_loader
node_ingestion_agent -->|"extracts knowledge"| node_extractor
node_ingestion_agent -->|"writes entities"| node_graph_builder
node_ingestion_agent -->|"indexes chunks"| node_vector_index
node_graph_builder -->|"writes graph"| node_neo4j
node_vector_index -->|"writes vectors"| node_pgvector
node_query_api -->|"executes query"| node_query_service
node_query_service -->|"queries knowledge"| node_query_interface
node_query_interface -->|"retrieves context"| node_retriever
node_retriever -->|"searches vectors"| node_pgvector
node_retriever -->|"traverses graph"| node_neo4j
node_query_interface -->|"synthesizes answer"| node_model_router
node_scheduler -->|"runs scan"| node_failure_agent
node_failure_agent -->|"creates alerts"| node_alert_service
node_alerts_api -->|"serves alerts"| node_alert_service
node_graph_api -->|"serves graph data"| node_neo4j

click node_documents "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/documents.tsx"
click node_upload "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/upload.tsx"
click node_query_ui "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/query.tsx"
click node_graph_ui "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/graph.tsx"
click node_alerts_ui "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/alerts.tsx"
click node_api_client "https://github.com/bhagat2678/bedrock/blob/main/frontend/src/api/services.ts"
click node_app "https://github.com/bhagat2678/bedrock/blob/main/backend/app/main.py"
click node_documents_api "https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/documents.py"
click node_query_api "https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/query.py"
click node_graph_api "https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/graph.py"
click node_alerts_api "https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/alerts.py"
click node_ingestion_service "https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/ingestion_service.py"
click node_query_service "https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/query_service.py"
click node_scheduler "https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/scheduler.py"
click node_ingestion_interface "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/interfaces/ingestion_interface.py"
click node_ingestion_agent "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/agents/ingestion_agent.py"
click node_loader "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/ingestion/loader.py"
click node_extractor "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/extraction/gemini_extractor.py"
click node_graph_builder "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/graph/graph_builder.py"
click node_vector_index "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/embeddings/vector_store.py"
click node_query_interface "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/interfaces/query_interface.py"
click node_retriever "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/retrieval/hybrid_retriever.py"
click node_model_router "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/llm/model_router.py"
click node_failure_agent "https://github.com/bhagat2678/bedrock/blob/main/ai_ml/agents/failure_intelligence_agent.py"
click node_alert_service "https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/alert_service.py"

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_documents,node_upload,node_query_ui,node_graph_ui,node_alerts_ui,node_api_client toneBlue
class node_app,node_documents_api,node_query_api,node_graph_api,node_alerts_api,node_ingestion_service,node_query_service,node_scheduler toneAmber
class node_ingestion_interface,node_ingestion_agent,node_loader,node_extractor,node_graph_builder,node_vector_index,node_query_interface,node_retriever,node_model_router toneMint
class node_pgvector,node_neo4j toneRose
class node_failure_agent,node_alert_service,node_operator toneIndigo
```

## Components

### Operator portal

- [Document workspace](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/documents.tsx): `frontend/src/routes/documents.tsx`
- [Document upload](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/upload.tsx): `frontend/src/routes/upload.tsx`
- [Knowledge query UI](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/query.tsx): `frontend/src/routes/query.tsx`
- [Graph explorer UI](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/graph.tsx): `frontend/src/routes/graph.tsx`
- [Alerts workspace](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/routes/alerts.tsx): `frontend/src/routes/alerts.tsx`
- [API services](https://github.com/bhagat2678/bedrock/blob/main/frontend/src/api/services.ts): `frontend/src/api/services.ts`

### API services

- [REST application](https://github.com/bhagat2678/bedrock/blob/main/backend/app/main.py): `backend/app/main.py`
- [Documents API](https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [Query API](https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/query.py): `backend/app/api/query.py`
- [Graph API](https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/graph.py): `backend/app/api/graph.py`
- [Alerts API](https://github.com/bhagat2678/bedrock/blob/main/backend/app/api/alerts.py): `backend/app/api/alerts.py`
- [Ingestion service](https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/ingestion_service.py): `backend/app/services/ingestion_service.py`
- [Query service](https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/query_service.py): `backend/app/services/query_service.py`
- [Risk scheduler](https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/scheduler.py): `backend/app/services/scheduler.py`

### Knowledge engine

- [Ingestion interface](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/interfaces/ingestion_interface.py): `ai_ml/interfaces/ingestion_interface.py`
- [Ingestion workflow](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/agents/ingestion_agent.py): `ai_ml/agents/ingestion_agent.py`
- [Document loader](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/ingestion/loader.py): `ai_ml/ingestion/loader.py`
- [Knowledge extractor](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/extraction/gemini_extractor.py): `ai_ml/extraction/gemini_extractor.py`
- [Graph builder](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/graph/graph_builder.py): `ai_ml/graph/graph_builder.py`
- [Chunk embedding index](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/embeddings/vector_store.py): `ai_ml/embeddings/vector_store.py`
- [Query interface](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/interfaces/query_interface.py): `ai_ml/interfaces/query_interface.py`
- [Hybrid retrieval](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/retrieval/hybrid_retriever.py): `ai_ml/retrieval/hybrid_retriever.py`
- [LLM model router](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/llm/model_router.py): `ai_ml/llm/model_router.py`

### Knowledge stores

- **PostgreSQL pgvector**
- **Neo4j graph**

### Failure intelligence

- [Failure scanner](https://github.com/bhagat2678/bedrock/blob/main/ai_ml/agents/failure_intelligence_agent.py): `ai_ml/agents/failure_intelligence_agent.py`
- [Alert service](https://github.com/bhagat2678/bedrock/blob/main/backend/app/services/alert_service.py): `backend/app/services/alert_service.py`

### Other components

- **Industrial operator**

## Connections

- Industrial operator → Document upload: uploads document
- Industrial operator → Knowledge query UI: asks question
- Industrial operator → Graph explorer UI: explores graph
- Industrial operator → Alerts workspace: reviews alerts
- Document upload → API services: submits file
- Knowledge query UI → API services: submits query
- Document workspace → API services: requests documents
- Graph explorer UI → API services: requests graph
- Alerts workspace → API services: requests alerts
- API services → REST application: REST requests
- REST application → Documents API: dispatches
- REST application → Query API: dispatches
- REST application → Graph API: dispatches
- REST application → Alerts API: dispatches
- Documents API → Ingestion service: starts ingestion
- Ingestion service → Ingestion interface: ingests file
- Ingestion interface → Ingestion workflow: invokes workflow
- Ingestion workflow → Document loader: loads document
- Ingestion workflow → Knowledge extractor: extracts knowledge
- Ingestion workflow → Graph builder: writes entities
- Ingestion workflow → Chunk embedding index: indexes chunks
- Graph builder → Neo4j graph: writes graph
- Chunk embedding index → PostgreSQL pgvector: writes vectors
- Query API → Query service: executes query
- Query service → Query interface: queries knowledge
- Query interface → Hybrid retrieval: retrieves context
- Hybrid retrieval → PostgreSQL pgvector: searches vectors
- Hybrid retrieval → Neo4j graph: traverses graph
- Query interface → LLM model router: synthesizes answer
- Risk scheduler → Failure scanner: runs scan
- Failure scanner → Alert service: creates alerts
- Alerts API → Alert service: serves alerts
- Graph API → Neo4j graph: serves graph data
