# siju-ani/pjt-1 architecture

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

- Interactive diagram: https://gitdiagram.com/siju-ani/pjt-1
- Repository: https://github.com/siju-ani/pjt-1

## Overview

This repository combines an ESP32 offline custody ledger and receiver handoff with a Node.js telemetry gateway that authenticates signed serial packets and anchors verified events on Ethereum. A Python client exercises the device’s challenge-and-handoff API. The README is only a title; the map follows the sampled source, and unsampled contract and UI details are limited to their supported roles.

Main entry points: [`ESP32.c`](https://github.com/siju-ani/pjt-1/blob/main/ESP32.c) (ESP32 Ledger), [`blockchain/blockchainService.js`](https://github.com/siju-ani/pjt-1/blob/main/blockchain/blockchainService.js) (Custody Service), [`Server.py`](https://github.com/siju-ani/pjt-1/blob/main/Server.py) (Handoff Simulation), [`gateway.js`](https://github.com/siju-ani/pjt-1/blob/main/gateway.js) (Serial Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device Ledger"]
  node_device_ledger["ESP32 Ledger<br/>[ESP32.c]"]
  node_device_crypto["Hardware Signing<br/>[ESP32.c]"]
  node_flash_ledger[("Flash Ledger<br/>[ESP32.c]")]
end

subgraph group_gateway["Telemetry Gateway"]
  node_serial_gateway["Serial Gateway<br/>[gateway.js]"]
  node_signature_check["Signature Verification<br/>[gateway.js]"]
  node_dashboard["Dashboard UI<br/>[index.html]"]
  node_legacy_server["Legacy Server<br/>[server.js]"]
end

subgraph group_chain["Blockchain Anchoring"]
  node_custody_service["Custody Service"]
  node_custody_contract["Custody Contract<br/>[CustodyLedger.sol]"]
  node_contract_abi["Contract ABI"]
end

subgraph group_client["Handoff Client"]
  node_handoff_client["Handoff Simulation<br/>[Server.py]"]
end

node_receiver(("Receiver"))
node_ethereum[("Ethereum RPC")]

node_receiver -->|"initiates handoff"| node_handoff_client
node_handoff_client -->|"requests challenge"| node_device_ledger
node_handoff_client -->|"posts handoff"| node_device_ledger
node_device_ledger -->|"verifies and signs"| node_device_crypto
node_device_ledger -->|"persists entries"| node_flash_ledger
node_device_ledger -->|"returns receipt"| node_handoff_client
node_serial_gateway -->|"verifies packets"| node_signature_check
node_serial_gateway -->|"emits socket events"| node_dashboard
node_serial_gateway -->|"records verified events"| node_custody_service
node_custody_service -->|"loads ABI"| node_contract_abi
node_custody_service -->|"calls custody method"| node_custody_contract
node_custody_service -->|"submits transaction"| node_ethereum
node_legacy_server -.->|"imports service"| node_custody_service

click node_device_ledger "https://github.com/siju-ani/pjt-1/blob/main/ESP32.c"
click node_device_crypto "https://github.com/siju-ani/pjt-1/blob/main/ESP32.c"
click node_flash_ledger "https://github.com/siju-ani/pjt-1/blob/main/ESP32.c"
click node_handoff_client "https://github.com/siju-ani/pjt-1/blob/main/Server.py"
click node_serial_gateway "https://github.com/siju-ani/pjt-1/blob/main/gateway.js"
click node_signature_check "https://github.com/siju-ani/pjt-1/blob/main/gateway.js"
click node_dashboard "https://github.com/siju-ani/pjt-1/blob/main/public/index.html"
click node_custody_service "https://github.com/siju-ani/pjt-1/blob/main/blockchain/blockchainService.js"
click node_custody_contract "https://github.com/siju-ani/pjt-1/blob/main/blockChainNetwork/contracts/CustodyLedger.sol"
click node_legacy_server "https://github.com/siju-ani/pjt-1/blob/main/server.js"
click node_contract_abi "https://github.com/siju-ani/pjt-1/blob/main/blockchain/CustodyLedgerABI.json"

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_device_ledger,node_device_crypto,node_flash_ledger toneBlue
class node_serial_gateway,node_signature_check,node_dashboard,node_legacy_server,node_ethereum toneAmber
class node_custody_service,node_custody_contract,node_contract_abi toneMint
class node_handoff_client toneRose
class node_receiver toneIndigo
```

## Components

### Device Ledger

- [ESP32 Ledger](https://github.com/siju-ani/pjt-1/blob/main/ESP32.c): `ESP32.c`
- [Hardware Signing](https://github.com/siju-ani/pjt-1/blob/main/ESP32.c): `ESP32.c`
- [Flash Ledger](https://github.com/siju-ani/pjt-1/blob/main/ESP32.c): `ESP32.c`

### Telemetry Gateway

- [Serial Gateway](https://github.com/siju-ani/pjt-1/blob/main/gateway.js): `gateway.js`
- [Signature Verification](https://github.com/siju-ani/pjt-1/blob/main/gateway.js): `gateway.js`
- [Dashboard UI](https://github.com/siju-ani/pjt-1/blob/main/public/index.html): `public/index.html`
- [Legacy Server](https://github.com/siju-ani/pjt-1/blob/main/server.js): `server.js`

### Blockchain Anchoring

- [Custody Service](https://github.com/siju-ani/pjt-1/blob/main/blockchain/blockchainService.js): `blockchain/blockchainService.js`
- [Custody Contract](https://github.com/siju-ani/pjt-1/blob/main/blockChainNetwork/contracts/CustodyLedger.sol): `blockChainNetwork/contracts/CustodyLedger.sol`
- [Contract ABI](https://github.com/siju-ani/pjt-1/blob/main/blockchain/CustodyLedgerABI.json): `blockchain/CustodyLedgerABI.json`

### Handoff Client

- [Handoff Simulation](https://github.com/siju-ani/pjt-1/blob/main/Server.py): `Server.py`

### Other components

- **Receiver**
- **Ethereum RPC**

## Connections

- Receiver → Handoff Simulation: initiates handoff (evidence: `Server.py`)
- Handoff Simulation → ESP32 Ledger: requests challenge (evidence: `Server.py`)
- Handoff Simulation → ESP32 Ledger: posts handoff (evidence: `Server.py`)
- ESP32 Ledger → Hardware Signing: verifies and signs (evidence: `ESP32.c`)
- ESP32 Ledger → Flash Ledger: persists entries (evidence: `ESP32.c`)
- ESP32 Ledger → Handoff Simulation: returns receipt (evidence: `ESP32.c`)
- Serial Gateway → Signature Verification: verifies packets (evidence: `gateway.js`)
- Serial Gateway → Dashboard UI: emits socket events (evidence: `gateway.js`)
- Serial Gateway → Custody Service: records verified events (evidence: `gateway.js`)
- Custody Service → Contract ABI: loads ABI (evidence: `blockchain/blockchainService.js`)
- Custody Service → Custody Contract: calls custody method (evidence: `blockchain/blockchainService.js`)
- Custody Service → Ethereum RPC: submits transaction (evidence: `blockchain/blockchainService.js`)
- Legacy Server → Custody Service: imports service (evidence: `server.js`)
