# shauryaverma1232/nlp-siem architecture

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

- Interactive diagram: https://gitdiagram.com/shauryaverma1232/nlp-siem
- Repository: https://github.com/shauryaverma1232/nlp-siem

## Overview

#### Purpose and deployment
NLP-SIEM is a conversational security-information system: users query security events in plain language, backend services search/analyze indexed logs, and return AI-assisted findings, visualizations, alerts, and exportable reports. Docker Compose is the primary deployment boundary in `docker-compose.yml`, with service images defined by `backend/Dockerfile` and `frontend/Dockerfile`.

#### Application entry points
- FastAPI backend application: `backend/main.py`; API route modules include `backend/api/ingest.py` and `backend/api/webhooks.py`.
- Streamlit dashboard: `frontend/streamlit_app.py`, the user-facing chat and visualization surface.
- Standalone ingestion utilities: `ingestion/ingest_logs.py`, `backend/generate_logs.py`, and `ingestion/generate_wsl_logs.py` support loading/generated event data outside the UI.

#### Ingestion and event preparation
`backend/ingestion/pipeline.py` is the ingestion orchestration layer. It selects format parsers—`backend/ingestion/parsers/syslog_parser.py`, `backend/ingestion/parsers/cef_parser.py`, and `backend/ingestion/parsers/json_parser.py`—then applies quality and shaping stages through `backend/ingestion/processors/validator.py`, `backend/ingestion/processors/normalizer.py`, and `backend/ingestion/processors/deduplicator.py`.

The resulting normalized event is the key boundary between heterogeneous source logs and the common SIEM/search model.

#### Enrichment, schemas, and state
Enrichment modules add investigative context before or alongside indexing: `backend/ingestion/enrichers/geoip_enricher.py`, `backend/ingestion/enrichers/dns_enricher.py`, and `backend/ingestion/enrichers/threat_intel.py`. Their configured behavior/sources are represented in `backend/config/enrichment.yaml` and `backend/config/sources.yaml`.

Cross-cutting event/context handling is concentrated in `backend/core/schema_mapper.py`, `backend/core/context_manager.py`, and `backend/core/cache_manager.py`, establishing schema translation, conversational/investigation context, and cached state boundaries.

#### SIEM search integration
The SIEM adapter layer isolates search-platform access from API and NLP logic. `backend/siem/connection_manager.py` and `backend/siem/elasticsearch_client.py` manage Elasticsearch connectivity; `backend/siem/query_builder.py` creates SIEM queries and `backend/siem/response_processor.py` converts responses into application-facing results. Connector implementations include `backend/siem/connectors/elastic_siem.py` and `backend/siem/connectors/wazuh.py`.

Elasticsearch 8.10 is the primary event datastore/search engine; Wazuh is an optional external SIEM integration.

#### Natural-language analysis flow
NLP orchestration is centered on `backend/nlp/nlp_processor.py`: user language is converted to structured search intent by `backend/nlp/query_builder.py`, executed through the SIEM layer, and summarized by `backend/nlp/response_generator.py`. Conversation-specific state is maintained separately in `backend/nlp/context_manager.py`.

Google Gemini 2.0 is the external AI service for interpretation and threat-oriented analysis, requiring the configured Google API key. The frontend submits queries to the backend rather than directly accessing Elasticsearch or Gemini.

#### Detection and reporting outputs
Post-search or post-ingestion detection logic resides in `backend/rules/correlation_engine.py` and `backend/rules/alert_generator.py`, driven by `backend/rules/rules.yaml`; this forms the alert/correlation boundary over normalized events.

Presentation and deliverables are produced by `backend/reports/visualizations.py`, `backend/reports/utils/report_generator.py`, and `backend/reports/utils/export_utils.py`, supporting dashboard charts plus report exports such as PDF, CSV, and JSON.

