# medtronic-labs/data-insights-copilot architecture

> Architecture diagram of the GitHub repository medtronic-labs/data-insights-copilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/medtronic-labs/data-insights-copilot
- Repository: https://github.com/medtronic-labs/data-insights-copilot

## Overview

Data Insights AI-Copilot is an enterprise data-analysis application: users configure agents and data sources, then ask questions through a React chat interface. The documented query flow routes intent to structured SQL, vector retrieval, or a hybrid response, with results rendered as answers and charts. The repository tree and excerpts support the API, chat, data-source, embedding, and administration modules; several pipeline connections and background-job details are documented in the README rather than shown in sampled implementation code.

Main entry points: [`backend/app/modules/chat/service.py`](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/service.py) (Chat orchestration), [`backend/app/app.py`](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/app.py) (FastAPI application), [`backend/app/modules/chat/sql_service.py`](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/sql_service.py) (SQL analysis), [`backend/app/modules/data_sources/service.py`](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/data_sources/service.py) (Data source management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_webapp["React application<br/>[App.tsx]"]
  node_chatui["Chat interface<br/>[ChatPage.tsx]"]
end

subgraph group_query["Question answering"]
  node_chat_routes["Chat routes<br/>[routes.py]"]
  node_chat_service["Chat orchestration<br/>[service.py]"]
  node_intent["Intent routing"]
  node_sql["SQL analysis<br/>[sql_service.py]"]
  node_hybrid["Hybrid synthesis"]
end

subgraph group_knowledge["Data and retrieval"]
  node_vector["Vector retrieval<br/>[retrieve.py]"]
  node_datasources["Data source management<br/>[service.py]"]
  node_embeddings["Embedding service<br/>[service.py]"]
end

subgraph group_admin["Administration"]
  node_agents["Agent configuration<br/>[service.py]"]
  node_models["AI model registry<br/>[service.py]"]
  node_users["User management<br/>[service.py]"]
end

subgraph group_platform["Platform services"]
  node_api["FastAPI application<br/>[app.py]"]
  node_llm["Language models<br/>[factory.py]"]
  node_auth["Authentication and RBAC<br/>[permissions.py]"]
  node_audit["Audit logging<br/>[service.py]"]
  node_observability["Observability"]
  node_eval["RAG evaluation<br/>[e2e_evaluator.py]"]
end

node_user(("Analyst"))
node_clinical_db[("Clinical database")]
node_vector_db[("Vector store")]
node_config_db[("Internal configuration store")]

node_user -->|"uses"| node_webapp
node_webapp -->|"opens chat"| node_chatui
node_chatui -->|"sends questions"| node_api
node_api -->|"routes requests"| node_chat_routes
node_chat_routes -.->|"calls"| node_chat_service
node_chat_service -->|"classifies intent"| node_intent
node_chat_service -->|"runs SQL"| node_sql
node_chat_service -->|"retrieves context"| node_vector
node_chat_service -->|"synthesizes results"| node_hybrid
node_sql -->|"queries"| node_clinical_db
node_vector -->|"searches"| node_vector_db
node_sql -.->|"generates SQL"| node_llm
node_hybrid -.->|"generates answer"| node_llm
node_datasources -->|"connects runtime"| node_clinical_db
node_datasources -.->|"indexes documents"| node_embeddings
node_embeddings -.->|"stores vectors"| node_vector_db
node_agents -.->|"persists configuration"| node_config_db
node_models -.->|"persists registry"| node_config_db
node_auth -->|"provisions identities"| node_users
node_users -.->|"stores users"| node_config_db
node_api -.->|"enforces access"| node_auth
node_api -.->|"records actions"| node_audit
node_api -.->|"reports analytics"| node_observability
node_eval -.->|"evaluates pipeline"| node_chat_service

click node_webapp "https://github.com/medtronic-labs/data-insights-copilot/blob/main/frontend/src/App.tsx"
click node_chatui "https://github.com/medtronic-labs/data-insights-copilot/blob/main/frontend/src/pages/ChatPage.tsx"
click node_api "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/app.py"
click node_chat_routes "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/routes.py"
click node_chat_service "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/service.py"
click node_intent "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/intent_classifier.py"
click node_sql "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/sql_service.py"
click node_vector "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/embeddings/retrieve.py"
click node_hybrid "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/comparison_engine.py"
click node_llm "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/core/llm/factory.py"
click node_datasources "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/data_sources/service.py"
click node_embeddings "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/embeddings/service.py"
click node_agents "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/agents/service.py"
click node_models "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/ai_models/service.py"
click node_auth "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/core/auth/permissions.py"
click node_users "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/users/service.py"
click node_audit "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/audit/service.py"
click node_observability "https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/observability/analytics_service.py"
click node_eval "https://github.com/medtronic-labs/data-insights-copilot/blob/main/eval/pipeline/e2e_evaluator.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_webapp,node_chatui toneBlue
class node_chat_routes,node_chat_service,node_intent,node_sql,node_hybrid,node_clinical_db,node_vector_db,node_config_db toneAmber
class node_vector,node_datasources,node_embeddings toneMint
class node_agents,node_models,node_users toneRose
class node_api,node_llm,node_auth,node_audit,node_observability,node_eval,node_user toneIndigo
```

## Components

### User experience

- [React application](https://github.com/medtronic-labs/data-insights-copilot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat interface](https://github.com/medtronic-labs/data-insights-copilot/blob/main/frontend/src/pages/ChatPage.tsx): `frontend/src/pages/ChatPage.tsx`

### Question answering

- [Chat routes](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/routes.py): `backend/app/modules/chat/routes.py`
- [Chat orchestration](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/service.py): `backend/app/modules/chat/service.py`
- [Intent routing](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/intent_classifier.py): `backend/app/modules/chat/intent_classifier.py`
- [SQL analysis](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/sql_service.py): `backend/app/modules/chat/sql_service.py`
- [Hybrid synthesis](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/chat/comparison_engine.py): `backend/app/modules/chat/comparison_engine.py`

### Data and retrieval

- [Vector retrieval](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/embeddings/retrieve.py): `backend/app/modules/embeddings/retrieve.py`
- [Data source management](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/data_sources/service.py): `backend/app/modules/data_sources/service.py`
- [Embedding service](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/embeddings/service.py): `backend/app/modules/embeddings/service.py`

### Administration

- [Agent configuration](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/agents/service.py): `backend/app/modules/agents/service.py`
- [AI model registry](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/ai_models/service.py): `backend/app/modules/ai_models/service.py`
- [User management](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/users/service.py): `backend/app/modules/users/service.py`

### Platform services

- [FastAPI application](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/app.py): `backend/app/app.py`
- [Language models](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/core/llm/factory.py): `backend/app/core/llm/factory.py`
- [Authentication and RBAC](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/core/auth/permissions.py): `backend/app/core/auth/permissions.py`
- [Audit logging](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/audit/service.py): `backend/app/modules/audit/service.py`
- [Observability](https://github.com/medtronic-labs/data-insights-copilot/blob/main/backend/app/modules/observability/analytics_service.py): `backend/app/modules/observability/analytics_service.py`
- [RAG evaluation](https://github.com/medtronic-labs/data-insights-copilot/blob/main/eval/pipeline/e2e_evaluator.py): `eval/pipeline/e2e_evaluator.py`

### Other components

- **Analyst**
- **Clinical database**
- **Vector store**
- **Internal configuration store**

## Connections

- Analyst → React application: uses
- React application → Chat interface: opens chat (evidence: `frontend/src/App.tsx`)
- Chat interface → FastAPI application: sends questions
- FastAPI application → Chat routes: routes requests (evidence: `backend/app/app.py`)
- Chat routes → Chat orchestration: calls
- Chat orchestration → Intent routing: classifies intent
- Chat orchestration → SQL analysis: runs SQL
- Chat orchestration → Vector retrieval: retrieves context
- Chat orchestration → Hybrid synthesis: synthesizes results
- SQL analysis → Clinical database: queries
- Vector retrieval → Vector store: searches
- SQL analysis → Language models: generates SQL
- Hybrid synthesis → Language models: generates answer
- Data source management → Clinical database: connects runtime
- Data source management → Embedding service: indexes documents
- Embedding service → Vector store: stores vectors
- Agent configuration → Internal configuration store: persists configuration
- AI model registry → Internal configuration store: persists registry
- Authentication and RBAC → User management: provisions identities (evidence: `backend/app/core/auth/permissions.py`)
- User management → Internal configuration store: stores users
- FastAPI application → Authentication and RBAC: enforces access
- FastAPI application → Audit logging: records actions
- FastAPI application → Observability: reports analytics
- RAG evaluation → Chat orchestration: evaluates pipeline
