commit fca8d50c6dfd68834d1e782835a04332d40a056f
Author: maydayv7 <maydayv7@gmail.com>
Date: Tue, 30 Sep 2025 18:44:52 +0530
feat: Add `docs`
Diffstat:
| A | .gitignore | | | 1 | + |
| A | README.md | | | 15 | +++++++++++++++ |
| A | docs/MODEL.md | | | 192 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | docs/SOLUTION.md | | | 308 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 516 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+~*
diff --git a/README.md b/README.md
@@ -0,0 +1,15 @@
+# Problem Statement
+
+SIH25045: Blockchain-Based Supply Chain Transparency for Agricultural Produce
+
+### Description
+
+Create a blockchain-based system to track agricultural produce from farm to consumer, ensuring transparency in pricing, quality, and origin. The solution should allow stakeholders (farmers, distributors, retailers) to verify transactions and reduce exploitation in the supply chain.
+
+### Expected Outcome
+
+A decentralized platform with a user-friendly interface for farmers and consumers to trace produce, reducing fraud and ensuring fair pricing, deployable on low-cost hardware or cloud infrastructure.
+
+### Technical Feasibility
+
+Leverages existing blockchain frameworks like Ethereum or Hyperledger, with smart contracts for automated tracking and QR code integration for consumer access.
diff --git a/docs/MODEL.md b/docs/MODEL.md
@@ -0,0 +1,192 @@
+# Roles
+
+1. Farmer
+2. Distributor
+3. Retailer
+4. Consumer
+5. Inspector
+
+# Chaincode Functions
+
+### Produce Lifecycle
+
+1. registerProduce(farmerId, details) -> Only Farmer
+
+- Creates a new 'Produce' asset
+- Adds it to 'actionHistory' and farmer's 'registeredProduce'
+- Creates a "REGISTER" 'actionItem'
+
+2. updateLocation(produceId, actorId, inTransit/newLocation) -> Only Farmer/Distributor/Retailer
+
+- Changes 'currentLocation' or 'status' to "In Transit"
+- Adds "MOVE" 'actionItem'
+
+3. markAsUnavailable(produceId, actorId, reason, newStatus) -> Only Farmer/Distributor/Retailer/Inspector
+
+- Mark 'isAvailable' as false and set 'notAvailableReason' to reason
+- Adds "REMOVED" actionItem
+
+4. inspectProduce(produceId, inspectorId, qualityUpdate) -> Only Inspector
+
+- Updates 'quality'/'expiryDate'
+- Adds an "INSPECT" 'actionItem'
+- Calls `markAsUnavailable` if asset fails inspection
+
+5. updateDetails(produceId, actorId, details) -> Only 'currentOwner'
+
+- Updates 'pricePerUnit', 'storageConditions'
+- Adds "UPDATED" actionItem
+
+6. splitProduce(produceId, qty, OwnerId) -> Only 'currentOwner'
+
+- Creates new assets and sets 'parentID'
+- Updates parent 'qty' and sets 'children'
+- Adds a "SPLIT" 'actionItem'
+
+7. transferOwnership(produceId, newOwnerId, qty, salePrice) -> Only 'currentOwner'
+
+- Verifies if asset is available
+- Full or partial transfer -> Calls `splitBatch` if partial
+- Updates 'saleHistory' and 'actionHistory', and fields in roles
+- Adds a "SALE" 'actionItem'
+
+8. recordPayment(produceId, transactionId, paymentStatus)
+
+- Update 'paymentStatus', 'paymentMethod', 'paymentRef'
+- Links off-chain payment confirmation (UPI/BankRef)
+
+## Querying
+
+1. getProduceById(produceId)
+
+- Returns current state
+
+2. getProduceByOwner(ownerId)
+
+- Lists all assets owned by a role
+
+## Governance
+
+1. registerUser(role, details) -> Accept user by vote
+
+- Registers Farmer/Distributor/Retailer/Inspector/Consumer
+
+2. getUserDetails(userId)
+
+- Returns profile
+
+3. updateUser(userId, role, details)
+
+- Updates user details
+
+# Schema
+
+## Produce
+
+```
+id:
+parentId: null if original batch, otherwise reference to parent batch
+children: null or [childIds]
+
+qty:
+qtyUnit: KG/Number
+
+pricePerUnit: Asking Price
+totalPrice: pricePerUnit * qty
+
+currentOwner:
+currentLocation:
+actionHistory: ['actionItem']
+saleHistory: ['transaction']
+
+cropType:
+harvestDate:
+quality:
+expiryDate:
+storageConditions: [Cold Storage, High Temperature, Ambient etc.]
+
+status: "Harvested"/"In Transit"/"Retail"/"Missing"/"Failed Inspection"/"Removed"
+isAvailable: true/false -> false if asset is not available due to 'notAvailableReason'
+notAvailableReason: If asset is expired/missing/fails inspection/sold to consumer
+```
+
+### actionItem
+
+Order by 'timestamp'
+
+```
+timestamp:
+action: "REGISTER"/"UPDATED"/"MOVE"/"SPLIT"/"SALE"/"INSPECT"/"REMOVED"
+currentLocation:
+currentOwner:
+```
+
+### transaction
+
+Order by 'timestamp'
+
+```
+timestamp:
+prevOwner:
+newOwner:
+salePrice: Total amount paid
+
+qtyBought:
+newId: If a new asset was created
+
+paymentStatus:
+paymentMethod:
+paymentRef:
+```
+
+## Farmer
+
+```
+role: "Farmer"
+id:
+name:
+location:
+walletId: For Payments
+registeredProduce: [produceIds]
+certification: ["Organic", "Fair Trade" etc]
+```
+
+## Distributor
+
+```
+role: "Distributor"
+id:
+name:
+location:
+walletId:
+ownedProduce: [produceIds]
+```
+
+## Retailer
+
+```
+role: "Retailer"
+id:
+name:
+shopLocation:
+walletId:
+inventory: [produceIds]
+```
+
+## Inspector
+
+```
+role: "Inspector"
+id:
+name:
+authority: "Govt"/"Private"/"NGO"
+```
+
+## Consumer
+
+```
+role: "Consumer"
+id:
+```
+
+We don't include any details of a particular consumer to protect their privacy, but at the same time they will be able to access all the information about the asset
diff --git a/docs/SOLUTION.md b/docs/SOLUTION.md
@@ -0,0 +1,308 @@
+# Proposed Solution
+
+_"Trustable Food, Transparent Journey"_
+
+- A **blockchain-powered agriculture supply chain platform** that records every stage of produce lifecycle — from **farmer → distributor → retailer → consumer**.
+- Each batch of produce is **digitally registered** with details like crop type, harvest date, quality, ownership, and movement.
+- **Role-based permissions** ensure farmers can register produce, distributors/retailers can update location and sales, inspectors can certify quality, and consumers can only view authenticity.
+- Consumers access this information instantly by **scanning QR/NFC codes**, even without blockchain knowledge.
+- **Payments** are supported via off-chain methods (UPI/Banking) with immutable references stored on-chain.
+
+### How It Addresses the Problem
+
+- **Reduces Exploitation** → Farmers get better price transparency and bargaining power.
+- **Curbs Fraud & Adulteration** → Immutability ensures no tampering with quality/inspection records.
+- **Trust** → Retailers and consumers know exactly where produce came from, when it was harvested, and under what conditions it was stored.
+- **Simplifies Regulatory Compliance** → Government/NGO inspectors gain digital audit trails, reducing corruption.
+- **Boosts export potential** → Aligns with international traceability standards, opening global markets for Indian produce.
+
+### Innovation and Uniqueness of the Solution
+
+- Farm-to-fork transparency
+- IoT & hybrid data model
+- Consumer-first design
+- Inclusive & low-tech friendly
+- Scalable modular architecture
+- Privacy-conscious
+
+# Technical Approach
+
+## 1. Hyperledger Fabric
+
+### Network Topology
+
+- **Organizations:**
+
+ - Farmer Org
+ - Distributor Org
+ - Retailer Org
+ - Inspector Org
+ - Consumer Org (read-only, query access)
+
+- **Peers:**
+ Each organization runs committer peer, creating a symmetric network.
+
+ - Endorser peers simulate transactions & enforce endorsement policies.
+ - Committer peers validate & append blocks to the ledger.
+
+- **Orderer Nodes:**
+ - **Odd number of orderers** running **Raft consensus** for fault tolerance.
+ - Guarantees finality and crash-fault tolerance without relying on external ordering services.
+
+### Governance Layer
+
+- **Chaincode Lifecycle Governance (Fabric v2.0):**
+
+ - Chaincode can only be activated when >50% organizations vote to approve its definition.
+ - Endorsement policy:
+ - `AND(FarmerOrg, DistributorOrg, RetailerOrg)` for produce lifecycle operations.
+ - `OR(InspectorOrg, FarmerOrg, DistributorOrg)` for inspection/removal events.
+ - Updates to chaincode versions also go through decentralized approval, preventing unilateral changes.
+
+- **Voting Rules:**
+ - New member admission → 1 vote per organization → majority (>50%) required.
+ - System admin election → democratic process via voting.
+ - Misbehaving member → flagged on-chain, removed via governance vote, cannot rejoin.
+
+### Data Model
+
+#### Ledger
+
+- **Immutable append-only log** → ensures full history of every asset.
+- **World state database (CouchDB)** → supports rich queries (e.g. “find all produce inspected in the last 7 days”).
+
+#### Assets
+
+- **Produce Asset Schema** with lifecycle attributes (`quality`, `expiryDate`, `actionHistory`, `saleHistory`, `status`).
+- **Nested provenance tracking:** Parent-child relationship for split batches ensures recursive traceability.
+
+#### Action History
+
+- Every change (`REGISTER`, `MOVE`, `SPLIT`, `SALE`, `INSPECT`, `REMOVED`) is an **event-sourced action item** ordered by timestamp.
+- Enables **time travel debugging** of supply chain flows.
+
+### Privacy & Security
+
+- **Private Data Collections (PDCs):**
+
+ - Pricing & payment details → visible only to transacting parties (e.g., Farmer–Distributor).
+ - Inspection results → shared with all except Consumers until final outcome is decided.
+ - Prevents sensitive commercial data leaks while ensuring verifiable integrity (hashes still on-chain).
+
+- **Role-Based Access Control (RBAC):**
+
+ - Enforced in chaincode using Fabric’s **Client Identity Chaincode Library (CID)**.
+ - Farmers can register produce, Inspectors can update quality, only current owners can transfer assets.
+
+- **Consumer Queries:**
+ - Consumers remain pseudonymous (no PII stored).
+ - They can query provenance (farm → distributor → retailer) using **read-only chaincode functions**.
+
+## 2. Cross-Platform App
+
+### Overview
+
+- QR scan-based provenance tracking for consumers.
+- Role-specific dashboards for farmers, distributors, retailers, and inspectors.
+- A Global Chain Access page that exposes all supply chain actions for maximum transparency.
+- Cross-platform availability (web, Android, iOS) for universal adoption.
+
+### Technology Stack
+
+- Frontend Web (PWA):
+ - React + TailwindCSS for rapid development, consistent UI, and responsive design.
+ - Provides consumer-facing provenance pages and administrative dashboards.
+- Mobile App (Cross-Platform):
+
+ - React Native (Expo) with NativeWind (Tailwind for RN).
+ - Published to Google Play Store and Apple App Store for mass adoption.
+ - Supports offline-first usage (local storage + background sync).
+
+- Shared Styling & Components:
+
+ - Unified Tailwind-based design system across web and mobile ensures a consistent experience.
+
+- Backend Gateway:
+
+ - Node.js/Express (or Apollo GraphQL) acting as a secure API layer.
+ - Interacts with Hyperledger Fabric SDK to submit transactions, fetch ledger state, and stream updates.
+
+- Distribution:
+ - Web: Installable Progressive Web App (PWA).
+ - Mobile: Expo builds distributed on Play Store and App Store.
+
+### Core Features
+
+#### a. QR Provenance Tracking
+
+- QR codes generated at the farmer/distributor level encode a unique asset identifier.
+- Consumers and other stakeholders\*scan the QR code to see the entire provenance — from farm → distributor → retailer → final sale.
+
+#### b. Role-Specific Dashboards
+
+- Farmers → Register produce, generate QR, transfer ownership.
+- Distributors → Update location, batch split, resale.
+- Inspectors → Record inspection results, approve/reject batches.
+- Retailers → Confirm inventory and log sales.
+- Consumers → Scan QR and view provenance (read-only).
+
+#### c. Global Chain Access Page (Ledger Explorer)
+
+- Complete transparency layer where all permitted users (and optionally the public) can view every action committed to the blockchain.
+- **Features:**
+ - Chronological action feed (`REGISTER`, `MOVE`, `SALE`, `INSPECT`, `REMOVED`).
+ - Search & filter (by product ID, actor, action type, time range).
+ - Governance activity logs (votes, admin election results, membership changes).
+ - Export & reporting tools for auditors and NGOs.
+- Privacy preservation: Sensitive details in Private Data Collections are replaced with hashed commitments, ensuring integrity without leakage.
+
+#### d. Security & Compliance
+
+- Role-based access enforced by Fabric’s Client Identity Chaincode Library (CID).
+- Consumers remain pseudonymous — no PII stored on-chain.
+- Compliance with India’s DPDP Act for data privacy.
+
+### User Journey
+
+1. **Farmer registers produce** → QR code generated and printed on packaging.
+2. **Distributor scans & updates movement** → location and batch split recorded.
+3. **Inspector inspects batch** → result logged on-chain.
+4. **Retailer confirms sale** → final transfer logged.
+5. **Consumer scans QR in the market** → provenance timeline displayed instantly.
+6. **Any stakeholder visits Global Chain Access** → full chronological record of supply chain actions visible, reinforcing **trust and auditability**.
+
+## 3. Future Additions
+
+### Fair Price Model
+
+Our system integrates a Fair Pricing Model that ensures farmers, distributors, retailers, and consumers participate in a transparent, exploitation-free market.
+Prices are driven by supply–demand dynamics and smart contracts, making the system self-regulating, fair, and trustworthy.
+
+### AI-Based Inventory Management & Analytics
+
+Our system integrates an AI-Based Inventory Management and Analytics module that helps farmers and distributors align production with real market demand.
+By analyzing historical sales, seasonal patterns, and regional preferences, the system reduces overhead, minimizes wastage, and ensures streamlined movement of produce.
+This data-driven approach provides predictive insights into what crops to grow and what stock to hold, ensuring efficiency, profitability, and sustainability across the supply chain.
+
+# Feasibility and Viability Analysis
+
+## 1. Feasibility of the Idea
+
+### Technical Feasibility
+
+- Blockchain framework: Hyperledger Fabric is mature, open-source, and modular. It supports permissioned networks, role-based access, and smart contracts — ideal for a multi-stakeholder agriculture supply chain.
+- Deployment: Can run on low-cost cloud servers (AWS/Azure/local datacenters) or low-power hardware (Raspberry Pi clusters, state-sponsored nodes).
+- Integration: Consumers can scan QR/NFC codes to verify authenticity; a simple website + scanner ensures ease of use even with minimal digital literacy.
+- Payments: Off-chain payments (UPI/Banking) with immutable on-chain references ensure compliance and practicality.
+
+### Economic Feasibility
+
+- Cost structure: Network expenses can be subsidized by government/NGOs or absorbed through CSR by agritech startups.
+- Value creation: Long-term savings arise from fraud reduction, better quality assurance, and stronger farmer bargaining power.
+- Market benefits: Transparent provenance boosts consumer willingness to pay a premium for certified produce (organic, fair-trade, etc).
+
+### Social Feasibility
+
+- Trust and fairness: Farmers get better price transparency, retailers gain confidence in sourcing, and consumers are assured of quality.
+- Governance benefits: Inspectors (Govt./NGOs) gain verifiable digital audit trails, helping reduce corruption.
+- Export readiness: Traceability aligns with global market demands (EU/US), boosting India’s agri-export potential.
+
+## 2. Potential Challenges and Risks
+
+### Technical Risks
+
+- Identity & data authenticity: Must ensure only verified farmers/inspectors register produce; false entries otherwise remain immutable.
+- Scalability & interoperability: High transaction volumes may strain the network; integration with mandi systems, farmer databases, and government subsidy platforms can be complex.
+- Adoption gaps: If not all stakeholders adopt the system, traceability remains incomplete.
+
+### Economic & Operational Risks
+
+- Onboarding costs: Many small farmers lack smartphones, internet, or digital wallets.
+- Adoption barriers: Farmers/distributors may resist digital tools; poor rural connectivity may disrupt real-time updates.
+
+### Legal & Regulatory Risks
+
+- Data privacy: Compliance with India’s Digital Personal Data Protection Act (DPDP) is mandatory.
+- Adoption pace: Government bureaucracy may delay rollout.
+
+## 3. Strategies to Overcome Challenges
+
+### Technical Strategies
+
+- Identity & data validation: Farmers/distributors verified via government-issued IDs (FPO membership, Aadhaar-KYC). IoT devices (weighing machines, GPS trackers, storage sensors) can ensure verifiable data.
+- Phased rollout: Begin with pilots in one mandi/district and focus on high-value crops (organic rice, spices, fruits) before scaling state-wide.
+- Efficient data storage: Record only essentials on-chain; offload certificates and lab reports to IPFS/cloud with hashes.
+- Offline-first design: Mobile apps should support offline data capture, syncing when connectivity returns.
+
+### Economic & Social Strategies
+
+- Incentives & subsidies: Government/NGO schemes (e.g., Odisha agriculture programs) can subsidize onboarding; participation may be mandated for certifications. Consumers could be rewarded with discounts/loyalty points for buying traceable produce.
+- Capacity building: Training through NGOs and Agri universities; SMS/IVR updates for farmers without smartphones ensure low-tech access.
+
+### Legal & Policy Strategies
+
+- Privacy & compliance: Follow DPDP principles with minimal personal data storage, anonymizing consumers while retaining IDs for verified roles.
+
+# Impact and Benefits
+
+## Currently existing issues
+
+- Opaque pricing: Farmers don’t know the final selling price; middlemen dominate and take large margins, leading to low farmer earnings(often only 25-40% of the consumers price).
+- Unreliable quality checks: Certifications and safety checks are inconsistent and prone to manipulation.
+- Distrust in labels: Claims like “organic” or “pesticide-free” are hard for consumers to verify.
+- Inefficient supply chains: Weak logistics and inability of distributors to swiftly trace issues cause huge losses.
+- Lack of accountability: No transparent record of actions taken by farmers, distributors, or retailers.
+- Vulnerability to tampering: Currently existing centralized databases can be tampered with/manipulated by dishonest actors.
+
+## Impact of proposed solution
+
+- The proposed solution effectively deals with all of these issues by enhancing trust and transparency at every point in the supply chain.
+- An immutable ledger system provides large scale benefits to all parties involved in the process.
+
+### 1. Impact on each player in the supply chain
+
+**Benefits for Consumers**
+
+- Total Transparency: Consumers can know exactly when, and from which farm their produce was harvested. Additionally they can understand how much of the price actually reached the farmer vs. middlemen.
+- Quality and Safety assurance: Immutable logging of quality checks and verifications build trust and reduce risk of adulteration or contamination.
+- Authenticity of labels: Claims like “organic” or “pesticide-free” can be independently verified.
+- Informed choices: Consumers can choose produce not just on price but on quality, sustainability, and fairness.
+
+**Benefits for Farmers**
+
+- Proof of Origin and Quality: The ledger can store verifiable data on farming practices and quality, which allows farmers to market their products as high-quality, organic, or sustainably grown and sell them at a premium.
+- Fairer Pricing: Farmers get a transparent record of the final retail price, which can help them negotiate fairer deals and bypass middlemen who often take a large cut.
+- Insight and Analytics: Farmers get access to an analytics dashboard that provides exhaustive information about the sales of their produce, which allows them to evaluate and optimize their processes.
+- Reduced disputes: Clear, verifiable records of transactions and quality checks protect farmers against false claims.
+
+**Benefits for Retailers/Distributors**
+
+- Brand differentiation: Can market produce as verifiably safe, authentic, and traceable, attracting premium customers.
+- Stronger consumer trust: Transparency builds loyalty and reduces skepticism around food quality.
+- Regulatory compliance: Easy proof of adherence to food safety and certification requirements.
+- Efficient supply management: Clear tracking of batches improves inventory control and reduces losses.
+- Access to premium partnerships: Exporters, large retailers, and institutional buyers prefer traceable supply chains.
+
+**Benefits for Regulators & Policymakers**
+
+- Real-time compliance monitoring of food safety and subsidy schemes.
+- Easier detection of fraud and malpractice (fake organic labels, subsidy misuse).
+- Data-driven policymaking for agriculture storage, logistics, and MSP interventions.
+- Faster response during crises (e.g., contaminated batch recall).
+
+### 2. Environmental impact
+
+- Promotion of sustainable farming: Farmers are incentivized to adopt eco-friendly practices since these can be verified and rewarded with better prices.
+- Reduction in food waste: Improved traceability and storage monitoring(with IoT integration) help minimize spoilage and losses along the supply chain.
+- Lower carbon footprint: Transparent supply chains reduce unnecessary transport and middlemen steps, streamlining logistics.
+- Support for eco-labeling: Verifiable claims (organic, low-pesticide, fair-trade) promote responsible consumer choices, driving demand for greener practices.
+- Accountability for harmful practices: Visibility discourages overuse of chemicals or unsustainable farming methods, as these would be recorded.
+
+### 3. Social impact
+
+- Farmer empowerment: Greater transparency strengthens farmers’ bargaining power and dignity in the supply chain.
+- Financial inclusion: Verifiable sales histories help farmers access credit, subsidies, and crop insurance more easily.
+- Consumer awareness: Shifts buying behavior toward fairness and sustainability by making information openly available.
+- Trust-building: Reduces the social gap between rural producers and urban consumers through openness and accountability.
+- Community benefits: Higher farmer earnings can improve rural livelihoods, education, and healthcare access.
+- Reduction in exploitation: Transparency discourages unfair practices by middlemen and dishonest actors.