# anamikasharma1509/scm-supply-chain-management architecture

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

- Interactive diagram: https://gitdiagram.com/anamikasharma1509/scm-supply-chain-management
- Repository: https://github.com/anamikasharma1509/scm-supply-chain-management

## Overview

SCM is a blockchain-backed supply-chain traceability and anti-counterfeit platform. Supplier batch registration and shipment dispatch, manufacturer receipt and lineage synthesis, and public QR/identifier verification are its principal domain stages; the API persists records and optionally consults a blockchain registry. The graph includes the documented alert, analytics, transaction, QR, and organization capabilities. Some route implementations and frontend pages were not sampled, so their internal calls are not inferred.

Main entry points: [`apps/api/src/app.ts`](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/app.ts) (REST application), [`apps/api/src/lib/prisma.ts`](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/prisma.ts) (Database access), [`apps/web/src/lib/api.ts`](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/lib/api.ts) (API client), [`apps/api/src/lib/blockchain.ts`](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/blockchain.ts) (Blockchain service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_supplier["Supplier dashboard"]
  node_manufacturer["Manufacturer dashboard"]
  node_verification["Verification page"]
  node_alerts_ui["Alerts page<br/>[AlertsPage.tsx]"]
  node_auth_ui["Authentication context<br/>[AuthContext.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_domain["Supply-chain API"]
  node_auth_routes["Authentication<br/>[auth.routes.ts]"]
  node_org_routes["Organizations"]
  node_batch_routes["Batch registry<br/>[batch.routes.ts]"]
  node_shipment_routes["Shipments and custody<br/>[shipment.routes.ts]"]
  node_verify_routes["Public verification<br/>[verify.routes.ts]"]
  node_qr_routes["QR codes<br/>[qr.routes.ts]"]
  node_alert_routes["Anomaly alerts<br/>[alert.routes.ts]"]
  node_analytics_routes["Analytics"]
  node_notification_routes["Notifications"]
  node_transaction_routes["Transaction audit"]
  node_health_routes["Health checks<br/>[health.routes.ts]"]
end

subgraph group_platform["API platform"]
  node_api_app["REST application<br/>[app.ts]"]
  node_auth_middleware["JWT authorization<br/>[auth.ts]"]
  node_error_middleware["Error handling<br/>[errorHandler.ts]"]
  node_rate_middleware["Rate limiting<br/>[rateLimiter.ts]"]
end

subgraph group_ledger["Persistence and ledger"]
  node_prisma["Database access<br/>[prisma.ts]"]
  node_database[("Relational database")]
  node_blockchain_service["Blockchain service<br/>[blockchain.ts]"]
  node_blockchain_network[("Blockchain registry")]
end

node_actors(("Supply-chain users"))

node_actors -->|"registers batches"| node_supplier
node_actors -->|"receives and processes"| node_manufacturer
node_actors -->|"checks products"| node_verification
node_actors -->|"reviews alerts"| node_alerts_ui
node_supplier -->|"requests API"| node_api_client
node_manufacturer -->|"requests API"| node_api_client
node_verification -->|"requests verification"| node_api_client
node_alerts_ui -.->|"requests alerts"| node_api_client
node_auth_ui -->|"requests identity"| node_api_client
node_api_client -->|"sends HTTP requests"| node_api_app
node_api_app -->|"mounts routes"| node_auth_routes
node_api_app -->|"mounts routes"| node_org_routes
node_api_app -->|"mounts routes"| node_batch_routes
node_api_app -->|"mounts routes"| node_shipment_routes
node_api_app -->|"mounts routes"| node_verify_routes
node_api_app -->|"mounts routes"| node_qr_routes
node_api_app -->|"mounts routes"| node_alert_routes
node_api_app -->|"mounts routes"| node_analytics_routes
node_api_app -->|"mounts routes"| node_notification_routes
node_api_app -->|"mounts routes"| node_transaction_routes
node_api_app -->|"mounts routes"| node_health_routes
node_api_app -->|"registers handler"| node_error_middleware
node_auth_routes -->|"reads and writes users"| node_prisma
node_auth_routes -->|"authenticates sessions"| node_auth_middleware
node_auth_routes -->|"limits login requests"| node_rate_middleware
node_batch_routes -->|"reads and writes batches"| node_prisma
node_batch_routes -->|"checks roles"| node_auth_middleware
node_batch_routes -->|"uses ledger service"| node_blockchain_service
node_shipment_routes -->|"reads and writes shipments"| node_prisma
node_shipment_routes -->|"checks roles"| node_auth_middleware
node_shipment_routes -->|"uses ledger service"| node_blockchain_service
node_verify_routes -->|"records scan evidence"| node_prisma
node_verify_routes -->|"limits public scans"| node_rate_middleware
node_verify_routes -->|"checks on-chain proof"| node_blockchain_service
node_alert_routes -->|"reads and updates alerts"| node_prisma
node_alert_routes -->|"checks access"| node_auth_middleware
node_analytics_routes -->|"queries records"| node_prisma
node_transaction_routes -->|"reads transaction records"| node_prisma
node_transaction_routes -->|"uses ledger service"| node_blockchain_service
node_notification_routes -->|"accesses notifications"| node_prisma
node_notification_routes -->|"checks access"| node_auth_middleware
node_org_routes -->|"accesses organizations"| node_prisma
node_qr_routes -->|"accesses QR records"| node_prisma
node_health_routes -->|"checks database"| node_prisma
node_health_routes -->|"checks ledger"| node_blockchain_service
node_prisma -.->|"persists records"| node_database
node_blockchain_service -->|"reads registry"| node_blockchain_network

click node_supplier "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/SupplierDashboard.tsx"
click node_manufacturer "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/ManufacturerDashboard.tsx"
click node_verification "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/VerificationPage.tsx"
click node_alerts_ui "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/AlertsPage.tsx"
click node_auth_ui "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/context/AuthContext.tsx"
click node_api_client "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/lib/api.ts"
click node_api_app "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/app.ts"
click node_auth_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/auth.routes.ts"
click node_org_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/organization.routes.ts"
click node_batch_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/batch.routes.ts"
click node_shipment_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/shipment.routes.ts"
click node_verify_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/verify.routes.ts"
click node_qr_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/qr.routes.ts"
click node_alert_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/alert.routes.ts"
click node_analytics_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/analytics.routes.ts"
click node_notification_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/notification.routes.ts"
click node_transaction_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/transaction.routes.ts"
click node_health_routes "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/health.routes.ts"
click node_auth_middleware "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/auth.ts"
click node_error_middleware "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/errorHandler.ts"
click node_rate_middleware "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/rateLimiter.ts"
click node_prisma "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/prisma.ts"
click node_blockchain_service "https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/blockchain.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_supplier,node_manufacturer,node_verification,node_alerts_ui,node_auth_ui,node_api_client,node_actors toneBlue
class node_auth_routes,node_org_routes,node_batch_routes,node_shipment_routes,node_verify_routes,node_qr_routes,node_alert_routes,node_analytics_routes,node_notification_routes,node_transaction_routes,node_health_routes toneAmber
class node_api_app,node_auth_middleware,node_error_middleware,node_rate_middleware toneMint
class node_prisma,node_database,node_blockchain_service,node_blockchain_network toneRose
```

## Components

### Web application

- [Supplier dashboard](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/SupplierDashboard.tsx): `apps/web/src/pages/SupplierDashboard.tsx`
- [Manufacturer dashboard](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/ManufacturerDashboard.tsx): `apps/web/src/pages/ManufacturerDashboard.tsx`
- [Verification page](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/VerificationPage.tsx): `apps/web/src/pages/VerificationPage.tsx`
- [Alerts page](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/pages/AlertsPage.tsx): `apps/web/src/pages/AlertsPage.tsx`
- [Authentication context](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/context/AuthContext.tsx): `apps/web/src/context/AuthContext.tsx`
- [API client](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`

### Supply-chain API

- [Authentication](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/auth.routes.ts): `apps/api/src/routes/auth.routes.ts`
- [Organizations](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/organization.routes.ts): `apps/api/src/routes/organization.routes.ts`
- [Batch registry](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/batch.routes.ts): `apps/api/src/routes/batch.routes.ts`
- [Shipments and custody](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/shipment.routes.ts): `apps/api/src/routes/shipment.routes.ts`
- [Public verification](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/verify.routes.ts): `apps/api/src/routes/verify.routes.ts`
- [QR codes](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/qr.routes.ts): `apps/api/src/routes/qr.routes.ts`
- [Anomaly alerts](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/alert.routes.ts): `apps/api/src/routes/alert.routes.ts`
- [Analytics](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/analytics.routes.ts): `apps/api/src/routes/analytics.routes.ts`
- [Notifications](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/notification.routes.ts): `apps/api/src/routes/notification.routes.ts`
- [Transaction audit](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/transaction.routes.ts): `apps/api/src/routes/transaction.routes.ts`
- [Health checks](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/routes/health.routes.ts): `apps/api/src/routes/health.routes.ts`

### API platform

- [REST application](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [JWT authorization](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/auth.ts): `apps/api/src/middleware/auth.ts`
- [Error handling](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/errorHandler.ts): `apps/api/src/middleware/errorHandler.ts`
- [Rate limiting](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/middleware/rateLimiter.ts): `apps/api/src/middleware/rateLimiter.ts`

### Persistence and ledger

- [Database access](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/prisma.ts): `apps/api/src/lib/prisma.ts`
- **Relational database**
- [Blockchain service](https://github.com/anamikasharma1509/scm-supply-chain-management/blob/main/apps/api/src/lib/blockchain.ts): `apps/api/src/lib/blockchain.ts`
- **Blockchain registry**

### Other components

- **Supply-chain users**

## Connections

- Supply-chain users → Supplier dashboard: registers batches
- Supply-chain users → Manufacturer dashboard: receives and processes
- Supply-chain users → Verification page: checks products
- Supply-chain users → Alerts page: reviews alerts
- Supplier dashboard → API client: requests API (evidence: `apps/web/src/pages/SupplierDashboard.tsx`)
- Manufacturer dashboard → API client: requests API (evidence: `apps/web/src/pages/ManufacturerDashboard.tsx`)
- Verification page → API client: requests verification (evidence: `apps/web/src/pages/VerificationPage.tsx`)
- Alerts page → API client: requests alerts
- Authentication context → API client: requests identity (evidence: `apps/web/src/context/AuthContext.tsx`)
- API client → REST application: sends HTTP requests (evidence: `apps/web/src/lib/api.ts`)
- REST application → Authentication: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Organizations: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Batch registry: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Shipments and custody: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Public verification: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → QR codes: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Anomaly alerts: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Analytics: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Notifications: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Transaction audit: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Health checks: mounts routes (evidence: `apps/api/src/app.ts`)
- REST application → Error handling: registers handler (evidence: `apps/api/src/app.ts`)
- Authentication → Database access: reads and writes users (evidence: `apps/api/src/routes/auth.routes.ts`)
- Authentication → JWT authorization: authenticates sessions (evidence: `apps/api/src/routes/auth.routes.ts`)
- Authentication → Rate limiting: limits login requests (evidence: `apps/api/src/routes/auth.routes.ts`)
- Batch registry → Database access: reads and writes batches (evidence: `apps/api/src/routes/batch.routes.ts`)
- Batch registry → JWT authorization: checks roles (evidence: `apps/api/src/routes/batch.routes.ts`)
- Batch registry → Blockchain service: uses ledger service (evidence: `apps/api/src/routes/batch.routes.ts`)
- Shipments and custody → Database access: reads and writes shipments (evidence: `apps/api/src/routes/shipment.routes.ts`)
- Shipments and custody → JWT authorization: checks roles (evidence: `apps/api/src/routes/shipment.routes.ts`)
- Shipments and custody → Blockchain service: uses ledger service (evidence: `apps/api/src/routes/shipment.routes.ts`)
- Public verification → Database access: records scan evidence (evidence: `apps/api/src/routes/verify.routes.ts`)
- Public verification → Rate limiting: limits public scans (evidence: `apps/api/src/routes/verify.routes.ts`)
- Public verification → Blockchain service: checks on-chain proof (evidence: `apps/api/src/routes/verify.routes.ts`)
- Anomaly alerts → Database access: reads and updates alerts (evidence: `apps/api/src/routes/alert.routes.ts`)
- Anomaly alerts → JWT authorization: checks access (evidence: `apps/api/src/routes/alert.routes.ts`)
- Analytics → Database access: queries records (evidence: `apps/api/src/routes/analytics.routes.ts`)
- Transaction audit → Database access: reads transaction records (evidence: `apps/api/src/routes/transaction.routes.ts`)
- Transaction audit → Blockchain service: uses ledger service (evidence: `apps/api/src/routes/transaction.routes.ts`)
- Notifications → Database access: accesses notifications (evidence: `apps/api/src/routes/notification.routes.ts`)
- Notifications → JWT authorization: checks access (evidence: `apps/api/src/routes/notification.routes.ts`)
- Organizations → Database access: accesses organizations (evidence: `apps/api/src/routes/organization.routes.ts`)
- QR codes → Database access: accesses QR records (evidence: `apps/api/src/routes/qr.routes.ts`)
- Health checks → Database access: checks database (evidence: `apps/api/src/routes/health.routes.ts`)
- Health checks → Blockchain service: checks ledger (evidence: `apps/api/src/routes/health.routes.ts`)
- Database access → Relational database: persists records
- Blockchain service → Blockchain registry: reads registry (evidence: `apps/api/src/lib/blockchain.ts`)
