agritech is a decentralized agricultural technology platform built on the Internet Computer (ICP) blockchain. It integrates smart canisters with a full-stack web application to provide secure, transparent, and role-based solutions for the agricultural supply chain. The platform includes OTP-based authentication using Twilio for SMS delivery, registration, and dedicated dashboards for farmers, distributors, and retailers, enabling streamlined farm produce management.
agritech/
├─ backend/ # Backend logic (Express + ICP integration)
│ ├─ .env # Environment variables (MongoDB, JWT, Twilio)
│ ├─ auth.js # OTP-based authentication logic (Twilio, JWT, middleware)
│ ├─ canister-ids.js # Canister configuration
│ ├─ ic-agent.js # ICP agent setup
│ ├─ server.js # Express server entry point
│ ├─ node_modules/ # Node.js dependencies
│ ├─ package.json # Backend dependencies
│ └─ package-lock.json
├─ src/
│ ├─ agritech/ # Motoko backend canister source
│ │ └─ main.mo # Core canister logic in Motoko
│ ├─ agritech_assets/ # React frontend assets and logic
│ │ ├─ assets/
│ │ │ └─ main.css # Global styles
│ │ ├─ src/
│ │ │ ├─ components/ # Reusable React components
│ │ │ │ ├─ Home.jsx
│ │ │ │ ├─ Login.jsx
│ │ │ │ ├─ Register.jsx
│ │ │ │ ├─ RoleSelection.jsx
│ │ │ │ ├─ FarmerDashboard.jsx
│ │ │ │ ├─ DistributorDashboard.jsx
│ │ │ │ └─ RetailerDashboard.jsx
│ │ │ ├─ index.jsx # Frontend entry point
│ │ │ └─ index.html # Root HTML file
│ └─ dist/ # Production build output
├─ dfx/ # DFX configuration for ICP canisters
│ └─ dfx.json
├─ declarations/ # TypeScript or Candid declarations for ICP
├─ webpack.config.cjs # Webpack configuration
├─ tsconfig.json # TypeScript config
├─ .gitignore # Git ignore rules
└─ README.md # Project documentation
-
Frontend
- React.js (component-based UI)
- Webpack (bundling & asset management)
- CSS (global styles in
main.css)
-
Backend
- Node.js + Express.js (REST API & business logic)
- JWT (authentication & session handling)
- MongoDB Atlas (cloud database for users, roles, and produce)
- Twilio (SMS-based OTP authentication)
-
Blockchain / ICP
- Internet Computer (smart canister deployment)
- Motoko (smart contract development)
- DFX (deployment & local development tool)
git clone <repo-url>
cd agritech/cd backend/
npm install dotenv express cors mongoose jsonwebtoken twilioConfigure the .env file with the following:
MONGO_URI="mongodb+srv://<username>:<password>@<cluster>.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
JWT_SECRET="your_jwt_secret_key"
TWILIO_SID="your_twilio_account_sid"
TWILIO_AUTH_TOKEN="your_twilio_auth_token"
TWILIO_PHONE_NUMBER="your_twilio_phone_number"
Run the backend server:
node server.jsAccess backend at: http://localhost:3000
Note: Sign up for a Twilio account at twilio.com to obtain TWILIO_SID, TWILIO_AUTH_TOKEN, and TWILIO_PHONE_NUMBER. In trial mode, Twilio only sends SMS to verified phone numbers.
cd src/agritech_assets/
npm install
npm startAccess frontend at: http://localhost:8080
dfx start --background
dfx deployAfter deployment, get the asset_canister_id using:
dfx canister id agritech_assetsAccess the deployed canister app at:
http://localhost:8000?canisterId=<asset_canister_id>
- User Authentication – Secure OTP-based registration and login using Twilio for SMS delivery, authenticated with JWT.
- Role-Based Dashboards – Farmers, Distributors, and Retailers each have dedicated dashboards.
- Produce Management – Add, view, and manage agricultural produce.
- ICP Integration – Decentralized data storage and smart contracts via Motoko canisters.
- Scalable Architecture – Modular design with separation of frontend, backend, and blockchain layers.
- Twilio Configuration: Ensure Twilio credentials are correctly set in the
.envfile. Adjust the country code inauth.js(e.g.,+91for India) based on your target region. - MongoDB: Verify that your MongoDB Atlas connection string is correct and your IP is whitelisted.
- Security: OTPs are stored in-memory for simplicity. In production, use Redis or a database for secure OTP storage.
- Rate Limiting: Consider adding rate limiting to the OTP endpoints (e.g., using
express-rate-limit) to prevent abuse.



