Every farmer's guide β from knowledge to prosperity
Rahnuma is an AI-powered agricultural platform designed to empower Pakistani farmers with intelligent guidance, smart irrigation planning, fertilizer optimization, energy tracking, and a blockchain-based marketplace. The platform supports Urdu and English languages to bridge the digital divide for farmers.
- Natural language conversations in Urdu and English
- Voice and text input support
- Instant answers to farming questions
- Weather information and market insights
- Available 24/7 for farmers
- Smart irrigation scheduling based on crop, soil, and weather data
- Water savings predictions and cost reduction estimates
- Weather integration for optimal watering decisions
- Daily reminder notifications
- Precise fertilizer recommendations based on crop and soil analysis
- Organic farming alternatives and tips
- Prevents overuse and chemical damage
- Cost-saving suggestions
- Monitor farm energy consumption (electricity and diesel)
- Track tube well and machinery usage
- Solar power recommendations with ROI calculations
- Efficiency optimization tips
- Transparent buying and selling of agricultural products
- Blockchain-based transaction records
- Direct farmer-to-buyer connections
- No middlemen, fair pricing
- Support for multiple roles: Farmers, Retailers, Distributors
- Next.js 15 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS 4 - Styling
- Framer Motion - Animations
- Radix UI - Accessible UI components
- React Hook Form - Form management
- Zod - Schema validation
- Next.js API Routes - Server-side endpoints
- PostgreSQL - Primary database
- Drizzle ORM - Database toolkit
- NextAuth.js v5 - Authentication (Google OAuth)
- AI SDK - AI integration framework
- Google Gemini AI - Primary AI model
- Groq - Fast AI inference
- Tavily - Web search for real-time information
- OpenWeather API - Weather data
- Hardhat - Smart contract development
- Ethers.js v6 - Ethereum interactions
- Polygon (Amoy testnet) - Blockchain network
- Solidity - Smart contract language
- Supabase Storage - Image uploads
- PostgreSQL - Relational database
- Node.js 20+ and pnpm 10+
- PostgreSQL database
- Google OAuth credentials
- API Keys: Google Gemini, Groq, Tavily, OpenWeather
- Blockchain: Polygon Amoy testnet (or mainnet) setup
git clone <repository-url>
cd rahnumapnpm installCreate a .env file in the root directory with the following variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/rahnuma"
# Authentication
AUTH_SECRET="your-auth-secret-key"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# AI Services
GOOGLE_GENERATIVE_AI_API_KEY="your-gemini-api-key"
GROQ_API_KEY="your-groq-api-key"
TAVILY_API_KEY="your-tavily-api-key"
# Weather API
NEXT_PUBLIC_OPENWEATHER_API_KEY="your-openweather-api-key"
# Supabase
NEXT_PUBLIC_SUPABASE_URL="your-supabase-url"
NEXT_PUBLIC_SUPABASE_ANON_KEY="your-supabase-anon-key"
NEXT_PUBLIC_BUCKET_NAME="your-bucket-name"
# Blockchain (Optional)
DEPLOYER_PRIVATE_KEY="your-deployer-private-key"
ALCHEMY_RPC_URL="https://polygon-amoy.g.alchemy.com/v2/your-key"
POLYGONSCAN_API_KEY="your-polygonscan-api-key"
WALLET_ENCRYPTION_KEY="your-wallet-encryption-key"
GAS_RELAYER_PRIVATE_KEY="your-gas-relayer-private-key"
# Contract Address (after deployment)
NEXT_PUBLIC_CONTRACT_ADDRESS="your-contract-address"
NEXT_PUBLIC_RPC_URL="your-rpc-url"
NEXT_PUBLIC_CHAIN_ID="80002" # Polygon Amoy testnet# Generate migration files
pnpm db:generate
# Push schema to database
pnpm db:push
# Or run migrations
pnpm db:migrate# Compile contracts
pnpm contracts:compile
# Deploy to Amoy testnet
pnpm contracts:deploy
# Deploy to Polygon mainnet
pnpm contracts:deploy:mainnetpnpm devThe application will be available at http://localhost:3000
pnpm dev- Start development server with Turbopackpnpm build- Build for productionpnpm start- Start production serverpnpm preview- Build and preview production build
pnpm lint- Run ESLintpnpm lint:fix- Fix ESLint errorspnpm typecheck- Run TypeScript type checkingpnpm format:check- Check code formattingpnpm format:write- Format code with Prettierpnpm check- Run lint and typecheck together
pnpm db:generate- Generate Drizzle migration filespnpm db:push- Push schema changes to databasepnpm db:migrate- Run database migrationspnpm db:studio- Open Drizzle Studio
pnpm contracts:compile- Compile Hardhat contractspnpm contracts:deploy- Deploy contracts to Amoy testnetpnpm contracts:deploy:mainnet- Deploy to Polygon mainnetpnpm contracts:verify- Verify contracts on Polygonscanpnpm generate-wallets- Generate custodial walletspnpm fund-gas-wallet- Fund the gas relayer wallet
rahnuma/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (dashboard)/ # Protected dashboard routes
β β β βββ energy-tracking/
β β β βββ fertilizer-optimizer/
β β β βββ marketplace/
β β β βββ water-management/
β β β βββ profile/
β β β βββ layout.tsx
β β βββ api/ # API routes
β β β βββ auth/
β β β βββ blockchain/
β β β βββ chat/
β β β βββ listings/
β β β βββ ...
β β βββ login/
β β βββ onboarding/
β β βββ layout.tsx
β β βββ page.tsx # Landing page
β βββ components/ # React components
β β βββ ai/ # AI chat components
β β βββ marketplace/ # Marketplace components
β β βββ ui/ # Reusable UI components
β β βββ ...
β βββ constants/ # Translation constants
β β βββ en.ts # English translations
β β βββ ur.ts # Urdu translations
β β βββ prompts.ts # AI prompts
β βββ contexts/ # React contexts
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility libraries
β β βββ services/ # Business logic services
β β βββ utils/ # Utility functions
β β βββ schemas/ # Zod schemas
β βββ server/ # Server-side code
β β βββ auth/ # Authentication config
β β βββ db/ # Database schema and config
β βββ styles/ # Global styles
β βββ types/ # TypeScript type definitions
βββ contracts/ # Solidity smart contracts
β βββ RahnumaMarketplace.sol
βββ drizzle/ # Database migration files
βββ scripts/ # Utility scripts
βββ public/ # Static assets
βββ hardhat.config.cjs # Hardhat configuration
βββ drizzle.config.ts # Drizzle configuration
βββ next.config.js # Next.js configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ package.json
Rahnuma supports bilingual interface:
- English - Full application support
- Urdu - Full application support with RTL layout
Users can switch between languages using the language selector in the header.
The platform uses NextAuth.js with Google OAuth for authentication. Users need to:
- Sign in with Google
- Select their role (Farmer, Retailer, or Distributor)
- Access platform features based on their role
- Next.js App Router - File-based routing with server and client components
- Server Components - For data fetching and SEO optimization
- Client Components - For interactivity and state management
- API Routes - RESTful API endpoints for backend operations
- Users - Authentication and user profiles
- Listings - Agricultural product listings
- Transactions - Purchase/sale transactions
- Supply Chain Events - Transaction lifecycle tracking
- Custodial Wallets - Server-managed wallets for users
- Gas Relayer - Platform pays for transaction fees
- Smart Contracts - Marketplace operations on-chain
- Polygon Network - Low-cost, fast transactions
- Set up PostgreSQL database (Supabase, Railway, or self-hosted)
- Configure environment variables for production
- Set up Supabase storage for image uploads
- Deploy smart contracts to Polygon network
- Configure domain and SSL certificates
pnpm build
pnpm startThis project is private and proprietary.
This is a private project. For contributions, please contact the project maintainers.
For support and inquiries, please contact through the platform's support channels.
Built with β€οΈ for Pakistani Farmers