Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
142 changes: 142 additions & 0 deletions Code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# SIH-2025
Agri-Trace Odisha Development Plan

## 1\. Project Overview

**Project Name:** Agri-Trace Odisha
**Objective:** To design, develop, and deploy a blockchain-based supply chain transparency system for agricultural produce in Odisha. The platform will leverage Hyperledger Fabric to create an immutable, transparent, and auditable record of produce from farm to consumer, aiming to ensure fair pricing for farmers, reduce fraud, and enhance food safety.

This document outlines the comprehensive development plan, technology stack, architecture, phased rollout strategy, and key milestones for the successful implementation of the pilot program.

-----

## 2\. Technology Stack

The platform will be built on a modular, enterprise-grade technology stack designed for security, scalability, and performance.[1, 2]

| Layer | Technology | Rationale |
| :--- | :--- | :--- |
| **Blockchain** | **Hyperledger Fabric v2.x** | Permissioned network ideal for a government-led consortium, offering data privacy via channels, high performance, and no cryptocurrency/gas fees.[3, 1] |
| **Smart Contracts** | **Go (Chaincode)** | High performance, strong typing, and seamless integration with Fabric's architecture.[4, 5] |
| **Backend API** | **Node.js (Express.js)** | Efficiently handles I/O operations and has robust SDK support for Hyperledger Fabric, facilitating communication between the frontend and the blockchain.[5] |
| **Database** | **CouchDB** | Serves as the state database for Fabric, enabling rich queries on ledger data, which is useful for dashboards and analytics.[6, 7] |
| **File Storage** | **IPFS (InterPlanetary File System)** | For decentralized, tamper-proof storage of off-chain data like quality certificates and images. The hash is stored on-chain for verification.[8] |
| **Frontend (Web)** | **React.js** | For building the responsive and data-rich dashboards for government officials, FPOs, and other business stakeholders. |
| **Frontend (Mobile)** | **React Native / Flutter** | For creating a cross-platform mobile app for farmers that is simple, intuitive, works on low-cost devices, and supports the Odia language. |
| **Deployment** | **Docker & Kubernetes** | For containerizing all network components and applications, ensuring consistent environments and scalable deployment on a cloud platform.[9] |
| **Cloud Provider** | **AWS / Azure / IBM Cloud** | Utilizing a managed blockchain service (BaaS) to reduce infrastructure overhead and convert capital expenditure to a predictable operational cost.[10, 11, 12] |

-----

## 3\. High-Level Architecture

The system is a permissioned consortium network where each participating organization (e.g., Dept. of Agriculture, FPOs, Processors) is a member.[13, 14]