Main entry points: [`backend/nlp/nlp_processor.py`](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/nlp/nlp_processor.py) (NLP processor), [`backend/main.py`](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/main.py) (FastAPI backend), [`backend/core/schema_mapper.py`](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/core/schema_mapper.py) (Schema mapper), [`backend/siem/connection_manager.py`](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/siem/connection_manager.py) (SIEM adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Deployment"]
  node_compose{{"Docker Compose<br/>deployment<br/>[docker-compose.yml]"}}
  node_api["FastAPI backend<br/>API service<br/>[main.py]"]
end

subgraph group_ingestion["Event ingestion"]
  node_ingest_api["Ingest &amp; webhook routes<br/>API routes<br/>[ingest.py]"]
  node_ingestion_tools["Standalone ingestion tools<br/>CLI utilities<br/>[ingest_logs.py]"]
  node_pipeline["Ingestion pipeline<br/>orchestrator<br/>[pipeline.py]"]
  node_parsers["Format parsers<br/>parser layer<br/>[syslog_parser.py]"]
  node_processors["Event quality stages<br/>processing layer<br/>[validator.py]"]
  node_enrichment["Event enrichment<br/>enrichment layer<br/>[geoip_enricher.py]"]
  node_schema["Schema mapper<br/>event model boundary<br/>[schema_mapper.py]"]
end

subgraph group_search["SIEM search"]
  node_siem_adapter["SIEM adapter<br/>search integration"]
  node_elasticsearch[("Elasticsearch 8.10<br/>event datastore")]
  node_wazuh["Wazuh<br/>external SIEM"]
end

subgraph group_analysis["NLP &amp; detection"]
  node_nlp_processor["NLP processor<br/>query orchestrator<br/>[nlp_processor.py]"]
  node_gemini["Google Gemini 2.0<br/>external AI service"]
  node_context["Context &amp; cache state<br/>state management<br/>[context_manager.py]"]
  node_detection["Correlation &amp; alerts<br/>detection engine"]
end

subgraph group_experience["User experience"]
  node_dashboard["Streamlit dashboard<br/>web UI<br/>[streamlit_app.py]"]
  node_reports["Visualizations &amp; exports<br/>reporting<br/>[visualizations.py]"]
end

node_compose -->|"deploys"| node_api
node_compose -->|"deploys"| node_dashboard
node_dashboard -->|"submits queries"| node_api
node_api -->|"serves"| node_ingest_api
node_ingest_api -->|"ingests"| node_pipeline
node_ingestion_tools -->|"loads events"| node_pipeline
node_pipeline -->|"selects"| node_parsers
node_parsers -->|"parsed events"| node_processors
node_processors -->|"normalized events"| node_enrichment
node_enrichment -->|"enriched events"| node_schema
node_schema -->|"indexes common events"| node_elasticsearch
node_schema -->|"normalized events"| node_detection
node_api -->|"forwards user query"| node_nlp_processor
node_nlp_processor -->|"uses conversation state"| node_context
node_nlp_processor -->|"interprets and analyzes"| node_gemini
node_nlp_processor -->|"executes structured search"| node_siem_adapter
node_siem_adapter -->|"queries"| node_elasticsearch
node_siem_adapter -.->|"optional connector"| node_wazuh
node_nlp_processor -->|"findings for presentation"| node_reports
node_detection -->|"alerts and correlations"| node_reports
node_reports -->|"charts and exports"| node_dashboard

click node_compose "https://github.com/shauryaverma1232/nlp-siem/blob/main/docker-compose.yml"
click node_api "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/main.py"
click node_dashboard "https://github.com/shauryaverma1232/nlp-siem/blob/main/frontend/streamlit_app.py"
click node_ingest_api "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/api/ingest.py"
click node_ingestion_tools "https://github.com/shauryaverma1232/nlp-siem/blob/main/ingestion/ingest_logs.py"
click node_pipeline "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/pipeline.py"
click node_parsers "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/parsers/syslog_parser.py"
click node_processors "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/processors/validator.py"
click node_enrichment "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/enrichers/geoip_enricher.py"
click node_schema "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/core/schema_mapper.py"
click node_siem_adapter "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/siem/connection_manager.py"
click node_nlp_processor "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/nlp/nlp_processor.py"
click node_context "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/core/context_manager.py"
click node_detection "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/rules/correlation_engine.py"
click node_reports "https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/reports/visualizations.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_compose,node_api toneBlue
class node_ingest_api,node_ingestion_tools,node_pipeline,node_parsers,node_processors,node_enrichment,node_schema toneAmber
class node_siem_adapter,node_elasticsearch,node_wazuh toneMint
class node_nlp_processor,node_gemini,node_context,node_detection toneRose
class node_dashboard,node_reports toneIndigo
```

## Components

### Deployment

- [Docker Compose](https://github.com/shauryaverma1232/nlp-siem/blob/main/docker-compose.yml): deployment · Primary service deployment boundary. · `docker-compose.yml`
- [FastAPI backend](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/main.py): API service · `backend/main.py`

### Event ingestion

- [Ingest & webhook routes](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/api/ingest.py): API routes · `backend/api/ingest.py`
- [Standalone ingestion tools](https://github.com/shauryaverma1232/nlp-siem/blob/main/ingestion/ingest_logs.py): CLI utilities · `ingestion/ingest_logs.py`
- [Ingestion pipeline](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/pipeline.py): orchestrator · `backend/ingestion/pipeline.py`
- [Format parsers](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/parsers/syslog_parser.py): parser layer · Syslog, CEF, and JSON inputs. · `backend/ingestion/parsers/syslog_parser.py`
- [Event quality stages](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/processors/validator.py): processing layer · Validation, normalization, and deduplication. · `backend/ingestion/processors/validator.py`
- [Event enrichment](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/ingestion/enrichers/geoip_enricher.py): enrichment layer · GeoIP, DNS, and threat-intelligence context. · `backend/ingestion/enrichers/geoip_enricher.py`
- [Schema mapper](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/core/schema_mapper.py): event model boundary · Maps normalized events to the common SIEM model. · `backend/core/schema_mapper.py`

### SIEM search

- [SIEM adapter](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/siem/connection_manager.py): search integration · Connection, query construction, and response conversion. · `backend/siem/connection_manager.py`
- **Elasticsearch 8.10**: event datastore · Primary indexed event search engine.
- **Wazuh**: external SIEM · Optional SIEM connector target.

### NLP & detection

- [NLP processor](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/nlp/nlp_processor.py): query orchestrator · Converts language to intent, executes search, and summarizes results. · `backend/nlp/nlp_processor.py`
- **Google Gemini 2.0**: external AI service · Threat-oriented interpretation and analysis.
- [Context & cache state](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/core/context_manager.py): state management · Investigation, conversation, and cached state boundary. · `backend/core/context_manager.py`
- [Correlation & alerts](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/rules/correlation_engine.py): detection engine · Rules-driven detection over normalized events. · `backend/rules/correlation_engine.py`

### User experience

- [Streamlit dashboard](https://github.com/shauryaverma1232/nlp-siem/blob/main/frontend/streamlit_app.py): web UI · Chat, findings, and visualization surface. · `frontend/streamlit_app.py`
- [Visualizations & exports](https://github.com/shauryaverma1232/nlp-siem/blob/main/backend/reports/visualizations.py): reporting · Charts plus PDF, CSV, and JSON deliverables. · `backend/reports/visualizations.py`

## Connections

- Docker Compose → FastAPI backend: deploys
- Docker Compose → Streamlit dashboard: deploys
- Streamlit dashboard → FastAPI backend: submits queries
- FastAPI backend → Ingest & webhook routes: serves
- Ingest & webhook routes → Ingestion pipeline: ingests
- Standalone ingestion tools → Ingestion pipeline: loads events
- Ingestion pipeline → Format parsers: selects
- Format parsers → Event quality stages: parsed events
- Event quality stages → Event enrichment: normalized events
- Event enrichment → Schema mapper: enriched events
- Schema mapper → Elasticsearch 8.10: indexes common events
- Schema mapper → Correlation & alerts: normalized events
- FastAPI backend → NLP processor: forwards user query
- NLP processor → Context & cache state: uses conversation state
- NLP processor → Google Gemini 2.0: interprets and analyzes
- NLP processor → SIEM adapter: executes structured search
- SIEM adapter → Elasticsearch 8.10: queries
- SIEM adapter → Wazuh: optional connector
- NLP processor → Visualizations & exports: findings for presentation
- Correlation & alerts → Visualizations & exports: alerts and correlations
- Visualizations & exports → Streamlit dashboard: charts and exports
