# honeynet/dicomhawk architecture

> Architecture diagram of the GitHub repository honeynet/dicomhawk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/honeynet/dicomhawk
- Repository: https://github.com/honeynet/dicomhawk

## Overview

##### Main Components
- DICOM Server (dicom_server): This is a Python-based service that accepts DICOM network operations (on port 104), manages dicom file storage, performs integrity checks, injects honeytokens (canary PDFs and honeyURLs) into the DICOM datasets, and periodically updates files via TCIA.
- API Service (API directory): A Node.js–based web service that exposes REST endpoints for searching, retrieving, and uploading DICOM data. It also serves as an interface for attackers to interact with the honeypot.
- Flask Logging Server (flask_logging_server): A Python/Flask application that centralizes log collection and offers a simplified UI (accessible on port 5000) to view logs and monitor events.
- Monitoring Stack (monitoring_stack): Deployed via Docker Compose, this includes Elastic Stack components – Elasticsearch for indexing alerts, Logstash for gathering logs (from, for example, Redis or other logging infrastructures), and Kibana for visualization (accessed on port 5601). This forms your central security monitoring hub.
- Data Storage & Update Subsystem: The dicom_server directory also contains a storage area for the DICOM files, including subdirectories where TCIA-downloaded files, licensing files, and the canary PDF are stored. This component is also part of the dynamic data rotation mechanism.
- External and Ancillary Services:
– Redis: Used as a temporary log staging area which Logstash pulls from.
– Threat Intelligence APIs: External services (such as AbuseIPDB, IPQualityScore, VirusTotal) are integrated for checking the reputation of interacting IPs.
– Docker & Docker Compose: Orchestrates the various containerized services (DICOM server, API, logging server, monitoring stack, etc.).
– TCIA Service: Acts as the source for periodic updates of DICOM files (the integration details are configured in config.py).

##### Relationships and Interactions
- Attackers (or external clients) interact through:
– The DICOM interface (using DCMTK tools or DICOM client software, connecting to port 104).
– The Web API (through HTTP requests on port 3000).
– The logging interface (via the simplified Flask logging UI on port 5000) if they view the system.
- The DICOM Server:
– Receives, processes, and stores DICOM messages.
– Injects honeytokens into the data.
– Updates its file repository periodically by fetching files from TCIA.
– Logs all activities for further analysis.
- The API Service:
– Exposes endpoints to perform searches and downloads; it uses similar logging mechanisms.
– Interacts with the threat intelligence APIs in order to check IP reputations.
- Both DICOM Server and API Service send logs (or are configured to store key events) into a centralized logging pipeline:
– Logs can be pushed into a Redis instance and then collected by Logstash.
– The Monitoring Stack (Elasticsearch/Kibana) receives processed logs for visualization.
- Docker Compose is used to coordinate all containerised services. It also injects environment variables and configuration options (found in config.py) into each container.
- There are configuration management touchpoints (via config.py and environment variables) influencing all services.

##### Architectural Patterns and Design Principles
- Microservices-based architecture: Each independent service (DICOM server, API, logging server, monitoring stack) runs in its own container and communicates via network protocols.
- Container orchestration: Using Docker Compose to tie together multi-service interactions.
- Centralized logging/monitoring: All services push events into a Redis-Logstash-Elasticsearch-Kibana (ELK) pipeline for real-time monitoring and forensics.
- Modular design: Separation of concerns is evident (DICOM operations, API interactions, logging, threat intelligence, data rotation) ensuring easy scalability and independent updates.

##### Relevant Technologies/Frameworks
- Python with Flask (for logging server and portions of DICOM handling via pynetdicom/pydicom).
- Node.js (for the API service).
- Docker/Docker Compose (containerization and orchestration).
- Redis (as a data staging area).
- Elastic Stack (Logstash, Elasticsearch, Kibana) for monitoring.
- External APIs for threat intelligence.

##### Detailed Architectural Elements
- Every major component and integration point.
- Component is clearly labeled with its technology (e.g., “Python/DICOM Server”, “Node.js API”).
- Use annotations to refer to architectural patterns (e.g., “centralized logging via ELK”, “container orchestration using Docker Compose”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    E["External Clients/Attackers"]:::client

    DC["Docker Compose Orchestration"]:::orchestration
    CM["Configuration Management"]:::orchestration

    DS["Python DICOM Server (Port 104)"]:::container
    DSF["File Storage & Update Subsystem"]:::container
    TC["TCIA Service/External File Update"]:::external
    TID["Threat Intelligence (DICOM)"]:::external

    FS["API Service (Node.js, Port 3000)"]:::container
    TIA["Threat Intelligence (API)"]:::external

    FL["Flask Logging Server (Port 5000)"]:::container
    R["Redis (Log Staging)"]:::external
    MS["Monitoring Stack (ELK: Kibana 5601, Elasticsearch 9200/9300)"]:::container

    E -->|"DICOMoperations"| DS
    E -->|"RESTAPICalls"| FS

    DS -->|"ManagesStorage"| DSF
    DS -->|"FetchesFiles"| TC
    DS -->|"QueriesThreatAPI"| TID

    FS -->|"QueriesThreatAPI"| TIA

    DS -->|"ForwardsLogs"| FL
    FS -->|"ForwardsLogs"| FL

    DS -->|"ForwardsLogs"| R
    FS -->|"ForwardsLogs"| R

    FL -->|"AggregatesLogs"| MS
    R -->|"LogProcessing"| MS

    DC -->|"Orchestrates"| DS
    DC -->|"Orchestrates"| FS
    DC -->|"Orchestrates"| FL
    DC -->|"Orchestrates"| MS

    CM -->|"Configures"| DS
    CM -->|"Configures"| FS
    CM -->|"Configures"| FL
    CM -->|"Configures"| MS

    click DS "https://github.com/honeynet/dicomhawk/tree/v2.0/dicom_server"
    click DSF "https://github.com/honeynet/dicomhawk/tree/v2.0/dicom_server/storage"
    click TC "https://github.com/honeynet/dicomhawk/blob/v2.0/dicom_server/custom_units/tcia_management.py"
    click TID "https://github.com/honeynet/dicomhawk/blob/v2.0/dicom_server/core/threat_intelligence_handler.py"
    click FS "https://github.com/honeynet/dicomhawk/tree/v2.0/API"
    click TIA "https://github.com/honeynet/dicomhawk/blob/v2.0/API/theatIntelligence.js"
    click FL "https://github.com/honeynet/dicomhawk/tree/v2.0/flask_logging_server"
    click R "https://github.com/honeynet/dicomhawk/blob/v2.0/API/dbConnectors/redisConnector.js"
    click MS "https://github.com/honeynet/dicomhawk/tree/v2.0/monitoring_stack"

classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
classDef container fill:#90EE90,stroke:#000,stroke-width:1px;
classDef external fill:#FFCCCB,stroke:#000,stroke-width:1px;
classDef orchestration fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
