How eddy165/ayurchain works
AyurChain provides farm-to-consumer herb-batch traceability: supply-chain participants create and advance batches, labs submit reports, and consumers verify provenance through a QR scan. The README describes a hybrid design: MongoDB serves operational records, IPFS holds documents and metadata, and Polygon anchors verifiable proofs and transfers. The graph combines documented capabilities with relationships visible in sampled source; some route implementations and web/mobile screens were not sampled, so those connections are documented rather than inferred from imports.
Main entry points: index.ts Express API · batchController.ts Batch workflow · blockchainService.ts Blockchain bridge · labController.ts Lab reports
Components 29
Client apps
- Web application
web/src/App.tsx - QR mobile app
mobile/src/screens/QRScannerScreen.tsx - Web API client
web/src/services/api.ts - Web auth state
web/src/store/authSlice.ts - Batch and user types
web/src/types/batch.types.ts
API and workflows
- Express API
backend/src/index.ts - Authentication routes
backend/src/routes/auth.ts - Authentication workflow
backend/src/controllers/authController.ts - Batch routes
backend/src/routes/batches.ts - Batch workflow
backend/src/controllers/batchController.ts - Lab routes
backend/src/routes/labs.ts - Lab reports
backend/src/controllers/labController.ts - Consumer route
backend/src/routes/consumer.ts - Consumer traceability
backend/src/controllers/consumerController.ts - QR routes
backend/src/routes/qr.ts - QR handling
backend/src/controllers/qrController.ts - Auth and request guards
backend/src/middleware/auth.ts
Operational records
- Batch records
backend/src/models/Batch.ts - User records
backend/src/models/User.ts - Lab reports
backend/src/models/LabReport.ts - MongoDB
Verification services
- Document storage
backend/src/services/ipfsService.ts - QR generation
backend/src/services/qrService.ts - Blockchain bridge
backend/src/services/blockchainService.ts
On-chain contracts
- Traceability contracts
contracts
Other components
- Supply-chain users
- Consumer
- IPFS Pinata
- Polygon network
Connections 36
- Supply-chain users → Web application: manages batches
README.md - Consumer → QR mobile app: scans QR
README.md - Consumer → Web application: verifies provenance
README.md - Web application → Web API client: requests API
README.md - Web API client → Express API: calls REST API
README.md - Web API client → Web auth state: uses auth state
web/src/services/api.ts - Web auth state → Batch and user types: uses user types
- QR mobile app → Express API: requests traceability
README.md - Express API → Authentication routes: routes requests
backend/src/index.ts - Express API → Batch routes: routes requests
backend/src/index.ts - Express API → Lab routes: routes requests
backend/src/index.ts - Express API → Consumer route: routes requests
backend/src/index.ts - Express API → QR routes: routes requests
backend/src/index.ts - Authentication routes → Authentication workflow: dispatches handlers
backend/src/routes/auth.ts - Consumer route → Consumer traceability: dispatches handlers
backend/src/routes/consumer.ts - QR routes → QR handling: dispatches handlers
backend/src/routes/qr.ts - Auth and request guards → QR routes: guards requests
backend/src/routes/qr.ts - Authentication workflow → User records: reads and writes
backend/src/controllers/authController.ts - Batch workflow → Batch records: reads and writes
backend/src/controllers/batchController.ts - Batch workflow → User records: reads user data
backend/src/controllers/batchController.ts - Batch workflow → Document storage: uploads metadata
backend/src/controllers/batchController.ts - Batch workflow → Blockchain bridge: anchors batch
backend/src/controllers/batchController.ts - Batch workflow → QR generation: creates QR
backend/src/controllers/batchController.ts - Lab reports → Batch records: reads and updates
backend/src/controllers/labController.ts - Lab reports → Lab reports: stores report
backend/src/controllers/labController.ts - Lab reports → Document storage: uploads report
backend/src/controllers/labController.ts - Lab reports → Blockchain bridge: records stage
backend/src/controllers/labController.ts - Consumer traceability → Batch records: reads batch
backend/src/controllers/consumerController.ts - Consumer traceability → Blockchain bridge: verifies history
backend/src/controllers/consumerController.ts - Batch records → MongoDB: persists records
README.md - User records → MongoDB: persists records
README.md - Lab reports → MongoDB: persists reports
README.md - Document storage → IPFS Pinata: stores documents
README.md - Blockchain bridge → Polygon network: submits transactions
README.md - Traceability contracts → Polygon network: executes on
README.md - Blockchain bridge → Traceability contracts: calls contract methods
backend/src/services/blockchainService.ts