# aadilvarshani/reaperwatch architecture

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

- Interactive diagram: https://gitdiagram.com/aadilvarshani/reaperwatch
- Repository: https://github.com/aadilvarshani/reaperwatch

## Overview

ReaperWatch is a Windows endpoint telemetry collector and analyst console. A process-start event is captured through ETW, enriched and normalized by the agent, then written to local JSONL and optionally pushed to the console. The console ingests events from JSONL or authenticated HTTP, stores them, evaluates EQL detection rules, and serves APIs to the dashboard for overview, alerts, and hunting. README-documented dashboard capabilities are included; some frontend wiring and unsampled subsystem details are represented only where documentation supports them.

Main entry points: [`backend/api/server.js`](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/api/server.js) (Console API), [`agent/collectors/etw_consumer.cpp`](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/etw_consumer.cpp) (ETW Consumer), [`backend/detection/matcher.js`](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/matcher.js) (Detection Matcher), [`backend/ingestor/ingest.js`](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/ingestor/ingest.js) (Event Ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Windows Agent"]
  node_agent_main["Agent Startup<br/>[main.cpp]"]
  node_etw_consumer["ETW Consumer<br/>[etw_consumer.cpp]"]
  node_enrichment["Process Enrichment"]
  node_event_model["Process Event Model<br/>[process_event.h]"]
  node_serialization["JSON Serialization<br/>[event_json.cpp]"]
  node_config["Network Config<br/>[config.cpp]"]
  node_local_sink["JSONL Event Sink<br/>[event_sink.cpp]"]
  node_http_sender["HTTP Sender<br/>[http_sender.cpp]"]
end

subgraph group_console["Console Backend"]
  node_api["Console API<br/>[server.js]"]
  node_file_tailer["JSONL Tailer<br/>[tail.js]"]
  node_ingest["Event Ingestion<br/>[ingest.js]"]
  node_database[("SQLite Store<br/>[db.js]")]
  node_matcher["Detection Matcher<br/>[matcher.js]"]
  node_rules["Declarative Rules<br/>[rules.js]"]
  node_mitre["MITRE Metadata<br/>[mitre.js]"]
  node_queries["API Queries<br/>[queries.js]"]
  node_ingest_key["Ingest Key<br/>[ingestKey.js]"]
end

subgraph group_dashboard["Analyst Dashboard"]
  node_dashboard_app["Dashboard Views<br/>[app.js]"]
  node_dashboard_data["Dashboard Data<br/>[data.js]"]
  node_eql["EQL Interpreter<br/>[eql.js]"]
end

node_operator(("Administrator"))
node_etw{{"Kernel ETW"}}
node_jsonl["Events JSONL"]
node_analyst(("Analyst"))

node_operator -->|"starts elevated"| node_agent_main
node_agent_main -->|"loads config"| node_config
node_agent_main -->|"starts collection"| node_etw_consumer
node_etw_consumer -->|"consumes events"| node_etw
node_etw_consumer -->|"builds events"| node_enrichment
node_enrichment -->|"populates"| node_event_model
node_etw_consumer -->|"serializes events"| node_serialization
node_etw_consumer -->|"appends events"| node_local_sink
node_local_sink -->|"writes JSONL"| node_jsonl
node_etw_consumer -->|"sends events"| node_http_sender
node_config -->|"configures destination"| node_http_sender
node_http_sender -->|"POSTs events"| node_api
node_api -->|"loads key"| node_ingest_key
node_api -->|"opens store"| node_database
node_api -->|"starts tailer"| node_file_tailer
node_file_tailer -->|"reads appended data"| node_jsonl
node_file_tailer -->|"passes events"| node_ingest
node_api -->|"ingests HTTP events"| node_ingest
node_ingest -->|"stores events and alerts"| node_database
node_ingest -->|"matches event"| node_matcher
node_matcher -->|"evaluates rules"| node_rules
node_matcher -->|"runs queries"| node_eql
node_matcher -->|"adds technique metadata"| node_mitre
node_api -->|"serves query results"| node_queries
node_queries -->|"reads records"| node_database
node_analyst -->|"uses console"| node_dashboard_app
node_dashboard_app -.->|"renders data"| node_dashboard_data
node_dashboard_data -->|"fetches console data"| node_api
node_dashboard_app -->|"runs Hunt queries"| node_eql

click node_agent_main "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/main.cpp"
click node_etw_consumer "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/etw_consumer.cpp"
click node_enrichment "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/process_monitor.cpp"
click node_event_model "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/process_event.h"
click node_serialization "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/event_json.cpp"
click node_config "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/config.cpp"
click node_local_sink "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/event_sink.cpp"
click node_http_sender "https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/http_sender.cpp"
click node_api "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/api/server.js"
click node_file_tailer "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/ingestor/tail.js"
click node_ingest "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/ingestor/ingest.js"
click node_database "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/storage/db.js"
click node_matcher "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/matcher.js"
click node_rules "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/rules.js"
click node_mitre "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/mitre.js"
click node_queries "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/api/queries.js"
click node_ingest_key "https://github.com/aadilvarshani/reaperwatch/blob/main/backend/storage/ingestKey.js"
click node_dashboard_app "https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/app.js"
click node_dashboard_data "https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/data.js"
click node_eql "https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/eql.js"

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_agent_main,node_etw_consumer,node_enrichment,node_event_model,node_serialization,node_config,node_local_sink,node_http_sender toneBlue
class node_api,node_file_tailer,node_ingest,node_database,node_matcher,node_rules,node_mitre,node_queries,node_ingest_key toneAmber
class node_dashboard_app,node_dashboard_data,node_eql toneMint
class node_operator,node_etw,node_jsonl,node_analyst toneIndigo
```

## Components

### Windows Agent

- [Agent Startup](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/main.cpp): `agent/main.cpp`
- [ETW Consumer](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/etw_consumer.cpp): `agent/collectors/etw_consumer.cpp`
- [Process Enrichment](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/process_monitor.cpp): `agent/collectors/process_monitor.cpp`
- [Process Event Model](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/process_event.h): `agent/collectors/process_event.h`
- [JSON Serialization](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/collectors/event_json.cpp): `agent/collectors/event_json.cpp`
- [Network Config](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/config.cpp): `agent/transport/config.cpp`
- [JSONL Event Sink](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/event_sink.cpp): `agent/transport/event_sink.cpp`
- [HTTP Sender](https://github.com/aadilvarshani/reaperwatch/blob/main/agent/transport/http_sender.cpp): `agent/transport/http_sender.cpp`

### Console Backend

- [Console API](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/api/server.js): `backend/api/server.js`
- [JSONL Tailer](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/ingestor/tail.js): `backend/ingestor/tail.js`
- [Event Ingestion](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/ingestor/ingest.js): `backend/ingestor/ingest.js`
- [SQLite Store](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/storage/db.js): `backend/storage/db.js`
- [Detection Matcher](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/matcher.js): `backend/detection/matcher.js`
- [Declarative Rules](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/rules.js): `backend/detection/rules.js`
- [MITRE Metadata](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/detection/mitre.js): `backend/detection/mitre.js`
- [API Queries](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/api/queries.js): `backend/api/queries.js`
- [Ingest Key](https://github.com/aadilvarshani/reaperwatch/blob/main/backend/storage/ingestKey.js): `backend/storage/ingestKey.js`

### Analyst Dashboard

- [Dashboard Views](https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/app.js): `dashboard/js/app.js`
- [Dashboard Data](https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/data.js): `dashboard/js/data.js`
- [EQL Interpreter](https://github.com/aadilvarshani/reaperwatch/blob/main/dashboard/js/eql.js): `dashboard/js/eql.js`

### Other components

- **Administrator**
- **Kernel ETW**
- **Events JSONL**
- **Analyst**

## Connections

- Administrator → Agent Startup: starts elevated (evidence: `agent/main.cpp`)
- Agent Startup → Network Config: loads config (evidence: `agent/main.cpp`)
- Agent Startup → ETW Consumer: starts collection (evidence: `agent/main.cpp`)
- ETW Consumer → Kernel ETW: consumes events (evidence: `agent/collectors/etw_consumer.cpp`)
- ETW Consumer → Process Enrichment: builds events (evidence: `agent/collectors/etw_consumer.cpp`)
- Process Enrichment → Process Event Model: populates (evidence: `agent/collectors/process_monitor.cpp`)
- ETW Consumer → JSON Serialization: serializes events (evidence: `agent/collectors/etw_consumer.cpp`)
- ETW Consumer → JSONL Event Sink: appends events (evidence: `agent/collectors/etw_consumer.cpp`)
- JSONL Event Sink → Events JSONL: writes JSONL (evidence: `agent/transport/event_sink.cpp`)
- ETW Consumer → HTTP Sender: sends events (evidence: `agent/collectors/etw_consumer.cpp`)
- Network Config → HTTP Sender: configures destination (evidence: `README.md`)
- HTTP Sender → Console API: POSTs events (evidence: `README.md`)
- Console API → Ingest Key: loads key (evidence: `backend/api/server.js`)
- Console API → SQLite Store: opens store (evidence: `backend/api/server.js`)
- Console API → JSONL Tailer: starts tailer (evidence: `backend/api/server.js`)
- JSONL Tailer → Events JSONL: reads appended data (evidence: `backend/ingestor/tail.js`)
- JSONL Tailer → Event Ingestion: passes events (evidence: `backend/ingestor/tail.js`)
- Console API → Event Ingestion: ingests HTTP events (evidence: `backend/api/server.js`)
- Event Ingestion → SQLite Store: stores events and alerts (evidence: `backend/ingestor/ingest.js`)
- Event Ingestion → Detection Matcher: matches event (evidence: `backend/ingestor/ingest.js`)
- Detection Matcher → Declarative Rules: evaluates rules (evidence: `backend/detection/matcher.js`)
- Detection Matcher → EQL Interpreter: runs queries (evidence: `backend/detection/matcher.js`)
- Detection Matcher → MITRE Metadata: adds technique metadata (evidence: `backend/detection/matcher.js`)
- Console API → API Queries: serves query results (evidence: `backend/api/server.js`)
- API Queries → SQLite Store: reads records (evidence: `backend/api/queries.js`)
- Analyst → Dashboard Views: uses console (evidence: `README.md`)
- Dashboard Views → Dashboard Data: renders data
- Dashboard Data → Console API: fetches console data (evidence: `README.md`)
- Dashboard Views → EQL Interpreter: runs Hunt queries (evidence: `README.md`)
