# priyanshudahiya757/cyber-threat-detection-and-incident-response architecture

> Architecture diagram of the GitHub repository priyanshudahiya757/cyber-threat-detection-and-incident-response, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshudahiya757/cyber-threat-detection-and-incident-response
- Repository: https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response

## Overview

Cyber Threat Detection is a SOC application for ingesting security logs, detecting threats with rules and ML, correlating detections into incidents, and supporting analyst workflows through a web interface. The principal backend flow is upload/API ingestion → source parsing and normalization → deduplication and indexing → rule and ML detection → alerting and incident correlation. The graph also preserves authentication, analytics, rule management, and the frontend’s major feature areas. Some frontend-to-API wiring and unsampled API behavior are not shown, so those relationships are omitted.

Main entry points: [`backend/app/detection/engine.py`](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/engine.py) (Rule engine), [`backend/app/ingestion/pipeline.py`](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/ingestion/pipeline.py) (Ingestion pipeline), [`backend/app/db/mongo.py`](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/db/mongo.py) (Application data store), [`backend/app/detection/ml/prediction_service.py`](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/prediction_service.py) (ML prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Log ingestion"]
  node_pipeline["Ingestion pipeline<br/>[pipeline.py]"]
  node_parsers["Source parsers"]
  node_normalizer["Log normalizer<br/>[normalizer.py]"]
  node_log_schema["Normalized log schema<br/>[log_schema.py]"]
end

subgraph group_detect["Threat detection"]
  node_engine["Rule engine<br/>[engine.py]"]
  node_rules["Detection rules"]
  node_prediction["ML prediction"]
  node_features["ML features"]
  node_registry["Model registry<br/>[model_registry.py]"]
  node_training["Model training"]
  node_detection_schema["Detection event schema"]
end

subgraph group_respond["Incident response"]
  node_alerting["Alert generation<br/>[alerting.py]"]
  node_correlator["Incident correlator<br/>[correlator.py]"]
  node_incident_service["Incident workflow<br/>[service.py]"]
end

subgraph group_platform["API and storage"]
  node_ingest_api["Log upload API<br/>[logs.py]"]
  node_elastic[("Log search and index<br/>[elastic.py]")]
  node_mongo[("Application data store<br/>[mongo.py]")]
  node_detection_api["Detection API<br/>[detections.py]"]
  node_incident_api["Incident API<br/>[incidents.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_security["Authentication security<br/>[security.py]"]
  node_analytics_api["Analytics API<br/>[analytics.py]"]
  node_rules_api["Rule management API<br/>[rules.py]"]
end

subgraph group_frontend["Analyst interface"]
  node_frontend["SOC web interface<br/>[App.tsx]"]
  node_dashboard["Dashboard and analytics<br/>[DashboardPage.tsx]"]
  node_log_upload["Log upload screen<br/>[UploadLogsPage.tsx]"]
  node_threat_views["Threat and anomaly views"]
  node_incident_view["Incident management view"]
  node_login["Login screen<br/>[LoginPage.tsx]"]
end

node_user(("Analyst"))

node_user -->|"uploads logs"| node_ingest_api
node_ingest_api -.->|"submits batch"| node_pipeline
node_pipeline -->|"selects parser"| node_parsers
node_pipeline -->|"normalizes events"| node_normalizer
node_normalizer -->|"builds records"| node_log_schema
node_pipeline -->|"indexes logs"| node_elastic
node_pipeline -->|"checks duplicates"| node_mongo
node_pipeline -->|"dispatches ingested logs"| node_engine
node_engine -->|"runs rules"| node_rules
node_engine -->|"scores anomalies"| node_prediction
node_prediction -->|"extracts features"| node_features
node_prediction -->|"loads model"| node_registry
node_training -->|"extracts training features"| node_features
node_training -->|"registers model"| node_registry
node_engine -->|"emits detections"| node_detection_schema
node_engine -->|"persists detections"| node_mongo
node_engine -->|"generates alerts"| node_alerting
node_engine -->|"correlates detections"| node_correlator
node_correlator -->|"reads and updates incidents"| node_mongo
node_incident_api -->|"delegates workflow"| node_incident_service
node_incident_service -->|"updates incidents"| node_mongo
node_auth_api -->|"uses security functions"| node_security
node_auth_api -->|"reads and writes users"| node_mongo
node_analytics_api -->|"queries log analytics"| node_elastic
node_analytics_api -->|"queries incident analytics"| node_mongo
node_rules_api -.->|"persists rule settings"| node_mongo
node_user -.->|"uses SOC interface"| node_frontend

click node_ingest_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/logs.py"
click node_pipeline "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/ingestion/pipeline.py"
click node_parsers "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/tree/main/backend/app/ingestion/parsers"
click node_normalizer "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/ingestion/normalizer.py"
click node_log_schema "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/models/log_schema.py"
click node_elastic "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/db/elastic.py"
click node_mongo "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/db/mongo.py"
click node_engine "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/engine.py"
click node_rules "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/tree/main/backend/app/detection/rules"
click node_prediction "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/prediction_service.py"
click node_features "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/feature_extraction.py"
click node_registry "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/model_registry.py"
click node_training "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/training_service.py"
click node_detection_schema "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/models/detection_schema.py"
click node_detection_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/detections.py"
click node_alerting "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/alerting.py"
click node_correlator "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/incidents/correlator.py"
click node_incident_service "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/incidents/service.py"
click node_incident_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/incidents.py"
click node_auth_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/auth.py"
click node_security "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/core/security.py"
click node_analytics_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/analytics.py"
click node_rules_api "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/rules.py"
click node_frontend "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/dashboard/pages/DashboardPage.tsx"
click node_log_upload "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/logs/pages/UploadLogsPage.tsx"
click node_threat_views "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/detections/pages/ThreatDetectionPage.tsx"
click node_incident_view "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/incidents/pages/IncidentManagementPage.tsx"
click node_login "https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/auth/pages/LoginPage.tsx"

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_pipeline,node_parsers,node_normalizer,node_log_schema toneBlue
class node_engine,node_rules,node_prediction,node_features,node_registry,node_training,node_detection_schema toneAmber
class node_alerting,node_correlator,node_incident_service toneMint
class node_ingest_api,node_elastic,node_mongo,node_detection_api,node_incident_api,node_auth_api,node_security,node_analytics_api,node_rules_api toneRose
class node_frontend,node_dashboard,node_log_upload,node_threat_views,node_incident_view,node_login,node_user toneIndigo
```

## Components

### Log ingestion

- [Ingestion pipeline](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/ingestion/pipeline.py): `backend/app/ingestion/pipeline.py`
- [Source parsers](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/tree/main/backend/app/ingestion/parsers): `backend/app/ingestion/parsers`
- [Log normalizer](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/ingestion/normalizer.py): `backend/app/ingestion/normalizer.py`
- [Normalized log schema](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/models/log_schema.py): `backend/app/models/log_schema.py`

### Threat detection

- [Rule engine](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/engine.py): `backend/app/detection/engine.py`
- [Detection rules](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/tree/main/backend/app/detection/rules): `backend/app/detection/rules`
- [ML prediction](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/prediction_service.py): `backend/app/detection/ml/prediction_service.py`
- [ML features](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/feature_extraction.py): `backend/app/detection/ml/feature_extraction.py`
- [Model registry](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/model_registry.py): `backend/app/detection/ml/model_registry.py`
- [Model training](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/ml/training_service.py): `backend/app/detection/ml/training_service.py`
- [Detection event schema](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/models/detection_schema.py): `backend/app/models/detection_schema.py`

### Incident response

- [Alert generation](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/detection/alerting.py): `backend/app/detection/alerting.py`
- [Incident correlator](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/incidents/correlator.py): `backend/app/incidents/correlator.py`
- [Incident workflow](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/incidents/service.py): `backend/app/incidents/service.py`

### API and storage

- [Log upload API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/logs.py): `backend/app/api/v1/logs.py`
- [Log search and index](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/db/elastic.py): `backend/app/db/elastic.py`
- [Application data store](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/db/mongo.py): `backend/app/db/mongo.py`
- [Detection API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/detections.py): `backend/app/api/v1/detections.py`
- [Incident API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/incidents.py): `backend/app/api/v1/incidents.py`
- [Authentication API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/auth.py): `backend/app/api/v1/auth.py`
- [Authentication security](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Analytics API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/analytics.py): `backend/app/api/v1/analytics.py`
- [Rule management API](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/backend/app/api/v1/rules.py): `backend/app/api/v1/rules.py`

### Analyst interface

- [SOC web interface](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard and analytics](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/dashboard/pages/DashboardPage.tsx): `frontend/src/features/dashboard/pages/DashboardPage.tsx`
- [Log upload screen](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/logs/pages/UploadLogsPage.tsx): `frontend/src/features/logs/pages/UploadLogsPage.tsx`
- [Threat and anomaly views](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/detections/pages/ThreatDetectionPage.tsx): `frontend/src/features/detections/pages/ThreatDetectionPage.tsx`
- [Incident management view](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/incidents/pages/IncidentManagementPage.tsx): `frontend/src/features/incidents/pages/IncidentManagementPage.tsx`
- [Login screen](https://github.com/priyanshudahiya757/cyber-threat-detection-and-incident-response/blob/main/frontend/src/features/auth/pages/LoginPage.tsx): `frontend/src/features/auth/pages/LoginPage.tsx`

### Other components

- **Analyst**

## Connections

- Analyst → Log upload API: uploads logs
- Log upload API → Ingestion pipeline: submits batch
- Ingestion pipeline → Source parsers: selects parser (evidence: `backend/app/ingestion/pipeline.py`)
- Ingestion pipeline → Log normalizer: normalizes events (evidence: `backend/app/ingestion/pipeline.py`)
- Log normalizer → Normalized log schema: builds records (evidence: `backend/app/ingestion/normalizer.py`)
- Ingestion pipeline → Log search and index: indexes logs (evidence: `backend/app/ingestion/pipeline.py`)
- Ingestion pipeline → Application data store: checks duplicates (evidence: `backend/app/ingestion/pipeline.py`)
- Ingestion pipeline → Rule engine: dispatches ingested logs (evidence: `backend/app/main.py`)
- Rule engine → Detection rules: runs rules (evidence: `backend/app/detection/engine.py`)
- Rule engine → ML prediction: scores anomalies (evidence: `backend/app/detection/engine.py`)
- ML prediction → ML features: extracts features (evidence: `backend/app/detection/ml/prediction_service.py`)
- ML prediction → Model registry: loads model (evidence: `backend/app/detection/ml/prediction_service.py`)
- Model training → ML features: extracts training features (evidence: `backend/app/detection/ml/training_service.py`)
- Model training → Model registry: registers model (evidence: `backend/app/detection/ml/training_service.py`)
- Rule engine → Detection event schema: emits detections (evidence: `backend/app/detection/engine.py`)
- Rule engine → Application data store: persists detections (evidence: `backend/app/detection/engine.py`)
- Rule engine → Alert generation: generates alerts (evidence: `backend/app/detection/engine.py`)
- Rule engine → Incident correlator: correlates detections (evidence: `backend/app/detection/engine.py`)
- Incident correlator → Application data store: reads and updates incidents (evidence: `backend/app/incidents/correlator.py`)
- Incident API → Incident workflow: delegates workflow (evidence: `backend/app/api/v1/incidents.py`)
- Incident workflow → Application data store: updates incidents (evidence: `backend/app/incidents/service.py`)
- Authentication API → Authentication security: uses security functions (evidence: `backend/app/api/v1/auth.py`)
- Authentication API → Application data store: reads and writes users (evidence: `backend/app/api/v1/auth.py`)
- Analytics API → Log search and index: queries log analytics (evidence: `backend/app/api/v1/analytics.py`)
- Analytics API → Application data store: queries incident analytics (evidence: `backend/app/api/v1/analytics.py`)
- Rule management API → Application data store: persists rule settings
- Analyst → SOC web interface: uses SOC interface
