How shauryaverma1232/nlp-siem works
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: nlp_processor.py NLP processor · main.py FastAPI backend · schema_mapper.py Schema mapper · connection_manager.py SIEM adapter
Components 18
Deployment
- Docker Compose · Primary service deployment boundary.
docker-compose.yml - FastAPI backend
backend/main.py
Event ingestion
- Ingest & webhook routes
backend/api/ingest.py - Standalone ingestion tools
ingestion/ingest_logs.py - Ingestion pipeline
backend/ingestion/pipeline.py - Format parsers · Syslog, CEF, and JSON inputs.
backend/ingestion/parsers/syslog_parser.py - Event quality stages · Validation, normalization, and deduplication.
backend/ingestion/processors/validator.py - Event enrichment · GeoIP, DNS, and threat-intelligence context.
backend/ingestion/enrichers/geoip_enricher.py - Schema mapper · Maps normalized events to the common SIEM model.
backend/core/schema_mapper.py
SIEM search
- SIEM adapter · Connection, query construction, and response conversion.
backend/siem/connection_manager.py - Elasticsearch 8.10 · Primary indexed event search engine.
- Wazuh · Optional SIEM connector target.
NLP & detection
- NLP processor · Converts language to intent, executes search, and summarizes results.
backend/nlp/nlp_processor.py - Google Gemini 2.0 · Threat-oriented interpretation and analysis.
- Context & cache state · Investigation, conversation, and cached state boundary.
backend/core/context_manager.py - Correlation & alerts · Rules-driven detection over normalized events.
backend/rules/correlation_engine.py
User experience
- Streamlit dashboard · Chat, findings, and visualization surface.
frontend/streamlit_app.py - Visualizations & exports · Charts plus PDF, CSV, and JSON deliverables.
backend/reports/visualizations.py
Connections 21
- 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