1. **Consortium & Identity:** The Department of Agriculture & Farmers' Empowerment will act as the network administrator. Each organization will have its own Certificate Authority (CA) to issue digital identities (x.509 certificates) to its users and nodes.[15, 16]
2. **Network Components:**
* **Peer Nodes:** Hosted by major organizations. They maintain the ledger and run chaincode. Roles include Endorsing Peers (simulating transactions) and Committing Peers (validating and writing blocks).[15, 14]
* **Ordering Service:** Managed by a neutral group of government entities using the Raft consensus algorithm to order transactions into blocks.[17, 18]
* **Channels:** Private sub-networks will be created for confidential transactions between specific parties (e.g., an FPO and a single buyer), ensuring data privacy. A general channel will exist for public data.[19, 20]
3. **Transaction Flow (Execute-Order-Validate):**
* A client application (e.g., farmer's mobile app) signs and sends a transaction proposal to endorsing peers.[21]
* Endorsing peers execute the chaincode, verify the request, and sign the result.[18, 21]
* The client collects endorsements and submits the transaction to the Ordering Service.
* The Ordering Service creates a block of ordered transactions and delivers it to all peers on the channel.
* Committing peers validate the block against endorsement policies and commit it to their local ledger.[21, 22]

-----

## 4\. Development Plan: Phased Sprints

The development will follow an agile methodology, broken down into four main phases.

### **Phase 1: Foundation & Core Blockchain Logic

*Goal: Establish the core blockchain network and business logic.*

* **Sprint 1: Network Setup & Configuration**
* [ ] Provision cloud infrastructure using a BaaS provider.[23]
* [ ] Configure the network topology (organizations, CAs, orderers, peers).
* [ ] Generate cryptographic materials and identities for pilot organizations.
* [ ] Set up the initial channel configuration.
* **Sprint 2: Chaincode Development (Part 1)**
* [ ] Design the core asset data structure (e.g., `ProduceBatch`).
* [ ] Implement `createAsset` function for registering new harvests.
* [ ] Implement `getAssetHistory` function for traceability queries.
* [ ] Write unit tests for all chaincode functions.
* **Sprint 3: Chaincode Development (Part 2)**
* [ ] Implement `transferOwnership` function with endorsement policies requiring signatures from both buyer and seller.
* [ ] Implement `updateAssetStatus` for logistical tracking.
* [ ] Design and implement Private Data Collections (PDCs) for sensitive data like pricing.[24, 25]
* **Sprint 4: API Layer & SDK Integration**
* [ ] Develop a secure RESTful API service (Node.js) to interact with the blockchain.
* [ ] Create endpoints for all chaincode functions (`/create`, `/transfer`, `/query`).
* [ ] Integrate the Hyperledger Fabric SDK for Go/Node.js to manage identities and submit transactions.

### **Phase 2: Application & UI/UX Development

*Goal: Build user-facing applications for all key stakeholders.*

* **Sprint 5: Farmer Mobile App (MVP)**
* [ ] UI/UX design focused on simplicity, icon-driven navigation, and Odia language support.[26, 27]
* [ ] Develop user registration and login flow.
* [ ] Implement the "Register New Harvest" feature, connecting to the backend API.
* **Sprint 6: QR Code Integration & Mobile App Features**
* [ ] Integrate QR code generation upon successful asset creation.
* [ ] Implement QR code scanning for asset lookup and ownership transfer.
* [ ] Develop "My Batches" and "Sales History" views.
* **Sprint 7: Stakeholder Web Portal (Government & Business)**
* [ ] UI/UX design for a data-rich, desktop-first dashboard.[28]
* [ ] Develop role-based access control (Admin, FPO Manager, Distributor).
* [ ] Implement a real-time map view for tracking produce movement.
* **Sprint 8: Web Portal Features & Analytics**
* [ ] Develop asset search and detailed traceability view.
* [ ] Create initial analytics dashboards (e.g., volume by district, price trends).
* [ ] Implement user management functionality for the network administrator.

### **Phase 3: Integration, Testing & Security

*Goal: Ensure all components work together seamlessly and securely.*

* **Sprint 9: End-to-End Integration Testing**
* [ ] Integrate mobile and web frontends with the backend API and blockchain network.
* [ ] Conduct full transaction lifecycle testing (from farmer creation to retailer receipt).
* [ ] Test private data functionality to ensure confidentiality.
* **Sprint 10: Performance & Security**
* [ ] Conduct load testing to measure transaction throughput (TPS) and latency.[29, 7]
* [ ] Perform a security audit of the chaincode and APIs.
* [ ] Implement robust error handling and logging across all layers.[18]
* **Sprint 11: User Acceptance Testing (UAT)**
* [ ] Deploy the platform to a staging environment.
* [ ] Conduct UAT with selected pilot users (farmers, FPO managers).
* [ ] Gather feedback and iterate on UI/UX based on user input.[27]

### **Phase 4: Deployment & Pilot Launch

*Goal: Launch the pilot program and provide ongoing support.*

* **Sprint 12: Production Deployment & Go-Live**
* [ ] Prepare and deploy the full application stack to the production environment.
* [ ] Onboard all pilot program participants and conduct final training sessions.
* [ ] **Official Pilot Launch.**
* [ ] Establish a user support system (helpline, field support).
* [ ] Begin monitoring system performance and user activity KPIs.

-----

## 5\. Risk Assessment & Mitigation

| Risk Category | Description | Mitigation Strategy |
| :--- | :--- | :--- |
| **Adoption Risk** | Farmers and other stakeholders may resist adopting a new, complex technology due to low digital literacy or lack of trust.[30, 31] | - **UI/UX:** Design an extremely simple, icon-based mobile app in the Odia language.[26] \<br\> - **Training:** Implement a comprehensive, hands-on training program leveraging government extension officers.[32] \<br\> - **Incentives:** Clearly demonstrate the primary benefit: faster, fairer payments. |
| **Technical Risk** | Scalability issues or bugs in the smart contracts could disrupt the supply chain.[33, 34] | - **Phased Rollout:** Start with a limited pilot to identify and fix issues before a state-wide launch. \<br\> - **Testing:** Conduct rigorous unit, integration, and performance testing. \<br\> - **Security Audit:** Engage third-party experts to audit the chaincode for vulnerabilities.[35] |
| **Governance Risk** | Lack of clear rules or disputes between consortium members could stall the project.[36] | - **Steering Committee:** Establish the "Odisha Blockchain for Agriculture (OBA)" Steering Committee from the outset to define policies and resolve disputes. \<br\> - **Clear Policies:** Define endorsement policies and channel access rules in the network configuration. |
| **Cost Risk** | Development and infrastructure costs could exceed the budget.[37, 38] | - **BaaS Model:** Use a managed blockchain service to have predictable, operational costs instead of large upfront capital costs.[39, 40] \<br\> - **MVP Focus:** Focus the pilot on core features to deliver value quickly and avoid scope creep. |

-----

## 6\. Future Enhancements (Post-Pilot)

* **Digital Payment Integration:** Integrate with UPI gateways to trigger automatic payments to farmers upon successful ownership transfer, using the blockchain transaction as a verifiable trigger.[9, 41]
* **AI & Data Analytics:** Leverage the trusted, immutable data on the blockchain to build AI models for demand forecasting, logistics optimization, and predictive market intelligence.[42, 43]
* **IoT Integration:** Integrate with IoT sensors in warehouses and transport vehicles to automatically record temperature and humidity data on the blockchain for high-value goods.[44]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/package.json → Code/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@clerk/clerk-react": "^5.0.0",
"@prisma/client": "^6.16.1",
"@tailwindcss/vite": "^4.1.13",
"bip39": "^3.1.0",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
181 changes: 181 additions & 0 deletions Code/frontend/src/components/verify.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import React, { useState } from "react";
import {
useSignIn,
useClerk,
useSession,
} from "@clerk/clerk-react";
import { useNavigate } from "react-router-dom";

const Verify = ({ onVerificationSuccess }) => {
const { signIn } = useSignIn();
const { isLoaded, isSignedIn } = useSession();
const clerk = useClerk();
const navigate = useNavigate();

const [phone, setPhone] = useState("");
const [smsCode, setSmsCode] = useState("");
const [loading, setLoading] = useState(false);
const [resending, setResending] = useState(false);
const [isSent, setIsSent] = useState(false);

// If already signed in, navigate to the dashboard or home page
if (isLoaded && isSignedIn) {
navigate("/");
}

// Handle phone number submission and send OTP
const handleSendOTP = async (e) => {
e.preventDefault();
if (!phone.trim()) {
alert("Please enter a valid phone number");
return;
}
setResending(true);
try {
// Create or update a sign-in attempt with the phone number
const res = await signIn.create({
strategy: "phone_code",
identifier: phone,
});

// After successful creation, request the phone code
await res.prepareFirstFactor({
strategy: "phone_code",
});

setIsSent(true);
alert("Verification code sent!");
} catch (err) {
console.error("Error sending OTP:", err.errors?.[0]?.longMessage || err.message);
alert(err.errors?.[0]?.longMessage || "Error sending OTP. Please try again.");
} finally {
setResending(false);
}
};

// Handle OTP verification
const handleVerifyOTP = async (e) => {
e.preventDefault();
setLoading(true);
try {
// Attempt to authenticate the user with the received code
const completeSignIn = await signIn.attemptFirstFactor({
strategy: "phone_code",
code: smsCode,
});
// If successful, set the active session and call success callback
if (completeSignIn.status === "complete") {
await clerk.setActive({ session: completeSignIn.createdSessionId });
localStorage.setItem("verified", "true");
onVerificationSuccess && onVerificationSuccess();
} else {
console.error("Verification failed:", completeSignIn);
const handleSubmit = (e) => {
e.preventDefault();
if (smsCode.length === 6) verifyOTP();

};

const handlePhoneChange = (e) => {
setPhone(e.target.value.replace(/[^\d+\-\s()]/g, ""));
};
return (
<div className="min-h-screen bg-gradient-to-r from-sky-200 to-blue-100 flex items-center justify-center p-4">
<div className="max-w-md w-full bg-white p-8 rounded-xl shadow-lg relative">
<div className="text-center mb-8">
<div className="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
<span className="text-2xl">📱</span>
</div>
<h2 className="text-2xl font-bold text-gray-800 mb-2">
Verify Your Phone
</h2>
<p className="text-gray-600">
{isSent ? "Enter the verification code sent to your phone." : "Enter your phone number to receive a verification code."}
</p>
</div>

<form onSubmit={isSent ? handleVerifyOTP : handleSendOTP} className="space-y-6">
{/* Phone input */}
{!isSent && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
Phone Number
</label>
<input
type="tel"
placeholder="+1 (555) 123-4567"
value={phone}
onChange={(e) => setPhone(e.target.value)}
className="w-full p-4 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 outline-none"
disabled={isSent}
/>
</div>
)}

{/* Conditional button for sending OTP */}
{!isSent && (
<button
type="submit"
disabled={!phone.trim() || resending}
className="w-full py-3 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 disabled:opacity-50"
>
{resending ? "Sending..." : "Send OTP"}
</button>
)}

{/* OTP input, only visible after OTP is sent */}
{isSent && (
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
Enter verification code
</label>
<input
type="text"
placeholder="000000"
maxLength={6}
value={smsCode}
onChange={(e) => setSmsCode(e.target.value.replace(/\D/g, ""))}
className="w-full p-4 border border-gray-300 rounded-lg text-center text-2xl font-mono"
/>
</div>
)}

{/* Conditional button for verifying OTP */}
{isSent && (
<button
type="submit"
disabled={smsCode.length !== 6 || loading}
className="w-full py-4 bg-green-600 text-white font-semibold rounded-lg hover:bg-green-700 disabled:opacity-50 flex items-center justify-center"
>
{loading ? "Verifying..." : "Verify Code"}
</button>
)}

{/* "Resend" and "Change Phone Number" links */}
{isSent && (
<div className="text-center mt-4 text-sm">
<button
type="button"
onClick={() => handleSendOTP({ preventDefault: () => {} })}
disabled={resending}
className="text-blue-500 hover:text-blue-700 font-medium disabled:opacity-50"
>
{resending ? "Resending..." : "Resend code"}
</button>
<span className="mx-2 text-gray-400">|</span>
<button
type="button"
onClick={() => setIsSent(false)}
className="text-gray-500 hover:text-gray-700 font-medium"
>
Change number
</button>
</div>
)}
</form>
</div>
</div>
);
};

export default Verify;
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions Code/frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
import { ClerkProvider } from '@clerk/clerk-react'

const Clerk_key = "pk_test_ZWxlY3RyaWMtcHl0aG9uLTY1LmNsZXJrLmFjY291bnRzLmRldiQ";

if(!Clerk_key) throw new Error("Clerk Key Required");
createRoot(document.getElementById('root')).render(
<StrictMode>
<ClerkProvider publishableKey={Clerk_key}>
<App />
</ClerkProvider>
</StrictMode>,
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { encodeUTF8, decodeUTF8, encodeBase64, decodeBase64 } from "tweetnacl-ut
const rpc = import.meta.env.VITE_RPC_ETH;
const provider = new ethers.JsonRpcProvider(rpc);

const adminPrivateKey = import.meta.env.VITE_PRIVATE_KEY;
const adminPrivateKey ="9ea352717b97e0ff235da9ce6e0d5e47cb4dd34f4ff296b7c748f1846cd086ad";
const adminWallet = new ethers.Wallet(adminPrivateKey, provider);

export const EthWallet = () => {
Expand Down
File renamed without changes.
Binary file added Files/Internal_PPT_Ni_Chan_Dance.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions Files/Internal_Video_LINK_TEAMNAME.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://youtu.be/2XbAU7xYoHY
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ This README provides an overview of the project, including team details, relevan

## Project Links

- **SIH Presentation:** [Final SIH Presentation](https://drive.google.com/file/d/1zgoAMluiVvNdn2dP9Q0dzmQKWdwp54I7/view?usp=sharing)
- **Video Demonstration:** [Watch Video](https://youtu.be/2XbAU7xYoHY)
- **SIH Presentation:** [Final SIH Presentation](URL TO PPT UPLOADED TO GITHUB)
- **Video Demonstration:** [Watch Video](UNLISTED YOUTUBE LINK)
- **Live Deployment:** [View Deployment](gdsc-silk.vercel.app/)
- **Source Code:** [GitHub Repository](https://github.com/prachi-33/gdsc)
- **Additional Resources:** [Other Relevant Links](ANY OTHER RELEVANT LINKS)


Loading