# diksha-raj/coldstoragesg architecture

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

- Interactive diagram: https://gitdiagram.com/diksha-raj/coldstoragesg
- Repository: https://github.com/diksha-raj/coldstoragesg

## Overview

ColdChainSG is a cold-chain shipment evidence and certification prototype, not a payment platform. Participants sign in with Ethereum, move shipments through signed two-sided custody checks, submit sensor logs for verification, resolve quality claims, and receive a printable certificate. The React app talks directly to four APIs; the APIs use shared Postgres and chain helpers, while custody actions and oracle/certificate services interact with on-chain registries. The README documents capabilities beyond the sampled excerpts; those relationships are cited to it, and unsampled implementation details are not assumed.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/api.ts) (Service API client), [`services/oracle-service/src/index.ts`](https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/index.ts) (Oracle API), [`frontend/src/lib/chain.ts`](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/chain.ts) (Wallet and chain client), [`frontend/src/main.tsx`](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/main.tsx) (Routes and dashboards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Participant application"]
  node_webapp["Routes and dashboards<br/>[main.tsx]"]
  node_auth["Wallet sign-in<br/>[auth.tsx]"]
  node_handover["Custody actions"]
  node_claim["Claim review<br/>[ClaimPage.tsx]"]
  node_certview["Certificate views"]
  node_print["Printable certificate"]
  node_apiclient["Service API client<br/>[api.ts]"]
  node_chainclient["Wallet and chain client<br/>[chain.ts]"]
end

subgraph group_services["Service APIs"]
  node_identity["Identity API<br/>[index.ts]"]
  node_custody["Custody API<br/>[index.ts]"]
end

subgraph group_evidence["Quality and certification"]
  node_oracle["Oracle API<br/>[index.ts]"]
  node_sensorverify["Sensor evidence checks<br/>[evidence.ts]"]
  node_replay["Sensor log replay<br/>[replay.ts]"]
  node_certificate["Certificate API<br/>[index.ts]"]
  node_certsync["Certificate sync<br/>[sync.ts]"]
end

subgraph group_shared["Shared infrastructure"]
  node_common["Shared auth and chain<br/>[chain.ts]"]
  node_postgres[("Postgres service schemas")]
  node_chain[("Blockchain registries")]
end

node_participant(("Shipment participants"))
node_wallet["MetaMask wallet"]

node_participant -->|"uses"| node_webapp
node_webapp -->|"provides sign-in"| node_auth
node_auth -->|"connects wallet"| node_chainclient
node_auth -->|"requests identity"| node_apiclient
node_wallet -->|"signs transactions"| node_chainclient
node_handover -->|"seals notes"| node_apiclient
node_handover -->|"submits checks"| node_chainclient
node_claim -->|"loads claim data"| node_apiclient
node_certview -.->|"offers print view"| node_print
node_print -->|"reads chain config"| node_chainclient
node_webapp -->|"calls services"| node_apiclient
node_apiclient -->|"routes identity requests"| node_identity
node_apiclient -->|"routes custody requests"| node_custody
node_apiclient -->|"routes oracle requests"| node_oracle
node_apiclient -->|"routes certificate requests"| node_certificate
node_identity -->|"uses shared auth"| node_common
node_custody -->|"records handovers"| node_chain
node_oracle -->|"uses evidence checks"| node_sensorverify
node_oracle -->|"uses replay"| node_replay
node_sensorverify -->|"checks replay output"| node_replay
node_oracle -->|"commits sensor evidence"| node_chain
node_certificate -->|"runs sync loop"| node_certsync
node_certsync -->|"syncs certificates"| node_chain
node_identity -->|"stores identity data"| node_postgres
node_custody -->|"stores custody data"| node_postgres
node_oracle -->|"stores evidence data"| node_postgres
node_certificate -->|"stores certificate data"| node_postgres
node_common -->|"connects RPC"| node_chain

click node_webapp "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/main.tsx"
click node_auth "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/auth.tsx"
click node_handover "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/components/HandoverActions.tsx"
click node_claim "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/pages/ClaimPage.tsx"
click node_certview "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/components/CertificatePanel.tsx"
click node_print "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/pages/CertificatePrint.tsx"
click node_apiclient "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/api.ts"
click node_chainclient "https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/chain.ts"
click node_identity "https://github.com/diksha-raj/coldstoragesg/blob/main/services/identity-service/src/index.ts"
click node_custody "https://github.com/diksha-raj/coldstoragesg/blob/main/services/custody-service/src/index.ts"
click node_oracle "https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/index.ts"
click node_sensorverify "https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/evidence.ts"
click node_replay "https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/replay.ts"
click node_certificate "https://github.com/diksha-raj/coldstoragesg/blob/main/services/certificate-service/src/index.ts"
click node_certsync "https://github.com/diksha-raj/coldstoragesg/blob/main/services/certificate-service/src/sync.ts"
click node_common "https://github.com/diksha-raj/coldstoragesg/blob/main/services/common/src/chain.ts"

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_webapp,node_auth,node_handover,node_claim,node_certview,node_print,node_apiclient,node_chainclient toneBlue
class node_identity,node_custody toneAmber
class node_oracle,node_sensorverify,node_replay,node_certificate,node_certsync toneMint
class node_common,node_postgres,node_chain toneRose
class node_participant,node_wallet toneIndigo
```

## Components

### Participant application

- [Routes and dashboards](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Wallet sign-in](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/auth.tsx): `frontend/src/auth.tsx`
- [Custody actions](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/components/HandoverActions.tsx): `frontend/src/components/HandoverActions.tsx`
- [Claim review](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/pages/ClaimPage.tsx): `frontend/src/pages/ClaimPage.tsx`
- [Certificate views](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/components/CertificatePanel.tsx): `frontend/src/components/CertificatePanel.tsx`
- [Printable certificate](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/pages/CertificatePrint.tsx): `frontend/src/pages/CertificatePrint.tsx`
- [Service API client](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Wallet and chain client](https://github.com/diksha-raj/coldstoragesg/blob/main/frontend/src/lib/chain.ts): `frontend/src/lib/chain.ts`

### Service APIs

- [Identity API](https://github.com/diksha-raj/coldstoragesg/blob/main/services/identity-service/src/index.ts): `services/identity-service/src/index.ts`
- [Custody API](https://github.com/diksha-raj/coldstoragesg/blob/main/services/custody-service/src/index.ts): `services/custody-service/src/index.ts`

### Quality and certification

- [Oracle API](https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/index.ts): `services/oracle-service/src/index.ts`
- [Sensor evidence checks](https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/evidence.ts): `services/oracle-service/src/evidence.ts`
- [Sensor log replay](https://github.com/diksha-raj/coldstoragesg/blob/main/services/oracle-service/src/replay.ts): `services/oracle-service/src/replay.ts`
- [Certificate API](https://github.com/diksha-raj/coldstoragesg/blob/main/services/certificate-service/src/index.ts): `services/certificate-service/src/index.ts`
- [Certificate sync](https://github.com/diksha-raj/coldstoragesg/blob/main/services/certificate-service/src/sync.ts): `services/certificate-service/src/sync.ts`

### Shared infrastructure

- [Shared auth and chain](https://github.com/diksha-raj/coldstoragesg/blob/main/services/common/src/chain.ts): `services/common/src/chain.ts`
- **Postgres service schemas**
- **Blockchain registries**

### Other components

- **Shipment participants**
- **MetaMask wallet**

## Connections

- Shipment participants → Routes and dashboards: uses (evidence: `README.md`)
- Routes and dashboards → Wallet sign-in: provides sign-in (evidence: `frontend/src/main.tsx`)
- Wallet sign-in → Wallet and chain client: connects wallet (evidence: `frontend/src/auth.tsx`)
- Wallet sign-in → Service API client: requests identity (evidence: `frontend/src/auth.tsx`)
- MetaMask wallet → Wallet and chain client: signs transactions (evidence: `frontend/src/lib/chain.ts`)
- Custody actions → Service API client: seals notes (evidence: `frontend/src/components/HandoverActions.tsx`)
- Custody actions → Wallet and chain client: submits checks (evidence: `frontend/src/components/HandoverActions.tsx`)
- Claim review → Service API client: loads claim data (evidence: `frontend/src/pages/ClaimPage.tsx`)
- Certificate views → Printable certificate: offers print view
- Printable certificate → Wallet and chain client: reads chain config (evidence: `frontend/src/pages/CertificatePrint.tsx`)
- Routes and dashboards → Service API client: calls services (evidence: `frontend/src/lib/api.ts`)
- Service API client → Identity API: routes identity requests (evidence: `frontend/src/lib/api.ts`)
- Service API client → Custody API: routes custody requests (evidence: `frontend/src/lib/api.ts`)
- Service API client → Oracle API: routes oracle requests (evidence: `frontend/src/lib/api.ts`)
- Service API client → Certificate API: routes certificate requests (evidence: `frontend/src/lib/api.ts`)
- Identity API → Shared auth and chain: uses shared auth
- Custody API → Blockchain registries: records handovers (evidence: `README.md`)
- Oracle API → Sensor evidence checks: uses evidence checks (evidence: `services/oracle-service/src/index.ts`)
- Oracle API → Sensor log replay: uses replay (evidence: `services/oracle-service/src/index.ts`)
- Sensor evidence checks → Sensor log replay: checks replay output (evidence: `services/oracle-service/src/evidence.ts`)
- Oracle API → Blockchain registries: commits sensor evidence (evidence: `README.md`)
- Certificate API → Certificate sync: runs sync loop (evidence: `services/certificate-service/src/index.ts`)
- Certificate sync → Blockchain registries: syncs certificates (evidence: `README.md`)
- Identity API → Postgres service schemas: stores identity data (evidence: `README.md`)
- Custody API → Postgres service schemas: stores custody data (evidence: `README.md`)
- Oracle API → Postgres service schemas: stores evidence data (evidence: `README.md`)
- Certificate API → Postgres service schemas: stores certificate data (evidence: `README.md`)
- Shared auth and chain → Blockchain registries: connects RPC (evidence: `services/common/src/chain.ts`)
