# ihyonoo/locuvera architecture

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

- Interactive diagram: https://gitdiagram.com/ihyonoo/locuvera
- Repository: https://github.com/ihyonoo/locuvera

## Overview

Locuvera tracks hospital equipment through BLE-based indoor positioning, records NFC-authenticated checkout and return events, and anchors completed usage records to Besu for integrity checks. Staff and administrators use a web application for live equipment views, usage history, NFC management, and verification. The README documents the principal flows; sampled source confirms selected backend, frontend, and simulator connections. Some routes and integrations are represented from README statements rather than inspected implementation excerpts.

Main entry points: [`backend/server.py`](https://github.com/ihyonoo/locuvera/blob/main/backend/server.py) (API and workflows), [`frontend/src/app/routes.tsx`](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/routes.tsx) (Web routes), [`backend/usage_history_service.py`](https://github.com/ihyonoo/locuvera/blob/main/backend/usage_history_service.py) (Usage history service), [`backend/rtls_utils.py`](https://github.com/ihyonoo/locuvera/blob/main/backend/rtls_utils.py) (RTLS state and cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Devices and simulation"]
  node_bletag["BLE equipment tags"]
  node_reader["BLE reader<br/>[send_to_server.py]"]
  node_sim["Hospital simulator<br/>[simulator.py]"]
  node_world["Simulated world<br/>[world.py]"]
  node_topology["Hospital topology<br/>[zones.py]"]
  node_api_client["Simulation API client<br/>[api_client.py]"]
  node_personalise["Tag personalisation<br/>[personalise.py]"]
  node_crypto["NTAG session crypto<br/>[crypto.py]"]
end

subgraph group_backend["Backend services"]
  node_server["API and workflows<br/>[server.py]"]
  node_location["Location decisions"]
  node_rtls["RTLS state and cache<br/>[rtls_utils.py]"]
  node_nfc["NFC tap validation<br/>[nfc_tap.py]"]
  node_ntag["NTAG cryptography<br/>[ntag424.py]"]
  node_history["Usage history service"]
  node_pg[("PostgreSQL")]
  node_redis[("Redis location cache")]
end

subgraph group_web["Web application"]
  node_app["Web routes<br/>[routes.tsx]"]
  node_equipment["Live equipment view"]
  node_device["Device status<br/>[DeviceStatus.tsx]"]
  node_nfcpage["NFC equipment actions<br/>[NfcEquipment.tsx]"]
  node_mapping["NFC tag mapping<br/>[NfcMapping.tsx]"]
  node_integrity["Integrity verification"]
  node_profile["Account and history<br/>[MyPage.tsx]"]
  node_auth["Session and auth<br/>[auth.ts]"]
end

subgraph group_chain["Usage integrity"]
  node_chain_scripts["Besu record scripts"]
  node_verify_script["Chain verification script"]
  node_besu[("Besu network")]
end

subgraph group_eval["Evaluation tools"]
  node_eval_rpc["Evaluation RPC proxy<br/>[rpc_proxy.py]"]
  node_evaluator["Evaluation workflows<br/>[integrity.py]"]
end

node_staff(("Clinical staff"))
node_admin(("Administrators"))

node_bletag -->|"broadcasts"| node_reader
node_reader -->|"posts RSSI"| node_server
node_server -.->|"decides location"| node_location
node_server -->|"updates location"| node_rtls
node_rtls -->|"stores source"| node_pg
node_rtls -->|"updates cache"| node_redis
node_equipment -->|"polls live data"| node_server
node_device -.->|"requests status"| node_server
node_staff -->|"tags equipment"| node_nfcpage
node_nfcpage -->|"requests NFC action"| node_server
node_server -.->|"validates tap"| node_nfc
node_nfc -.->|"checks CMAC"| node_ntag
node_server -->|"records checkout/return"| node_history
node_history -->|"reads and writes"| node_pg
node_history -->|"invokes record script"| node_chain_scripts
node_chain_scripts -->|"anchors records"| node_besu
node_history -->|"invokes verification"| node_verify_script
node_verify_script -->|"reads chain records"| node_besu
node_admin -->|"reviews integrity"| node_integrity
node_integrity -->|"requests verification"| node_server
node_staff -->|"finds equipment"| node_equipment
node_admin -->|"manages mappings"| node_mapping
node_mapping -->|"manages NFC bindings"| node_server
node_staff -.->|"views history"| node_profile
node_app -->|"routes to"| node_equipment
node_app -->|"routes to"| node_integrity
node_app -->|"routes to"| node_mapping
node_app -->|"routes to"| node_nfcpage
node_app -->|"routes to"| node_profile
node_auth -.->|"guards sessions"| node_app
node_sim -->|"advances state"| node_world
node_world -->|"uses zone model"| node_topology
node_sim -.->|"sends actions"| node_api_client
node_api_client -.->|"calls backend"| node_server
node_personalise -->|"uses crypto"| node_crypto
node_personalise -->|"registers tag UID"| node_server
node_evaluator -->|"uses RPC proxy"| node_eval_rpc

click node_bletag "https://github.com/ihyonoo/locuvera/blob/main/rtls/rtls_tag/ibeacon_broadcast.py"
click node_reader "https://github.com/ihyonoo/locuvera/blob/main/rtls/rtls_reader/send_to_server.py"
click node_sim "https://github.com/ihyonoo/locuvera/blob/main/simulation/simulator.py"
click node_world "https://github.com/ihyonoo/locuvera/blob/main/simulation/world.py"
click node_topology "https://github.com/ihyonoo/locuvera/blob/main/simulation/topology/zones.py"
click node_api_client "https://github.com/ihyonoo/locuvera/blob/main/simulation/api_client.py"
click node_server "https://github.com/ihyonoo/locuvera/blob/main/backend/server.py"
click node_location "https://github.com/ihyonoo/locuvera/blob/main/backend/location_decision.py"
click node_rtls "https://github.com/ihyonoo/locuvera/blob/main/backend/rtls_utils.py"
click node_nfc "https://github.com/ihyonoo/locuvera/blob/main/backend/nfc_tap.py"
click node_ntag "https://github.com/ihyonoo/locuvera/blob/main/backend/ntag424.py"
click node_history "https://github.com/ihyonoo/locuvera/blob/main/backend/usage_history_service.py"
click node_app "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/routes.tsx"
click node_equipment "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/EquipmentSearch.tsx"
click node_device "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/DeviceStatus.tsx"
click node_nfcpage "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/NfcEquipment.tsx"
click node_mapping "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/NfcMapping.tsx"
click node_integrity "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/IntegrityVerification.tsx"
click node_profile "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/MyPage.tsx"
click node_auth "https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/lib/auth.ts"
click node_chain_scripts "https://github.com/ihyonoo/locuvera/blob/main/blockchain/besu/scripts/record-usage-record.mjs"
click node_verify_script "https://github.com/ihyonoo/locuvera/blob/main/blockchain/besu/scripts/verify-usage-records.mjs"
click node_personalise "https://github.com/ihyonoo/locuvera/blob/main/tools/ntag/personalise.py"
click node_crypto "https://github.com/ihyonoo/locuvera/blob/main/tools/ntag/crypto.py"
click node_eval_rpc "https://github.com/ihyonoo/locuvera/blob/main/eval/rpc_proxy.py"
click node_evaluator "https://github.com/ihyonoo/locuvera/blob/main/eval/integrity.py"

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_bletag,node_reader,node_sim,node_world,node_topology,node_api_client,node_personalise,node_crypto toneBlue
class node_server,node_location,node_rtls,node_nfc,node_ntag,node_history,node_pg,node_redis toneAmber
class node_app,node_equipment,node_device,node_nfcpage,node_mapping,node_integrity,node_profile,node_auth toneMint
class node_chain_scripts,node_verify_script,node_besu toneRose
class node_eval_rpc,node_evaluator,node_staff,node_admin toneIndigo
```

## Components

### Devices and simulation

- [BLE equipment tags](https://github.com/ihyonoo/locuvera/blob/main/rtls/rtls_tag/ibeacon_broadcast.py): `rtls/rtls_tag/ibeacon_broadcast.py`
- [BLE reader](https://github.com/ihyonoo/locuvera/blob/main/rtls/rtls_reader/send_to_server.py): `rtls/rtls_reader/send_to_server.py`
- [Hospital simulator](https://github.com/ihyonoo/locuvera/blob/main/simulation/simulator.py): `simulation/simulator.py`
- [Simulated world](https://github.com/ihyonoo/locuvera/blob/main/simulation/world.py): `simulation/world.py`
- [Hospital topology](https://github.com/ihyonoo/locuvera/blob/main/simulation/topology/zones.py): `simulation/topology/zones.py`
- [Simulation API client](https://github.com/ihyonoo/locuvera/blob/main/simulation/api_client.py): `simulation/api_client.py`
- [Tag personalisation](https://github.com/ihyonoo/locuvera/blob/main/tools/ntag/personalise.py): `tools/ntag/personalise.py`
- [NTAG session crypto](https://github.com/ihyonoo/locuvera/blob/main/tools/ntag/crypto.py): `tools/ntag/crypto.py`

### Backend services

- [API and workflows](https://github.com/ihyonoo/locuvera/blob/main/backend/server.py): `backend/server.py`
- [Location decisions](https://github.com/ihyonoo/locuvera/blob/main/backend/location_decision.py): `backend/location_decision.py`
- [RTLS state and cache](https://github.com/ihyonoo/locuvera/blob/main/backend/rtls_utils.py): `backend/rtls_utils.py`
- [NFC tap validation](https://github.com/ihyonoo/locuvera/blob/main/backend/nfc_tap.py): `backend/nfc_tap.py`
- [NTAG cryptography](https://github.com/ihyonoo/locuvera/blob/main/backend/ntag424.py): `backend/ntag424.py`
- [Usage history service](https://github.com/ihyonoo/locuvera/blob/main/backend/usage_history_service.py): `backend/usage_history_service.py`
- **PostgreSQL**
- **Redis location cache**

### Web application

- [Web routes](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/routes.tsx): `frontend/src/app/routes.tsx`
- [Live equipment view](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/EquipmentSearch.tsx): `frontend/src/app/pages/EquipmentSearch.tsx`
- [Device status](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/DeviceStatus.tsx): `frontend/src/app/pages/DeviceStatus.tsx`
- [NFC equipment actions](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/NfcEquipment.tsx): `frontend/src/app/pages/NfcEquipment.tsx`
- [NFC tag mapping](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/NfcMapping.tsx): `frontend/src/app/pages/NfcMapping.tsx`
- [Integrity verification](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/IntegrityVerification.tsx): `frontend/src/app/pages/IntegrityVerification.tsx`
- [Account and history](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/pages/MyPage.tsx): `frontend/src/app/pages/MyPage.tsx`
- [Session and auth](https://github.com/ihyonoo/locuvera/blob/main/frontend/src/app/lib/auth.ts): `frontend/src/app/lib/auth.ts`

### Usage integrity

- [Besu record scripts](https://github.com/ihyonoo/locuvera/blob/main/blockchain/besu/scripts/record-usage-record.mjs): `blockchain/besu/scripts/record-usage-record.mjs`
- [Chain verification script](https://github.com/ihyonoo/locuvera/blob/main/blockchain/besu/scripts/verify-usage-records.mjs): `blockchain/besu/scripts/verify-usage-records.mjs`
- **Besu network**

### Evaluation tools

- [Evaluation RPC proxy](https://github.com/ihyonoo/locuvera/blob/main/eval/rpc_proxy.py): `eval/rpc_proxy.py`
- [Evaluation workflows](https://github.com/ihyonoo/locuvera/blob/main/eval/integrity.py): `eval/integrity.py`

### Other components

- **Clinical staff**
- **Administrators**

## Connections

- BLE equipment tags → BLE reader: broadcasts
- BLE reader → API and workflows: posts RSSI
- API and workflows → Location decisions: decides location (evidence: `backend/server.py`)
- API and workflows → RTLS state and cache: updates location (evidence: `backend/server.py`)
- RTLS state and cache → PostgreSQL: stores source
- RTLS state and cache → Redis location cache: updates cache
- Live equipment view → API and workflows: polls live data
- Device status → API and workflows: requests status
- Clinical staff → NFC equipment actions: tags equipment
- NFC equipment actions → API and workflows: requests NFC action
- API and workflows → NFC tap validation: validates tap (evidence: `backend/server.py`)
- NFC tap validation → NTAG cryptography: checks CMAC
- API and workflows → Usage history service: records checkout/return (evidence: `backend/server.py`)
- Usage history service → PostgreSQL: reads and writes
- Usage history service → Besu record scripts: invokes record script (evidence: `backend/usage_history_service.py`)
- Besu record scripts → Besu network: anchors records
- Usage history service → Chain verification script: invokes verification (evidence: `backend/usage_history_service.py`)
- Chain verification script → Besu network: reads chain records
- Administrators → Integrity verification: reviews integrity
- Integrity verification → API and workflows: requests verification
- Clinical staff → Live equipment view: finds equipment
- Administrators → NFC tag mapping: manages mappings
- NFC tag mapping → API and workflows: manages NFC bindings
- Clinical staff → Account and history: views history
- Web routes → Live equipment view: routes to (evidence: `frontend/src/app/routes.tsx`)
- Web routes → Integrity verification: routes to (evidence: `frontend/src/app/routes.tsx`)
- Web routes → NFC tag mapping: routes to (evidence: `frontend/src/app/routes.tsx`)
- Web routes → NFC equipment actions: routes to (evidence: `frontend/src/app/routes.tsx`)
- Web routes → Account and history: routes to (evidence: `frontend/src/app/routes.tsx`)
- Session and auth → Web routes: guards sessions
- Hospital simulator → Simulated world: advances state (evidence: `simulation/world.py`)
- Simulated world → Hospital topology: uses zone model (evidence: `simulation/world.py`)
- Hospital simulator → Simulation API client: sends actions
- Simulation API client → API and workflows: calls backend
- Tag personalisation → NTAG session crypto: uses crypto (evidence: `tools/ntag/personalise.py`)
- Tag personalisation → API and workflows: registers tag UID
- Evaluation workflows → Evaluation RPC proxy: uses RPC proxy (evidence: `eval/integrity.py`)
