# anujbendre/ai-ransomware-detection-system architecture

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

- Interactive diagram: https://gitdiagram.com/anujbendre/ai-ransomware-detection-system
- Repository: https://github.com/anujbendre/ai-ransomware-detection-system

## Overview

This is an AI-based ransomware detection system: filesystem activity is recorded, event counts feed a machine-learning prediction, and alerts and event analytics are exposed through a FastAPI backend for a React dashboard. The main documented path is file monitoring through detection and alerting to dashboard display. Some connections are supported only by the README or the SOURCE INDEX; unsampled implementations are represented by their existing paths, with uncertain wiring left out or marked dashed.

Main entry points: [`frontend/src/components/Dashboard.jsx`](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/Dashboard.jsx) (Dashboard), [`backend/routes/stats.py`](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/stats.py) (Stats endpoint), [`backend/main.py`](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/main.py) (FastAPI app), [`backend/monitoring/event_handler.py`](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/event_handler.py) (Event handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Monitoring and detection"]
  node_file_monitor["File monitor<br/>[file_monitor.py]"]
  node_event_handler["Event handler<br/>[event_handler.py]"]
  node_feature_collector["Feature collector"]
  node_predictor["ML predictor<br/>[predict.py]"]
  node_model["Trained model"]
end

subgraph group_storage_api["Storage and API"]
  node_events_csv[("Events CSV<br/>[events.csv]")]
  node_alerts_csv[("Alerts CSV<br/>[alerts.csv]")]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_events_route["Events endpoint<br/>[events.py]"]
  node_alerts_route["Alerts endpoint<br/>[alerts.py]"]
  node_stats_route["Stats endpoint<br/>[stats.py]"]
end

subgraph group_frontend["Dashboard"]
  node_react_app["React app<br/>[App.jsx]"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_api_client["API client<br/>[api.jsx]"]
  node_stats_cards["Stats cards<br/>[StatsCards.jsx]"]
  node_event_chart["Event chart<br/>[EventChart.jsx]"]
  node_threat_meter["Threat meter<br/>[ThreatMeter.jsx]"]
  node_events_table["Events table<br/>[EventsTable.jsx]"]
  node_alerts_table["Alerts table<br/>[AlertsTable.jsx]"]
end

node_user(("User activity"))

node_user -->|"changes files"| node_file_monitor
node_file_monitor -->|"dispatches events"| node_event_handler
node_event_handler -->|"writes events"| node_events_csv
node_event_handler -->|"updates counts"| node_feature_collector
node_feature_collector -->|"requests prediction"| node_predictor
node_predictor -->|"loads and predicts"| node_model
node_feature_collector -->|"writes alerts"| node_alerts_csv
node_api_app -->|"mounts router"| node_events_route
node_api_app -->|"mounts router"| node_alerts_route
node_api_app -->|"mounts router"| node_stats_route
node_events_route -->|"reads events"| node_events_csv
node_alerts_route -->|"reads alerts"| node_alerts_csv
node_stats_route -->|"reads events"| node_events_csv
node_stats_route -->|"reads alerts"| node_alerts_csv
node_react_app -->|"renders"| node_landing
node_react_app -->|"renders"| node_dashboard
node_dashboard -->|"requests data through"| node_api_client
node_dashboard -->|"requests events"| node_events_route
node_dashboard -->|"requests alerts"| node_alerts_route
node_dashboard -->|"requests stats"| node_stats_route
node_dashboard -->|"renders"| node_stats_cards
node_dashboard -->|"renders"| node_event_chart
node_dashboard -->|"renders"| node_threat_meter
node_dashboard -->|"renders"| node_events_table
node_dashboard -->|"renders"| node_alerts_table

click node_file_monitor "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/file_monitor.py"
click node_event_handler "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/event_handler.py"
click node_feature_collector "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/feature_collector.py"
click node_predictor "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/ml/predict.py"
click node_model "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/ml/ransomware_model.pkl"
click node_events_csv "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/storage/events.csv"
click node_alerts_csv "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/storage/alerts.csv"
click node_api_app "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/main.py"
click node_events_route "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/events.py"
click node_alerts_route "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/alerts.py"
click node_stats_route "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/stats.py"
click node_react_app "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/LandingPage.jsx"
click node_dashboard "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/Dashboard.jsx"
click node_api_client "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/services/api.jsx"
click node_stats_cards "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/StatsCards.jsx"
click node_event_chart "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/EventChart.jsx"
click node_threat_meter "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/ThreatMeter.jsx"
click node_events_table "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/EventsTable.jsx"
click node_alerts_table "https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/AlertsTable.jsx"

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_file_monitor,node_event_handler,node_feature_collector,node_predictor,node_model,node_user toneBlue
class node_events_csv,node_alerts_csv,node_api_app,node_events_route,node_alerts_route,node_stats_route toneAmber
class node_react_app,node_landing,node_dashboard,node_api_client,node_stats_cards,node_event_chart,node_threat_meter,node_events_table,node_alerts_table toneMint
```

## Components

### Monitoring and detection

- [File monitor](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/file_monitor.py): `backend/monitoring/file_monitor.py`
- [Event handler](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/event_handler.py): `backend/monitoring/event_handler.py`
- [Feature collector](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/monitoring/feature_collector.py): `backend/monitoring/feature_collector.py`
- [ML predictor](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/ml/predict.py): `backend/ml/predict.py`
- [Trained model](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/ml/ransomware_model.pkl): `backend/ml/ransomware_model.pkl`

### Storage and API

- [Events CSV](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/storage/events.csv): `backend/storage/events.csv`
- [Alerts CSV](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/storage/alerts.csv): `backend/storage/alerts.csv`
- [FastAPI app](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/main.py): `backend/main.py`
- [Events endpoint](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/events.py): `backend/routes/events.py`
- [Alerts endpoint](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/alerts.py): `backend/routes/alerts.py`
- [Stats endpoint](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/backend/routes/stats.py): `backend/routes/stats.py`

### Dashboard

- [React app](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing page](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/LandingPage.jsx): `frontend/src/components/LandingPage.jsx`
- [Dashboard](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/Dashboard.jsx): `frontend/src/components/Dashboard.jsx`
- [API client](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/services/api.jsx): `frontend/src/services/api.jsx`
- [Stats cards](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/StatsCards.jsx): `frontend/src/components/StatsCards.jsx`
- [Event chart](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/EventChart.jsx): `frontend/src/components/EventChart.jsx`
- [Threat meter](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/ThreatMeter.jsx): `frontend/src/components/ThreatMeter.jsx`
- [Events table](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/EventsTable.jsx): `frontend/src/components/EventsTable.jsx`
- [Alerts table](https://github.com/anujbendre/ai-ransomware-detection-system/blob/main/frontend/src/components/AlertsTable.jsx): `frontend/src/components/AlertsTable.jsx`

### Other components

- **User activity**

## Connections

- User activity → File monitor: changes files (evidence: `README.md`)
- File monitor → Event handler: dispatches events (evidence: `backend/monitoring/file_monitor.py`)
- Event handler → Events CSV: writes events (evidence: `backend/monitoring/event_handler.py`)
- Event handler → Feature collector: updates counts (evidence: `backend/monitoring/event_handler.py`)
- Feature collector → ML predictor: requests prediction (evidence: `backend/monitoring/feature_collector.py`)
- ML predictor → Trained model: loads and predicts (evidence: `backend/ml/predict.py`)
- Feature collector → Alerts CSV: writes alerts (evidence: `backend/monitoring/feature_collector.py`)
- FastAPI app → Events endpoint: mounts router (evidence: `backend/main.py`)
- FastAPI app → Alerts endpoint: mounts router (evidence: `backend/main.py`)
- FastAPI app → Stats endpoint: mounts router (evidence: `backend/main.py`)
- Events endpoint → Events CSV: reads events (evidence: `backend/routes/events.py`)
- Alerts endpoint → Alerts CSV: reads alerts (evidence: `backend/routes/alerts.py`)
- Stats endpoint → Events CSV: reads events (evidence: `backend/routes/stats.py`)
- Stats endpoint → Alerts CSV: reads alerts (evidence: `backend/routes/stats.py`)
- React app → Landing page: renders (evidence: `frontend/src/App.jsx`)
- React app → Dashboard: renders (evidence: `frontend/src/App.jsx`)
- Dashboard → API client: requests data through (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Events endpoint: requests events (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Alerts endpoint: requests alerts (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Stats endpoint: requests stats (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Stats cards: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Event chart: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Threat meter: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Events table: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Dashboard → Alerts table: renders (evidence: `frontend/src/components/Dashboard.jsx`)
