# bharathrajm-2005/trustistics architecture

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

- Interactive diagram: https://gitdiagram.com/bharathrajm-2005/trustistics
- Repository: https://github.com/bharathrajm-2005/trustistics

## Overview

Trustistics is a blockchain-backed cold-chain provenance application. Suppliers create shipments and upload records; shipment events and IoT temperature readings are recorded for operational tracking, risk monitoring, and audit, while customers can verify a shipment publicly. The frontend serves role-based workflows and calls a FastAPI backend; MongoDB stores operational records and Ethereum anchors hashes. The README describes the product capabilities, but several routes and pages were not sampled, so their internal service links are left out or marked unverified.

Main entry points: [`frontend/src/App.tsx`](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/App.tsx) (App routing), [`backend/services/temperature_service.py`](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/temperature_service.py) (Temperature monitoring), [`backend/services/blockchain_service.py`](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/blockchain_service.py) (Blockchain anchoring), [`backend/services/verification_service.py`](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/verification_service.py) (Shipment verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Role-based frontend"]
  node_supplier["Supplier workflows<br/>[CreateShipment.tsx]"]
  node_document_ui["Document upload"]
  node_tracking_ui["Live tracking<br/>[LiveTracking.tsx]"]
  node_audit_ui["Audit and alerts<br/>[AnalyticsAudit.tsx]"]
  node_verification_ui["Public verification<br/>[PublicVerify.tsx]"]
  node_role_ui["Role dashboards<br/>[DriverManifest.tsx]"]
  node_auth["Role authentication<br/>[AuthContext.tsx]"]
  node_api_client["Shipment API client<br/>[shipmentApi.ts]"]
  node_app_routes["App routing<br/>[App.tsx]"]
end

subgraph group_api["API and domain services"]
  node_api_entry["FastAPI application<br/>[main.py]"]
  node_api_routes["Domain API routes"]
  node_shipment_service["Shipment lifecycle"]
end

subgraph group_integrity["Provenance and monitoring"]
  node_documents["Document provenance"]
  node_handoffs["Custody handoffs<br/>[handoff_service.py]"]
  node_temperature["Temperature monitoring"]
  node_verification["Shipment verification"]
  node_risk["Risk assessment<br/>[risk_service.py]"]
  node_weather["Dispatch weather<br/>[weather_service.py]"]
  node_blockchain_service["Blockchain anchoring"]
end

subgraph group_external["External infrastructure"]
  node_database[("MongoDB collections<br/>[database.py]")]
  node_ethereum{{"Ethereum network"}}
  node_iot["IoT sensor readings<br/>[iot_simulator.py]"]
end

node_customer(("Customer / auditor"))
node_operator(("Supply-chain users"))

node_operator -->|"uses"| node_app_routes
node_app_routes -->|"provides auth"| node_auth
node_app_routes -->|"routes to"| node_supplier
node_app_routes -->|"routes to"| node_document_ui
node_app_routes -->|"routes to"| node_tracking_ui
node_app_routes -->|"routes to"| node_audit_ui
node_app_routes -->|"routes to"| node_verification_ui
node_app_routes -->|"routes to"| node_role_ui
node_supplier -->|"calls"| node_api_client
node_tracking_ui -->|"calls"| node_api_client
node_audit_ui -->|"calls"| node_api_client
node_api_client -.->|"HTTP requests"| node_api_entry
node_api_entry -->|"registers routes"| node_api_routes
node_api_routes -->|"calls"| node_shipment_service
node_api_routes -->|"calls"| node_temperature
node_api_routes -->|"calls"| node_weather
node_shipment_service -->|"writes shipments"| node_database
node_shipment_service -->|"anchors events"| node_blockchain_service
node_temperature -->|"stores readings"| node_database
node_temperature -->|"anchors hashes"| node_blockchain_service
node_temperature -.->|"updates risk"| node_risk
node_documents -->|"stores records"| node_database
node_documents -->|"anchors hashes"| node_blockchain_service
node_handoffs -->|"stores handoffs"| node_database
node_handoffs -->|"anchors events"| node_blockchain_service
node_verification -->|"checks records"| node_documents
node_verification -->|"checks custody"| node_handoffs
node_verification -->|"checks readings"| node_temperature
node_verification -->|"checks risk"| node_risk
node_blockchain_service -->|"reads and writes"| node_ethereum
node_iot -.->|"submits readings"| node_temperature
node_customer -->|"audits shipment"| node_verification_ui

click node_supplier "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/CreateShipment.tsx"
click node_document_ui "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/UploadDocuments.tsx"
click node_tracking_ui "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/LiveTracking.tsx"
click node_audit_ui "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/AnalyticsAudit.tsx"
click node_verification_ui "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/PublicVerify.tsx"
click node_role_ui "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/roles/DriverManifest.tsx"
click node_auth "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/context/AuthContext.tsx"
click node_api_client "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/api/shipmentApi.ts"
click node_app_routes "https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/App.tsx"
click node_api_entry "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/main.py"
click node_api_routes "https://github.com/bharathrajm-2005/trustistics/tree/main/backend/routes"
click node_shipment_service "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/shipment_service.py"
click node_documents "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/document_service.py"
click node_handoffs "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/handoff_service.py"
click node_temperature "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/temperature_service.py"
click node_verification "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/verification_service.py"
click node_risk "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/risk_service.py"
click node_weather "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/weather_service.py"
click node_blockchain_service "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/blockchain_service.py"
click node_database "https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/database.py"
click node_iot "https://github.com/bharathrajm-2005/trustistics/blob/main/iot_simulator.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_supplier,node_document_ui,node_tracking_ui,node_audit_ui,node_verification_ui,node_role_ui,node_auth,node_api_client,node_app_routes,node_operator toneBlue
class node_api_entry,node_api_routes,node_shipment_service toneAmber
class node_documents,node_handoffs,node_temperature,node_verification,node_risk,node_weather,node_blockchain_service toneMint
class node_database,node_ethereum,node_iot toneRose
class node_customer toneIndigo
```

## Components

### Role-based frontend

- [Supplier workflows](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/CreateShipment.tsx): `frontend/src/pages/CreateShipment.tsx`
- [Document upload](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/UploadDocuments.tsx): `frontend/src/pages/UploadDocuments.tsx`
- [Live tracking](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/LiveTracking.tsx): `frontend/src/pages/LiveTracking.tsx`
- [Audit and alerts](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/AnalyticsAudit.tsx): `frontend/src/pages/AnalyticsAudit.tsx`
- [Public verification](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/PublicVerify.tsx): `frontend/src/pages/PublicVerify.tsx`
- [Role dashboards](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/pages/roles/DriverManifest.tsx): `frontend/src/pages/roles/DriverManifest.tsx`
- [Role authentication](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Shipment API client](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/api/shipmentApi.ts): `frontend/src/api/shipmentApi.ts`
- [App routing](https://github.com/bharathrajm-2005/trustistics/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### API and domain services

- [FastAPI application](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/main.py): `backend/main.py`
- [Domain API routes](https://github.com/bharathrajm-2005/trustistics/tree/main/backend/routes): `backend/routes`
- [Shipment lifecycle](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/shipment_service.py): `backend/services/shipment_service.py`

### Provenance and monitoring

- [Document provenance](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/document_service.py): `backend/services/document_service.py`
- [Custody handoffs](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/handoff_service.py): `backend/services/handoff_service.py`
- [Temperature monitoring](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/temperature_service.py): `backend/services/temperature_service.py`
- [Shipment verification](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/verification_service.py): `backend/services/verification_service.py`
- [Risk assessment](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/risk_service.py): `backend/services/risk_service.py`
- [Dispatch weather](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/weather_service.py): `backend/services/weather_service.py`
- [Blockchain anchoring](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/blockchain_service.py): `backend/services/blockchain_service.py`

### External infrastructure

- [MongoDB collections](https://github.com/bharathrajm-2005/trustistics/blob/main/backend/services/database.py): `backend/services/database.py`
- **Ethereum network**
- [IoT sensor readings](https://github.com/bharathrajm-2005/trustistics/blob/main/iot_simulator.py): `iot_simulator.py`

### Other components

- **Customer / auditor**
- **Supply-chain users**

## Connections

- Supply-chain users → App routing: uses (evidence: `frontend/src/App.tsx`)
- App routing → Role authentication: provides auth (evidence: `frontend/src/App.tsx`)
- App routing → Supplier workflows: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Document upload: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Live tracking: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Audit and alerts: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Public verification: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Role dashboards: routes to (evidence: `frontend/src/App.tsx`)
- Supplier workflows → Shipment API client: calls (evidence: `frontend/src/pages/CreateShipment.tsx`)
- Live tracking → Shipment API client: calls (evidence: `frontend/src/pages/LiveTracking.tsx`)
- Audit and alerts → Shipment API client: calls (evidence: `frontend/src/pages/AnalyticsAudit.tsx`)
- Shipment API client → FastAPI application: HTTP requests
- FastAPI application → Domain API routes: registers routes (evidence: `backend/main.py`)
- Domain API routes → Shipment lifecycle: calls (evidence: `backend/routes/shipments.py`)
- Domain API routes → Temperature monitoring: calls (evidence: `backend/routes/tracking.py`)
- Domain API routes → Dispatch weather: calls (evidence: `backend/routes/weather.py`)
- Shipment lifecycle → MongoDB collections: writes shipments (evidence: `backend/services/shipment_service.py`)
- Shipment lifecycle → Blockchain anchoring: anchors events (evidence: `backend/services/shipment_service.py`)
- Temperature monitoring → MongoDB collections: stores readings (evidence: `backend/services/temperature_service.py`)
- Temperature monitoring → Blockchain anchoring: anchors hashes (evidence: `backend/services/temperature_service.py`)
- Temperature monitoring → Risk assessment: updates risk
- Document provenance → MongoDB collections: stores records (evidence: `backend/services/document_service.py`)
- Document provenance → Blockchain anchoring: anchors hashes (evidence: `backend/services/document_service.py`)
- Custody handoffs → MongoDB collections: stores handoffs (evidence: `backend/services/handoff_service.py`)
- Custody handoffs → Blockchain anchoring: anchors events (evidence: `backend/services/handoff_service.py`)
- Shipment verification → Document provenance: checks records (evidence: `backend/services/verification_service.py`)
- Shipment verification → Custody handoffs: checks custody (evidence: `backend/services/verification_service.py`)
- Shipment verification → Temperature monitoring: checks readings (evidence: `backend/services/verification_service.py`)
- Shipment verification → Risk assessment: checks risk (evidence: `backend/services/verification_service.py`)
- Blockchain anchoring → Ethereum network: reads and writes (evidence: `backend/services/blockchain_service.py`)
- IoT sensor readings → Temperature monitoring: submits readings
- Customer / auditor → Public verification: audits shipment
