# harsh-singh-2023/tamper-evident-digital-twin architecture

> Architecture diagram of the GitHub repository harsh-singh-2023/tamper-evident-digital-twin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsh-singh-2023/tamper-evident-digital-twin
- Repository: https://github.com/harsh-singh-2023/tamper-evident-digital-twin

## Overview

This repository implements tamper-evident synchronization for industrial digital-twin state, with a live integrity dashboard, attack simulations, and a benchmarking suite. The main workflow accepts telemetry, hashes and stores its payload off-chain, then anchors a record on Hyperledger Fabric; the dashboard separately compares incoming payload hashes with the ledger and displays events. Sampled source supports the sync, ledger, and dashboard flows. Attack and benchmark capabilities are also documented, but their broader implementations were not inspected; those branches are shown at directory level.

Main entry points: [`attack-injection/attack.js`](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/attack-injection/attack.js) (Attack injection), [`sync-service/index.js`](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/index.js) (Sync API), [`dashboard/backend/server.js`](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/backend/server.js) (Stream verifier), [`chaincode/chaincode.go`](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/chaincode/chaincode.go) (State contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sync["State synchronization"]
  node_sync_api["Sync API<br/>[index.js]"]
  node_fabric_helper["Fabric connection<br/>[fabric.js]"]
  node_ipfs[("IPFS storage")]
end

subgraph group_ledger["Ledger"]
  node_chaincode["State contract<br/>[chaincode.go]"]
  node_fabric_ledger[("Fabric ledger")]
end

subgraph group_monitor["Live monitoring"]
  node_stream_api["Stream verifier<br/>[server.js]"]
  node_dashboard_fabric["Dashboard Fabric access<br/>[fabric.js]"]
  node_websocket["Live event feed<br/>[server.js]"]
  node_dashboard_ui["Security dashboard<br/>[App.jsx]"]
end

subgraph group_resilience["Resilience evaluation"]
  node_attack_suite["Attack injection<br/>[attack.js]"]
  node_benchmark_suite["Benchmark suite"]
  node_per_update["Per-update policy<br/>[per-update.js]"]
  node_batched["Batched policy<br/>[batched.js]"]
  node_deviation["Deviation policy"]
end

node_sensor(("Telemetry source"))
node_attack_actor(("Test operator"))

node_sensor -->|"submits telemetry"| node_sync_api
node_sync_api -->|"stores payload"| node_ipfs
node_sync_api -->|"initializes connection"| node_fabric_helper
node_sync_api -->|"submits record"| node_chaincode
node_chaincode -->|"writes and reads"| node_fabric_ledger
node_sensor -->|"posts telemetry"| node_stream_api
node_stream_api -->|"initializes connection"| node_dashboard_fabric
node_stream_api -->|"queries latest record"| node_chaincode
node_stream_api -->|"emits event"| node_websocket
node_websocket -->|"sends state updates"| node_dashboard_ui
node_attack_actor -->|"runs attacks"| node_attack_suite
node_attack_suite -->|"replays payload"| node_sync_api
node_attack_suite -->|"connects directly"| node_fabric_helper
node_attack_suite -->|"submits rogue record"| node_chaincode
node_attack_suite -.->|"tests spoofing"| node_stream_api
node_benchmark_suite -.->|"measures policy"| node_per_update
node_benchmark_suite -.->|"measures policy"| node_batched
node_benchmark_suite -.->|"measures policy"| node_deviation

click node_sync_api "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/index.js"
click node_fabric_helper "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/fabric.js"
click node_chaincode "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/chaincode/chaincode.go"
click node_stream_api "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/backend/server.js"
click node_dashboard_fabric "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/fabric.js"
click node_websocket "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/backend/server.js"
click node_dashboard_ui "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/frontend/src/App.jsx"
click node_attack_suite "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/attack-injection/attack.js"
click node_benchmark_suite "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/tree/main/benchmark"
click node_per_update "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/per-update.js"
click node_batched "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/batched.js"
click node_deviation "https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/deviation-triggered.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_sync_api,node_fabric_helper,node_ipfs toneBlue
class node_chaincode,node_fabric_ledger toneAmber
class node_stream_api,node_dashboard_fabric,node_websocket,node_dashboard_ui toneMint
class node_attack_suite,node_benchmark_suite,node_per_update,node_batched,node_deviation toneRose
class node_sensor,node_attack_actor toneIndigo
```

## Components

### State synchronization

- [Sync API](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/index.js): `sync-service/index.js`
- [Fabric connection](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/fabric.js): `sync-service/fabric.js`
- **IPFS storage**

### Ledger

- [State contract](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/chaincode/chaincode.go): `chaincode/chaincode.go`
- **Fabric ledger**

### Live monitoring

- [Stream verifier](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/backend/server.js): `dashboard/backend/server.js`
- [Dashboard Fabric access](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/sync-service/fabric.js): `sync-service/fabric.js`
- [Live event feed](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/backend/server.js): `dashboard/backend/server.js`
- [Security dashboard](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/dashboard/frontend/src/App.jsx): `dashboard/frontend/src/App.jsx`

### Resilience evaluation

- [Attack injection](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/attack-injection/attack.js): `attack-injection/attack.js`
- [Benchmark suite](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/tree/main/benchmark): `benchmark`
- [Per-update policy](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/per-update.js): `benchmark/workload/per-update.js`
- [Batched policy](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/batched.js): `benchmark/workload/batched.js`
- [Deviation policy](https://github.com/harsh-singh-2023/tamper-evident-digital-twin/blob/main/benchmark/workload/deviation-triggered.js): `benchmark/workload/deviation-triggered.js`

### Other components

- **Telemetry source**
- **Test operator**

## Connections

- Telemetry source → Sync API: submits telemetry (evidence: `sync-service/index.js`)
- Sync API → IPFS storage: stores payload (evidence: `sync-service/index.js`)
- Sync API → Fabric connection: initializes connection (evidence: `sync-service/index.js`)
- Sync API → State contract: submits record (evidence: `sync-service/index.js`)
- State contract → Fabric ledger: writes and reads (evidence: `chaincode/chaincode.go`)
- Telemetry source → Stream verifier: posts telemetry (evidence: `dashboard/backend/server.js`)
- Stream verifier → Dashboard Fabric access: initializes connection (evidence: `dashboard/backend/server.js`)
- Stream verifier → State contract: queries latest record (evidence: `dashboard/backend/server.js`)
- Stream verifier → Live event feed: emits event (evidence: `dashboard/backend/server.js`)
- Live event feed → Security dashboard: sends state updates (evidence: `dashboard/frontend/src/App.jsx`)
- Test operator → Attack injection: runs attacks (evidence: `attack-injection/attack.js`)
- Attack injection → Sync API: replays payload (evidence: `attack-injection/attack.js`)
- Attack injection → Fabric connection: connects directly (evidence: `attack-injection/attack.js`)
- Attack injection → State contract: submits rogue record (evidence: `attack-injection/attack.js`)
- Attack injection → Stream verifier: tests spoofing
- Benchmark suite → Per-update policy: measures policy (evidence: `README.md`)
- Benchmark suite → Batched policy: measures policy (evidence: `README.md`)
- Benchmark suite → Deviation policy: measures policy (evidence: `README.md`)
