# xore/apiary architecture

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

- Interactive diagram: https://gitdiagram.com/xore/apiary
- Repository: https://github.com/xore/apiary

## Overview

APIARY is a multi-service honeypot and automated malware-analysis stack. Its main workflow exposes decoy services through a VPS and WireGuard, collects activity for correlation and anomaly detection, and presents results in an investigation dashboard. The README documents the major workers, dashboard tiers, and deployment topology; source excerpts confirm selected Ghidra, LLM, and ML internals. Several operational links are documented only at a high level, so those edges cite the README rather than implying inspected implementation details.

Main entry points: [`arcane/home/honeypot-elk`](https://github.com/xore/apiary/tree/main/arcane/home/honeypot-elk) (Elasticsearch and ELK), [`ml-worker/worker.py`](https://github.com/xore/apiary/blob/main/ml-worker/worker.py) (Anomaly scoring), [`arcane/home/honeypot-http/http-honeypot/main.go`](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-http/http-honeypot/main.go) (Honeypot sensors), [`vps/portbridge/main.go`](https://github.com/xore/apiary/blob/main/vps/portbridge/main.go) (VPS ingress)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Exposure and ingress"]
  node_vps["VPS ingress<br/>[main.go]"]
  node_portbridge["Raw port bridge<br/>[main.go]"]
end

subgraph group_sensors["Deception sensors"]
  node_sensors["Honeypot sensors<br/>[main.go]"]
  node_canary["Canarytokens<br/>[main.go]"]
end

subgraph group_analysis["Analysis and workers"]
  node_correlation["Correlation workers<br/>[worker.rs]"]
  node_mlworker["Anomaly scoring<br/>[worker.py]"]
  node_features["Session features"]
  node_isolation["IsolationForest and HBOS"]
  node_lstm["LSTM autoencoder"]
  node_ghidraworker["Ghidra analysis worker<br/>[ghidra-worker.py]"]
  node_ghidraservice["Ghidra analysis service<br/>[server.py]"]
  node_llmworker["LLM analysis worker<br/>[worker.py]"]
  node_llmcontracts["LLM output contracts<br/>[contracts.py]"]
  node_vault["Knowledge vault worker<br/>[worker.py]"]
  node_huginn["Flow fingerprinting<br/>[main.rs]"]
  node_p0f["Passive OS fingerprinting<br/>[fp_tcp.c]"]
end

subgraph group_dashboard["Investigation dashboard"]
  node_backend["Dashboard API<br/>[main.rs]"]
  node_frontend["Investigation UI<br/>[index.tsx]"]
end

subgraph group_storage["Data and knowledge"]
  node_elasticsearch[("Elasticsearch and ELK")]
end

node_attacker(("Internet attacker"))

node_attacker -->|"connects via HTTP"| node_vps
node_attacker -->|"sends raw traffic"| node_portbridge
node_vps -->|"tunnels traffic"| node_sensors
node_portbridge -->|"tunnels traffic"| node_sensors
node_sensors -.->|"records activity"| node_elasticsearch
node_canary -.->|"emits alerts"| node_elasticsearch
node_elasticsearch -->|"provides events"| node_correlation
node_elasticsearch -->|"provides events"| node_mlworker
node_mlworker -->|"computes features"| node_features
node_mlworker -->|"scores events"| node_isolation
node_mlworker -->|"scores events"| node_lstm
node_mlworker -->|"writes anomalies"| node_elasticsearch
node_elasticsearch -.->|"queues samples"| node_ghidraworker
node_ghidraworker -->|"submits analysis"| node_ghidraservice
node_elasticsearch -.->|"provides sessions"| node_llmworker
node_llmworker -->|"validates output"| node_llmcontracts
node_elasticsearch -->|"provides analysis"| node_vault
node_elasticsearch -.->|"serves investigation data"| node_backend
node_backend -->|"serves dashboard API"| node_frontend
node_huginn -.->|"emits fingerprints"| node_elasticsearch
node_p0f -.->|"reports fingerprints"| node_elasticsearch

click node_vps "https://github.com/xore/apiary/blob/main/vps/portbridge/main.go"
click node_portbridge "https://github.com/xore/apiary/blob/main/portbridge/main.go"
click node_sensors "https://github.com/xore/apiary/blob/main/arcane/home/honeypot-http/http-honeypot/main.go"
click node_canary "https://github.com/xore/apiary/blob/main/arcane/home/honeypot-canarytokens/canarytokens-adapter/main.go"
click node_elasticsearch "https://github.com/xore/apiary/tree/main/arcane/home/honeypot-elk"
click node_correlation "https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/backend-service/src/worker.rs"
click node_mlworker "https://github.com/xore/apiary/blob/main/ml-worker/worker.py"
click node_features "https://github.com/xore/apiary/blob/main/ml-worker/models/session_features.py"
click node_isolation "https://github.com/xore/apiary/blob/main/ml-worker/models/isolation_forest.py"
click node_lstm "https://github.com/xore/apiary/blob/main/ml-worker/models/lstm_autoencoder.py"
click node_ghidraworker "https://github.com/xore/apiary/blob/main/analysis/ghidra/worker/ghidra-worker.py"
click node_ghidraservice "https://github.com/xore/apiary/blob/main/analysis/ghidra/service/server.py"
click node_llmworker "https://github.com/xore/apiary/blob/main/llm-worker/worker.py"
click node_llmcontracts "https://github.com/xore/apiary/blob/main/llm-worker/contracts.py"
click node_vault "https://github.com/xore/apiary/blob/main/vault-worker/worker.py"
click node_backend "https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/backend-service/src/main.rs"
click node_frontend "https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/frontend-next/src/routes/index.tsx"
click node_huginn "https://github.com/xore/apiary/blob/main/vps/huginn-sidecar/src/main.rs"
click node_p0f "https://github.com/xore/apiary/blob/main/vps/p0f/fp_tcp.c"

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_vps,node_portbridge toneBlue
class node_sensors,node_canary toneAmber
class node_correlation,node_mlworker,node_features,node_isolation,node_lstm,node_ghidraworker,node_ghidraservice,node_llmworker,node_llmcontracts,node_vault,node_huginn,node_p0f toneMint
class node_backend,node_frontend toneRose
class node_elasticsearch,node_attacker toneIndigo
```

## Components

### Exposure and ingress

- [VPS ingress](https://github.com/xore/apiary/blob/main/vps/portbridge/main.go): `vps/portbridge/main.go`
- [Raw port bridge](https://github.com/xore/apiary/blob/main/portbridge/main.go): `portbridge/main.go`

### Deception sensors

- [Honeypot sensors](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-http/http-honeypot/main.go): `arcane/home/honeypot-http/http-honeypot/main.go`
- [Canarytokens](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-canarytokens/canarytokens-adapter/main.go): `arcane/home/honeypot-canarytokens/canarytokens-adapter/main.go`

### Analysis and workers

- [Correlation workers](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/backend-service/src/worker.rs): `arcane/home/honeypot-dashboard/backend-service/src/worker.rs`
- [Anomaly scoring](https://github.com/xore/apiary/blob/main/ml-worker/worker.py): `ml-worker/worker.py`
- [Session features](https://github.com/xore/apiary/blob/main/ml-worker/models/session_features.py): `ml-worker/models/session_features.py`
- [IsolationForest and HBOS](https://github.com/xore/apiary/blob/main/ml-worker/models/isolation_forest.py): `ml-worker/models/isolation_forest.py`
- [LSTM autoencoder](https://github.com/xore/apiary/blob/main/ml-worker/models/lstm_autoencoder.py): `ml-worker/models/lstm_autoencoder.py`
- [Ghidra analysis worker](https://github.com/xore/apiary/blob/main/analysis/ghidra/worker/ghidra-worker.py): `analysis/ghidra/worker/ghidra-worker.py`
- [Ghidra analysis service](https://github.com/xore/apiary/blob/main/analysis/ghidra/service/server.py): `analysis/ghidra/service/server.py`
- [LLM analysis worker](https://github.com/xore/apiary/blob/main/llm-worker/worker.py): `llm-worker/worker.py`
- [LLM output contracts](https://github.com/xore/apiary/blob/main/llm-worker/contracts.py): `llm-worker/contracts.py`
- [Knowledge vault worker](https://github.com/xore/apiary/blob/main/vault-worker/worker.py): `vault-worker/worker.py`
- [Flow fingerprinting](https://github.com/xore/apiary/blob/main/vps/huginn-sidecar/src/main.rs): `vps/huginn-sidecar/src/main.rs`
- [Passive OS fingerprinting](https://github.com/xore/apiary/blob/main/vps/p0f/fp_tcp.c): `vps/p0f/fp_tcp.c`

### Investigation dashboard

- [Dashboard API](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/backend-service/src/main.rs): `arcane/home/honeypot-dashboard/backend-service/src/main.rs`
- [Investigation UI](https://github.com/xore/apiary/blob/main/arcane/home/honeypot-dashboard/frontend-next/src/routes/index.tsx): `arcane/home/honeypot-dashboard/frontend-next/src/routes/index.tsx`

### Data and knowledge

- [Elasticsearch and ELK](https://github.com/xore/apiary/tree/main/arcane/home/honeypot-elk): `arcane/home/honeypot-elk`

### Other components

- **Internet attacker**

## Connections

- Internet attacker → VPS ingress: connects via HTTP
- Internet attacker → Raw port bridge: sends raw traffic
- VPS ingress → Honeypot sensors: tunnels traffic
- Raw port bridge → Honeypot sensors: tunnels traffic
- Honeypot sensors → Elasticsearch and ELK: records activity
- Canarytokens → Elasticsearch and ELK: emits alerts
- Elasticsearch and ELK → Correlation workers: provides events
- Elasticsearch and ELK → Anomaly scoring: provides events (evidence: `ml-worker/worker.py`)
- Anomaly scoring → Session features: computes features (evidence: `ml-worker/worker.py`)
- Anomaly scoring → IsolationForest and HBOS: scores events (evidence: `ml-worker/worker.py`)
- Anomaly scoring → LSTM autoencoder: scores events (evidence: `ml-worker/worker.py`)
- Anomaly scoring → Elasticsearch and ELK: writes anomalies (evidence: `ml-worker/worker.py`)
- Elasticsearch and ELK → Ghidra analysis worker: queues samples
- Ghidra analysis worker → Ghidra analysis service: submits analysis (evidence: `analysis/ghidra/worker/ghidra-worker.py`)
- Elasticsearch and ELK → LLM analysis worker: provides sessions
- LLM analysis worker → LLM output contracts: validates output (evidence: `llm-worker/worker.py`)
- Elasticsearch and ELK → Knowledge vault worker: provides analysis (evidence: `vault-worker/worker.py`)
- Elasticsearch and ELK → Dashboard API: serves investigation data
- Dashboard API → Investigation UI: serves dashboard API
- Flow fingerprinting → Elasticsearch and ELK: emits fingerprints
- Passive OS fingerprinting → Elasticsearch and ELK: reports fingerprints
