# rohitkmr27/ai-soc-rag architecture

> Architecture diagram of the GitHub repository rohitkmr27/ai-soc-rag, 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/rohitkmr27/ai-soc-rag
- Repository: https://github.com/rohitkmr27/ai-soc-rag

## Overview

AI-SOC is a security operations application combining flow-based intrusion detection, alert management, incident correlation/investigation, and a cybersecurity knowledge base. Analysts submit flow features or CSVs, review persisted alerts and correlated incidents, and can request grounded enrichment or investigation. The frontend routes authenticated users to these workflows and calls the FastAPI API. README documents ingestion, embedding, indexing, and search capabilities beyond the sampled source; their internal wiring is therefore shown only where documented. Some subsystem links rely on README statements rather than inspected implementations.

Main entry points: [`backend/app/main.py`](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/main.py) (FastAPI application), [`backend/app/alerts/api.py`](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/api.py) (Alert endpoints), [`backend/app/rag/search.py`](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/search.py) (Knowledge search), [`frontend/src/App.tsx`](https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Analyst interface"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_authstate["Auth state<br/>[AuthContext.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_workflow_pages["SOC workflows"]
end

subgraph group_api["API and identity"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_identity["Identity and access<br/>[dependencies.py]"]
  node_user_store[("User records<br/>[models.py]")]
  node_database["Database sessions<br/>[database.py]"]
end

subgraph group_detection["Detection and alerts"]
  node_ids_api["IDS endpoints<br/>[api.py]"]
  node_ids_predict["Flow prediction<br/>[prediction.py]"]
  node_ids_model["IDS model<br/>[model.py]"]
  node_ids_training["IDS preparation and training"]
  node_alert_api["Alert endpoints<br/>[api.py]"]
  node_alert_service["Alert persistence<br/>[service.py]"]
  node_alert_store[("Alert records<br/>[models.py]")]
end

subgraph group_investigation["Incident investigation"]
  node_correlation["Incident correlation<br/>[correlation.py]"]
  node_investigation_api["Investigation API<br/>[api.py]"]
  node_investigation["Incident investigation"]
  node_enrichment["Alert enrichment"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_ingestion["Document ingestion<br/>[document_loader.py]"]
  node_indexing["Embedding and indexing<br/>[index.py]"]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
  node_vector_store[("Vector store<br/>[vector_store.py]")]
  node_retrieval["Knowledge search<br/>[search.py]"]
  node_generation["RAG generation<br/>[generator.py]"]
  node_llm["Gemini provider<br/>[llm.py]"]
end

node_analyst(("Analyst"))
node_gemini["Google Gemini"]

node_analyst -->|"uses"| node_webapp
node_webapp -->|"provides auth"| node_authstate
node_webapp -->|"routes to"| node_workflow_pages
node_authstate -->|"calls"| node_api_client
node_workflow_pages -->|"requests data"| node_api_client
node_api_client -->|"HTTP requests"| node_backend
node_backend -->|"registers routes"| node_identity
node_backend -->|"registers routes"| node_ids_api
node_backend -->|"registers routes"| node_alert_api
node_backend -->|"registers routes"| node_investigation_api
node_identity -->|"opens session"| node_database
node_identity -->|"loads user"| node_user_store
node_ids_api -->|"predicts flows"| node_ids_predict
node_ids_predict -->|"loads model"| node_ids_model
node_ids_training -->|"creates artifact"| node_ids_model
node_alert_api -->|"runs IDS"| node_ids_predict
node_alert_api -->|"delegates persistence"| node_alert_service
node_alert_service -->|"creates and reads"| node_alert_store
node_alert_api -->|"correlates alerts"| node_correlation
node_investigation_api -->|"investigates incidents"| node_investigation
node_alert_api -->|"enriches alerts"| node_enrichment
node_ingestion -->|"provides chunks"| node_indexing
node_indexing -->|"embeds chunks"| node_embeddings
node_indexing -->|"stores vectors"| node_vector_store
node_retrieval -->|"searches vectors"| node_vector_store
node_investigation -.->|"retrieves context"| node_retrieval
node_enrichment -.->|"retrieves context"| node_retrieval
node_generation -.->|"uses search results"| node_retrieval
node_generation -.->|"requests generation"| node_llm
node_llm -->|"calls provider"| node_gemini

click node_webapp "https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/App.tsx"
click node_authstate "https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/context/AuthContext.tsx"
click node_api_client "https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/services/api.ts"
click node_workflow_pages "https://github.com/rohitkmr27/ai-soc-rag/tree/master/frontend/src/pages"
click node_backend "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/main.py"
click node_identity "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/auth/dependencies.py"
click node_user_store "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/auth/models.py"
click node_database "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/database.py"
click node_ids_api "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/api.py"
click node_ids_predict "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/prediction.py"
click node_ids_model "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/model.py"
click node_ids_training "https://github.com/rohitkmr27/ai-soc-rag/tree/master/backend/app/ids"
click node_alert_api "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/api.py"
click node_alert_service "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/service.py"
click node_alert_store "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/models.py"
click node_correlation "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/correlation.py"
click node_investigation_api "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/api.py"
click node_investigation "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/incident_investigation.py"
click node_enrichment "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/alert_enrichment.py"
click node_ingestion "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/document_loader.py"
click node_indexing "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/index.py"
click node_embeddings "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/embeddings.py"
click node_vector_store "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/vector_store.py"
click node_retrieval "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/search.py"
click node_generation "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/generator.py"
click node_llm "https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/llm.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_authstate,node_api_client,node_workflow_pages toneBlue
class node_backend,node_identity,node_user_store,node_database toneAmber
class node_ids_api,node_ids_predict,node_ids_model,node_ids_training,node_alert_api,node_alert_service,node_alert_store toneMint
class node_correlation,node_investigation_api,node_investigation,node_enrichment toneRose
class node_ingestion,node_indexing,node_embeddings,node_vector_store,node_retrieval,node_generation,node_llm,node_analyst,node_gemini toneIndigo
```

## Components

### Analyst interface

- [Web application](https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth state](https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [API client](https://github.com/rohitkmr27/ai-soc-rag/blob/master/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [SOC workflows](https://github.com/rohitkmr27/ai-soc-rag/tree/master/frontend/src/pages): `frontend/src/pages`

### API and identity

- [FastAPI application](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/main.py): `backend/app/main.py`
- [Identity and access](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [User records](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/auth/models.py): `backend/app/auth/models.py`
- [Database sessions](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/database.py): `backend/app/database.py`

### Detection and alerts

- [IDS endpoints](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/api.py): `backend/app/ids/api.py`
- [Flow prediction](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/prediction.py): `backend/app/ids/prediction.py`
- [IDS model](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/ids/model.py): `backend/app/ids/model.py`
- [IDS preparation and training](https://github.com/rohitkmr27/ai-soc-rag/tree/master/backend/app/ids): `backend/app/ids`
- [Alert endpoints](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/api.py): `backend/app/alerts/api.py`
- [Alert persistence](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/service.py): `backend/app/alerts/service.py`
- [Alert records](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/models.py): `backend/app/alerts/models.py`

### Incident investigation

- [Incident correlation](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/alerts/correlation.py): `backend/app/alerts/correlation.py`
- [Investigation API](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/api.py): `backend/app/rag/api.py`
- [Incident investigation](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/incident_investigation.py): `backend/app/rag/incident_investigation.py`
- [Alert enrichment](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/alert_enrichment.py): `backend/app/rag/alert_enrichment.py`

### Knowledge retrieval

- [Document ingestion](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/document_loader.py): `backend/app/rag/document_loader.py`
- [Embedding and indexing](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/index.py): `backend/app/rag/index.py`
- [Text embeddings](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/embeddings.py): `backend/app/rag/embeddings.py`
- [Vector store](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/vector_store.py): `backend/app/rag/vector_store.py`
- [Knowledge search](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/search.py): `backend/app/rag/search.py`
- [RAG generation](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/generator.py): `backend/app/rag/generator.py`
- [Gemini provider](https://github.com/rohitkmr27/ai-soc-rag/blob/master/backend/app/rag/llm.py): `backend/app/rag/llm.py`

### Other components

- **Analyst**
- **Google Gemini**

## Connections

- Analyst → Web application: uses (evidence: `frontend/src/App.tsx`)
- Web application → Auth state: provides auth (evidence: `frontend/src/App.tsx`)
- Web application → SOC workflows: routes to (evidence: `frontend/src/App.tsx`)
- Auth state → API client: calls (evidence: `frontend/src/context/AuthContext.tsx`)
- SOC workflows → API client: requests data (evidence: `frontend/src/pages/IncidentDetailPage.tsx`)
- API client → FastAPI application: HTTP requests (evidence: `frontend/src/services/api.ts`)
- FastAPI application → Identity and access: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → IDS endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Alert endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Investigation API: registers routes (evidence: `backend/app/main.py`)
- Identity and access → Database sessions: opens session (evidence: `backend/app/auth/dependencies.py`)
- Identity and access → User records: loads user (evidence: `backend/app/auth/dependencies.py`)
- IDS endpoints → Flow prediction: predicts flows (evidence: `backend/app/ids/api.py`)
- Flow prediction → IDS model: loads model (evidence: `backend/app/ids/prediction.py`)
- IDS preparation and training → IDS model: creates artifact (evidence: `README.md`)
- Alert endpoints → Flow prediction: runs IDS (evidence: `backend/app/alerts/api.py`)
- Alert endpoints → Alert persistence: delegates persistence (evidence: `backend/app/alerts/api.py`)
- Alert persistence → Alert records: creates and reads (evidence: `backend/app/alerts/service.py`)
- Alert endpoints → Incident correlation: correlates alerts (evidence: `backend/app/alerts/api.py`)
- Investigation API → Incident investigation: investigates incidents (evidence: `backend/app/rag/api.py`)
- Alert endpoints → Alert enrichment: enriches alerts (evidence: `backend/app/alerts/api.py`)
- Document ingestion → Embedding and indexing: provides chunks (evidence: `README.md`)
- Embedding and indexing → Text embeddings: embeds chunks (evidence: `README.md`)
- Embedding and indexing → Vector store: stores vectors (evidence: `README.md`)
- Knowledge search → Vector store: searches vectors (evidence: `README.md`)
- Incident investigation → Knowledge search: retrieves context
- Alert enrichment → Knowledge search: retrieves context
- RAG generation → Knowledge search: uses search results
- RAG generation → Gemini provider: requests generation
- Gemini provider → Google Gemini: calls provider (evidence: `backend/app/rag/llm.py`)
