# ranjithkumar-kb/ai-soc architecture

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

- Interactive diagram: https://gitdiagram.com/ranjithkumar-kb/ai-soc
- Repository: https://github.com/ranjithkumar-kb/ai-soc

## Overview

This repository is an AI-assisted security operations platform: it accepts login and network events, evaluates them for brute-force and SQL-injection activity, records blocks and alerts, and exposes SOC metrics and generated incident PDFs. The API can also query external IP intelligence. The graph includes the documented-by-code collection, MCP, and reporting surfaces, but several are isolated where the available excerpts do not establish their runtime wiring. The README is empty; relationships are limited to shown calls and imports.

Main entry points: [`backend/main.py`](https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/main.py) (REST API), [`database/models.py`](https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/models.py) (Security database), [`ai_agent/agent.py`](https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/agent.py) (Security agent), [`backend/routes/reports.py`](https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/routes/reports.py) (Report endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and interface"]
  node_frontend["Dashboard UI<br/>[app.py]"]
  node_api_service["REST API<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_analysis["Detection and response"]
  node_rule_engine["Detection rules<br/>[detection_logic.py]"]
  node_agent["Security agent<br/>[agent.py]"]
  node_prompts["Agent prompts<br/>[prompts.py]"]
  node_alarm["Alarm audio<br/>[sound_engine.py]"]
end

subgraph group_data["Telemetry and state"]
  node_database[("Security database<br/>[models.py]")]
  node_schema_setup["Schema setup<br/>[db_setup.py]"]
  node_seed_data["Sample data seeding<br/>[seed_data.py]"]
  node_sniffer["Packet sniffer<br/>[sniffer.py]"]
  node_win_collector["Windows log collector<br/>[win_collector.py]"]
end

subgraph group_integrations["Reports and integrations"]
  node_reports_router["Report endpoint<br/>[reports.py]"]
  node_pdf_generator["PDF generation<br/>[pdf_generator.py]"]
  node_mcp_server["MCP server<br/>[server.py]"]
  node_ip_intel(("IP intelligence service"))
end

node_operator(("SOC operator"))

node_operator -.->|"uses dashboard"| node_frontend
node_api_service -->|"reads and writes"| node_database
node_api_service -->|"evaluates logs"| node_rule_engine
node_api_service -->|"runs agent"| node_agent
node_api_service -->|"mounts routes"| node_reports_router
node_api_service -->|"queries IP"| node_ip_intel
node_agent -->|"runs audit"| node_rule_engine
node_agent -->|"records mitigations"| node_database
node_sniffer -->|"stores packets"| node_database
node_schema_setup -->|"creates schema"| node_database
node_seed_data -->|"seeds records"| node_database
node_reports_router -->|"generates PDF"| node_pdf_generator

click node_frontend "https://github.com/ranjithkumar-kb/ai-soc/blob/main/frontend/app.py"
click node_api_service "https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/main.py"
click node_auth "https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/auth.py"
click node_rule_engine "https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/detection_logic.py"
click node_agent "https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/agent.py"
click node_prompts "https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/prompts.py"
click node_alarm "https://github.com/ranjithkumar-kb/ai-soc/blob/main/alerts/sound_engine.py"
click node_database "https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/models.py"
click node_schema_setup "https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/db_setup.py"
click node_seed_data "https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/seed_data.py"
click node_sniffer "https://github.com/ranjithkumar-kb/ai-soc/blob/main/sniffer.py"
click node_win_collector "https://github.com/ranjithkumar-kb/ai-soc/blob/main/logs/win_collector.py"
click node_reports_router "https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/routes/reports.py"
click node_pdf_generator "https://github.com/ranjithkumar-kb/ai-soc/blob/main/reports/pdf_generator.py"
click node_mcp_server "https://github.com/ranjithkumar-kb/ai-soc/blob/main/mcp_server/server.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_frontend,node_api_service,node_auth toneBlue
class node_rule_engine,node_agent,node_prompts,node_alarm toneAmber
class node_database,node_schema_setup,node_seed_data,node_sniffer,node_win_collector toneMint
class node_reports_router,node_pdf_generator,node_mcp_server,node_ip_intel toneRose
class node_operator toneIndigo
```

## Components

### API and interface

- [Dashboard UI](https://github.com/ranjithkumar-kb/ai-soc/blob/main/frontend/app.py): `frontend/app.py`
- [REST API](https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/auth.py): `backend/auth.py`

### Detection and response

- [Detection rules](https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/detection_logic.py): `ai_agent/detection_logic.py`
- [Security agent](https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/agent.py): `ai_agent/agent.py`
- [Agent prompts](https://github.com/ranjithkumar-kb/ai-soc/blob/main/ai_agent/prompts.py): `ai_agent/prompts.py`
- [Alarm audio](https://github.com/ranjithkumar-kb/ai-soc/blob/main/alerts/sound_engine.py): `alerts/sound_engine.py`

### Telemetry and state

- [Security database](https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/models.py): `database/models.py`
- [Schema setup](https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/db_setup.py): `database/db_setup.py`
- [Sample data seeding](https://github.com/ranjithkumar-kb/ai-soc/blob/main/database/seed_data.py): `database/seed_data.py`
- [Packet sniffer](https://github.com/ranjithkumar-kb/ai-soc/blob/main/sniffer.py): `sniffer.py`
- [Windows log collector](https://github.com/ranjithkumar-kb/ai-soc/blob/main/logs/win_collector.py): `logs/win_collector.py`

### Reports and integrations

- [Report endpoint](https://github.com/ranjithkumar-kb/ai-soc/blob/main/backend/routes/reports.py): `backend/routes/reports.py`
- [PDF generation](https://github.com/ranjithkumar-kb/ai-soc/blob/main/reports/pdf_generator.py): `reports/pdf_generator.py`
- [MCP server](https://github.com/ranjithkumar-kb/ai-soc/blob/main/mcp_server/server.py): `mcp_server/server.py`
- **IP intelligence service**

### Other components

- **SOC operator**

## Connections

- SOC operator → Dashboard UI: uses dashboard
- REST API → Security database: reads and writes (evidence: `backend/main.py`)
- REST API → Detection rules: evaluates logs (evidence: `backend/main.py`)
- REST API → Security agent: runs agent (evidence: `backend/main.py`)
- REST API → Report endpoint: mounts routes (evidence: `backend/main.py`)
- REST API → IP intelligence service: queries IP (evidence: `backend/main.py`)
- Security agent → Detection rules: runs audit (evidence: `ai_agent/agent.py`)
- Security agent → Security database: records mitigations (evidence: `ai_agent/agent.py`)
- Packet sniffer → Security database: stores packets (evidence: `sniffer.py`)
- Schema setup → Security database: creates schema (evidence: `database/db_setup.py`)
- Sample data seeding → Security database: seeds records (evidence: `database/seed_data.py`)
- Report endpoint → PDF generation: generates PDF (evidence: `backend/routes/reports.py`)
