# vatsa095/ai-investigation-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/vatsa095/ai-investigation-copilot
- Repository: https://github.com/vatsa095/ai-investigation-copilot

## Overview

AI Investigation Copilot is a case-management and investigation-analysis application: investigators can search records, inspect cases and movement timelines, and use AI-assisted suspect and case-link analysis. The graph separates the Next.js interface, FastAPI endpoints, investigation/ML logic, and persistence. Sampled evidence confirms backend router registration and several endpoint dependencies; frontend-to-backend request wiring and some unsampled endpoint behavior are not established, so those links are omitted.

Main entry points: [`backend/app/main.py`](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/main.py) (FastAPI Application), [`backend/app/models.py`](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/models.py) (Case Data Models), [`backend/app/database.py`](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/database.py) (SQL Database Access), [`backend/app/api/cases.py`](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/cases.py) (Case Endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Investigator Interface"]
  node_search_ui["Universal Search UI<br/>[page.js]"]
  node_case_ui["Case Views<br/>[page.js]"]
  node_case_list_ui["Case List<br/>[page.js]"]
  node_create_case_ui["Case Entry<br/>[page.js]"]
  node_dashboard_ui["Dashboard<br/>[page.js]"]
  node_investigation_graph["Investigation Graph"]
  node_movement_map["Movement Map<br/>[MovementMap.js]"]
  node_web_case_api["Web Case Routes<br/>[route.js]"]
  node_web_timeline_api["Web Timeline Route<br/>[route.js]"]
  node_web_search_api["Web Search Route<br/>[route.js]"]
  node_web_ai_api["Web AI Route<br/>[route.js]"]
  node_web_analytics_api["Web Analytics Route<br/>[route.js]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI Application<br/>[main.py]"]
  node_case_api["Case Endpoints<br/>[cases.py]"]
  node_search_api["Search Endpoint<br/>[search.py]"]
  node_suspect_api["Suspect Endpoint<br/>[suspects.py]"]
  node_analytics_api["Analytics Endpoint<br/>[analytics.py]"]
  node_ai_api["AI Endpoint<br/>[ai.py]"]
  node_reports_api["Report Endpoint<br/>[reports.py]"]
end

subgraph group_analysis["Investigation Analysis"]
  node_investigation_model["Investigation Analysis<br/>[model.py]"]
  node_ai_service["Report Generation<br/>[ai_service.py]"]
  node_ml_db_adapter["ML Data Adapter<br/>[db_adapter.py]"]
  node_dataset["Training Dataset<br/>[dataset.py]"]
end

subgraph group_data["Case Data"]
  node_case_crud["Case Operations<br/>[case.py]"]
  node_person_crud["Person Operations<br/>[person.py]"]
  node_data_models["Case Data Models<br/>[models.py]"]
  node_schemas["Request Schemas<br/>[schemas.py]"]
  node_database[("SQL Database Access<br/>[database.py]")]
end

node_investigator(("Investigator"))

node_investigator -->|"searches records"| node_search_ui
node_search_ui -->|"renders analysis"| node_investigation_graph
node_search_ui -->|"renders timeline"| node_movement_map
node_investigator -.->|"opens case"| node_case_ui
node_investigator -.->|"enters case"| node_create_case_ui
node_investigator -.->|"views dashboard"| node_dashboard_ui
node_fastapi -->|"registers router"| node_case_api
node_fastapi -->|"registers router"| node_search_api
node_fastapi -->|"registers router"| node_suspect_api
node_fastapi -->|"registers router"| node_analytics_api
node_fastapi -->|"registers router"| node_ai_api
node_fastapi -->|"registers router"| node_reports_api
node_fastapi -->|"initializes tables"| node_database
node_case_api -->|"calls operations"| node_case_crud
node_case_api -->|"queries records"| node_data_models
node_case_api -->|"validates payloads"| node_schemas
node_case_api -->|"injects session"| node_database
node_search_api -->|"queries records"| node_data_models
node_search_api -->|"injects session"| node_database
node_suspect_api -->|"uses operations"| node_person_crud
node_suspect_api -->|"injects session"| node_database
node_analytics_api -->|"queries records"| node_data_models
node_analytics_api -->|"injects session"| node_database
node_ai_api -->|"runs analysis"| node_investigation_model
node_ai_api -->|"loads analysis data"| node_ml_db_adapter
node_ai_api -->|"generates report"| node_ai_service
node_reports_api -->|"uses analysis"| node_investigation_model
node_reports_api -->|"generates report"| node_ai_service
node_reports_api -->|"uses dataset"| node_dataset
node_case_crud -->|"operates on"| node_data_models
node_person_crud -->|"operates on"| node_data_models
node_data_models -->|"maps tables"| node_database
node_ml_db_adapter -->|"reads records"| node_data_models

click node_search_ui "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/search/page.js"
click node_case_ui "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/case/%5Bid%5D/page.js"
click node_case_list_ui "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/case/page.js"
click node_create_case_ui "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/create-case/page.js"
click node_dashboard_ui "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/dashboard/page.js"
click node_investigation_graph "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/components/InvestigationGraph.js"
click node_movement_map "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/components/MovementMap.js"
click node_web_case_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/cases/route.js"
click node_web_timeline_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/cases/%5Bid%5D/timeline/route.js"
click node_web_search_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/search/route.js"
click node_web_ai_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/ai/route.js"
click node_web_analytics_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/analytics/route.js"
click node_fastapi "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/main.py"
click node_case_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/cases.py"
click node_search_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/search.py"
click node_suspect_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/suspects.py"
click node_analytics_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/analytics.py"
click node_ai_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/ai.py"
click node_reports_api "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/reports.py"
click node_case_crud "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/crud/case.py"
click node_person_crud "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/crud/person.py"
click node_data_models "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/models.py"
click node_schemas "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/schemas.py"
click node_database "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/database.py"
click node_investigation_model "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/model.py"
click node_ai_service "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/ai_service.py"
click node_ml_db_adapter "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/db_adapter.py"
click node_dataset "https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/dataset.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_search_ui,node_case_ui,node_case_list_ui,node_create_case_ui,node_dashboard_ui,node_investigation_graph,node_movement_map,node_web_case_api,node_web_timeline_api,node_web_search_api,node_web_ai_api,node_web_analytics_api toneBlue
class node_fastapi,node_case_api,node_search_api,node_suspect_api,node_analytics_api,node_ai_api,node_reports_api toneAmber
class node_investigation_model,node_ai_service,node_ml_db_adapter,node_dataset toneMint
class node_case_crud,node_person_crud,node_data_models,node_schemas,node_database toneRose
class node_investigator toneIndigo
```

## Components

### Investigator Interface

- [Universal Search UI](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/search/page.js): `app/search/page.js`
- [Case Views](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/case/%5Bid%5D/page.js): `app/case/[id]/page.js`
- [Case List](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/case/page.js): `app/case/page.js`
- [Case Entry](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/create-case/page.js): `app/create-case/page.js`
- [Dashboard](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/dashboard/page.js): `app/dashboard/page.js`
- [Investigation Graph](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/components/InvestigationGraph.js): `app/components/InvestigationGraph.js`
- [Movement Map](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/components/MovementMap.js): `app/components/MovementMap.js`
- [Web Case Routes](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/cases/route.js): `app/api/cases/route.js`
- [Web Timeline Route](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/cases/%5Bid%5D/timeline/route.js): `app/api/cases/[id]/timeline/route.js`
- [Web Search Route](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/search/route.js): `app/api/search/route.js`
- [Web AI Route](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/ai/route.js): `app/api/ai/route.js`
- [Web Analytics Route](https://github.com/vatsa095/ai-investigation-copilot/blob/main/app/api/analytics/route.js): `app/api/analytics/route.js`

### Backend API

- [FastAPI Application](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Case Endpoints](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/cases.py): `backend/app/api/cases.py`
- [Search Endpoint](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/search.py): `backend/app/api/search.py`
- [Suspect Endpoint](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/suspects.py): `backend/app/api/suspects.py`
- [Analytics Endpoint](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/analytics.py): `backend/app/api/analytics.py`
- [AI Endpoint](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/ai.py): `backend/app/api/ai.py`
- [Report Endpoint](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/api/reports.py): `backend/app/api/reports.py`

### Investigation Analysis

- [Investigation Analysis](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/model.py): `backend/app/ml/model.py`
- [Report Generation](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/ai_service.py): `backend/app/ml/ai_service.py`
- [ML Data Adapter](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/db_adapter.py): `backend/app/ml/db_adapter.py`
- [Training Dataset](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/ml/dataset.py): `backend/app/ml/dataset.py`

### Case Data

- [Case Operations](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/crud/case.py): `backend/app/crud/case.py`
- [Person Operations](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/crud/person.py): `backend/app/crud/person.py`
- [Case Data Models](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/models.py): `backend/app/models.py`
- [Request Schemas](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [SQL Database Access](https://github.com/vatsa095/ai-investigation-copilot/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Investigator**

## Connections

- Investigator → Universal Search UI: searches records (evidence: `app/search/page.js`)
- Universal Search UI → Investigation Graph: renders analysis (evidence: `app/search/page.js`)
- Universal Search UI → Movement Map: renders timeline (evidence: `app/search/page.js`)
- Investigator → Case Views: opens case
- Investigator → Case Entry: enters case
- Investigator → Dashboard: views dashboard
- FastAPI Application → Case Endpoints: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Search Endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Suspect Endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Analytics Endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → AI Endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → Report Endpoint: registers router (evidence: `backend/app/main.py`)
- FastAPI Application → SQL Database Access: initializes tables (evidence: `backend/app/main.py`)
- Case Endpoints → Case Operations: calls operations (evidence: `backend/app/api/cases.py`)
- Case Endpoints → Case Data Models: queries records (evidence: `backend/app/api/cases.py`)
- Case Endpoints → Request Schemas: validates payloads (evidence: `backend/app/api/cases.py`)
- Case Endpoints → SQL Database Access: injects session (evidence: `backend/app/api/cases.py`)
- Search Endpoint → Case Data Models: queries records (evidence: `backend/app/api/search.py`)
- Search Endpoint → SQL Database Access: injects session (evidence: `backend/app/api/search.py`)
- Suspect Endpoint → Person Operations: uses operations (evidence: `backend/app/api/suspects.py`)
- Suspect Endpoint → SQL Database Access: injects session (evidence: `backend/app/api/suspects.py`)
- Analytics Endpoint → Case Data Models: queries records (evidence: `backend/app/api/analytics.py`)
- Analytics Endpoint → SQL Database Access: injects session (evidence: `backend/app/api/analytics.py`)
- AI Endpoint → Investigation Analysis: runs analysis (evidence: `backend/app/api/ai.py`)
- AI Endpoint → ML Data Adapter: loads analysis data (evidence: `backend/app/api/ai.py`)
- AI Endpoint → Report Generation: generates report (evidence: `backend/app/api/ai.py`)
- Report Endpoint → Investigation Analysis: uses analysis (evidence: `backend/app/api/reports.py`)
- Report Endpoint → Report Generation: generates report (evidence: `backend/app/api/reports.py`)
- Report Endpoint → Training Dataset: uses dataset (evidence: `backend/app/api/reports.py`)
- Case Operations → Case Data Models: operates on (evidence: `backend/app/crud/case.py`)
- Person Operations → Case Data Models: operates on (evidence: `backend/app/crud/person.py`)
- Case Data Models → SQL Database Access: maps tables (evidence: `backend/app/models.py`)
- ML Data Adapter → Case Data Models: reads records (evidence: `backend/app/ml/db_adapter.py`)
