CropChain is a comprehensive full-stack web application that enables transparent tracking of crop supply chains using blockchain technology. From farm to fork, every step in the supply chain is recorded immutably, providing complete traceability and building trust between all stakeholders.
- Complete Supply Chain Tracking: Track crops through all stages - Farmer β Mandi (Market) β Transport β Retailer
- Blockchain Integration: Immutable record keeping using Ethereum/Polygon smart contracts
- QR Code Generation: Unique QR codes for each batch enabling instant verification
- Multi-Role Support: Different interfaces for farmers, markets, transporters, and retailers
- Admin Dashboard: Comprehensive monitoring and analytics for supply chain managers
- Beautiful, Modern UI: Apple-level design aesthetics with smooth animations
- Responsive Design: Optimized for mobile, tablet, and desktop devices
- Real-time Timeline: Visual supply chain journey with status indicators
- QR Code Scanner: Simulate scanning QR codes for batch tracking
- Search & Filter: Easy batch lookup and filtering capabilities
- Framework: React 18 with TypeScript
- Styling: Tailwind CSS with custom design system
- Routing: React Router for navigation
- Icons: Lucide React for consistent iconography
- State Management: React hooks and context
- Runtime: Node.js with Express framework
- Blockchain: Ethers.js for smart contract interaction
- QR Codes: QRCode library for batch QR generation
- Database: MongoDB for metadata storage
- Authentication: JWT-based auth system
- Platform: Ethereum/Polygon compatible
- Language: Solidity ^0.8.19
- Features: Batch creation, supply chain updates, access control
- Security: Role-based permissions and data validation
- Node.js (v14+)
- npm or yarn
- MetaMask wallet
- Infura/Alchemy account (for blockchain)
- MongoDB (for production)
-
Clone the repository
git clone https://github.com/your-username/cropchain.git cd cropchain -
Install Frontend Dependencies
npm install
-
Install Backend Dependencies
cd backend npm install cd ..
-
Install Smart Contract Dependencies
npm install --save-dev @nomicfoundation/hardhat-toolbox
-
Environment Setup
# Copy environment file cp backend/.env.example backend/.env # Edit with your configuration nano backend/.env
-
Start Frontend Development Server
npm run dev
-
Start Backend Server (in separate terminal)
cd backend npm run dev -
Deploy Smart Contracts (optional, for blockchain integration)
# For local development npx hardhat node npx hardhat run scripts/deploy.js --network localhost # For Mumbai testnet npx hardhat run scripts/deploy.js --network mumbai
graph TD
subgraph Client_Layer [Frontend - React & TypeScript]
UI[User Interface]
QR[QR Scanner/Generator]
end
subgraph Logic_Layer [Backend - Node.js & Express]
API[Express API]
JWT[JWT Auth]
ETH[Ethers.js Instance]
end
subgraph Storage_Layer [Data & Blockchain]
DB[(MongoDB Metadata)]
BC{Smart Contracts - Solidity}
Network[Polygon / Mumbai Testnet]
end
UI --> API
API --> JWT
API --> DB
API --> ETH
ETH --> BC
BC --> Network
sequenceDiagram
participant F as Farmer
participant M as Mandi (Market)
participant T as Transport
participant R as Retailer
participant B as Blockchain (CropChain)
F->>B: Create Batch (Harvest Info)
B-->>F: Generate Unique Batch ID & QR
F->>M: Handover Crops
M->>B: Update Stage (Price & Quality)
M->>T: Handover to Logistics
T->>B: Update Stage (Location & Transit)
T->>R: Deliver to Store
R->>B: Update Stage (Received/Stocked)
Note over R,B: Immutable History Available for Consumer
- Navigate to "Add Batch" page
- Fill in crop details (type, quantity, harvest date, etc.)
- Submit to create blockchain record and QR code
- Share QR code with supply chain partners
- Go to "Update Batch" page
- Search for batch using Batch ID
- Add your stage information (actor, location, notes)
- Submit update to blockchain
- Use "Track Batch" page
- Scan QR code or enter Batch ID
- View complete supply chain history
- Verify authenticity and quality information
- Access Admin Dashboard
- Monitor all batches and supply chain activity
- View analytics and statistics
- Manage system-wide operations
Backend (.env)
# Server
PORT=3001
NODE_ENV=development
# Blockchain
INFURA_URL=https://polygon-mumbai.infura.io/v3/YOUR_PROJECT_ID
CONTRACT_ADDRESS=0x...
PRIVATE_KEY=0x...
# Database
MONGODB_URI=mongodb://localhost:27017/cropchain
# Security
JWT_SECRET=your_secret_keySmart Contracts (hardhat.config.js)
networks: {
mumbai: {
url: process.env.INFURA_URL,
accounts: [process.env.PRIVATE_KEY]
}
}npm testcd backend
npm testnpx hardhat testnpm run build
# Deploy dist/ folder to your hosting providercd backend
# Configure environment variables on your platform
git push heroku main# Mumbai Testnet
npx hardhat run scripts/deploy.js --network mumbai
# Polygon Mainnet
npx hardhat run scripts/deploy.js --network polygon- Access Control: Role-based permissions in smart contracts
- Data Validation: Input sanitization and validation
- Rate Limiting: API rate limiting to prevent abuse
- CORS Protection: Configured CORS policies
- Environment Variables: Sensitive data protected via env vars
- Smart Contract Auditing: Comprehensive testing and validation
Frontend
- React 18 + TypeScript
- Tailwind CSS
- React Router
- Lucide React Icons
- QRCode.js
Backend
- Node.js + Express
- Ethers.js
- MongoDB + Mongoose
- JWT Authentication
- QRCode Generation
Blockchain
- Solidity ^0.8.19
- Hardhat Development Environment
- Ethereum/Polygon Networks
- OpenZeppelin Libraries
DevOps
- ESLint + Prettier
- Husky Git Hooks
- GitHub Actions CI/CD
- Docker Support
- β Basic supply chain tracking
- β QR code generation and scanning
- β Multi-role interfaces
- β Admin dashboard
- π IoT Sensor Integration
- π Advanced analytics and reporting
- π Mobile app development
- π Multi-language support
- π AI-powered quality prediction
- π Carbon footprint tracking
- π Marketplace integration
- π Government compliance features
I welcome contributions!
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the Apache License 2.0- see the LICENSE file for further details.
- OpenZeppelin for smart contract libraries
- Infura/Alchemy for blockchain infrastructure
- The amazing open-source community
- Agricultural experts who provided domain knowledge
Built with β€οΈ for transparent agriculture and food safety
CropChain - Connecting farms to forks with blockchain transparency