Complete step-by-step guide to set up KisanAI for development.
Before starting, ensure you have:
-
Node.js 18+ - Download
node --version # Should be v18.0.0 or higher -
npm 9+ - Download
npm --version # Should be 9.0.0 or higher -
Git - Download
git --version
-
A Code Editor - VS Code recommended
-
MongoDB - Local or cloud instance
- Local: Download
- Cloud: MongoDB Atlas
git clone https://github.com/yourusername/KisanAI.git
cd KisanAInpm installcp .env.example .env.local
# Edit .env.local with your API keysnpm run devVisit: http://localhost:3000
# 1. Go to https://ai.google.dev/
# 2. Click "Get API Key"
# 3. Create new project
# 4. Copy API key
# 5. Add to .env.local:
NEXT_PUBLIC_GEMINI_API_KEY=your_key_here# 1. Sign up at https://elevenlabs.io/
# 2. Go to Profile β API Key
# 3. Copy API key
# 4. Add to .env.local:
ELEVENLABS_API_KEY=your_key_here# 1. Create account at https://www.mongodb.com/cloud/atlas
# 2. Create cluster
# 3. Get connection string
# 4. Add to .env.local:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/kisanai# 1. Sign up at https://openweathermap.org/
# 2. Get free API key
# 3. Add to .env.local:
WEATHER_API_KEY=your_key_hereCreate .env.local file:
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/kisanai
# Gemini AI
NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_key
GEMINI_MODEL=gemini-pro-vision
# Voice API
ELEVENLABS_API_KEY=your_elevenlabs_key
# Weather API
WEATHER_API_KEY=your_weather_key
# App Config
NEXT_PUBLIC_APP_URL=http://localhost:3000
NODE_ENV=developmentSee .env.example for all options.
npm testExpected output:
PASS src/__tests__/components/Header.test.jsx
PASS src/__tests__/pages/Home.test.jsx
...
Tests: X passed, Y total
npm run lintExpected: No errors
npm run buildExpected: Build completes successfully
npm run dev
# Server runs on http://localhost:3000
# Auto-reloads on file changes# Run all tests once
npm test
# Run in watch mode (re-run on changes)
npm run test:watch
# Generate coverage report
npm run test:coveragenpm run lintnpm run formatnpm run buildnpm startKisanAI/
βββ src/
β βββ app/ # Next.js pages
β β βββ page.jsx # Home page
β β βββ layout.jsx # Root layout
β β βββ api/ # API routes
β β βββ voice-assistant/ # Voice feature
β β βββ crop-analysis/ # Crop analysis
β β βββ weather/ # Weather feature
β β βββ market-prices/ # Market prices
β β βββ schemes/ # Government schemes
β β
β βββ components/ # React components
β β βββ ui/ # Reusable UI components
β β βββ layout/ # Layout components
β β βββ [features]/ # Feature components
β β
β βββ hooks/ # Custom hooks
β β βββ useSpeechRecognition.js
β β βββ useSpeechSynthesis.js
β β βββ [custom hooks]/
β β
β βββ lib/ # Utilities & libraries
β β βββ mongodb.ts # Database
β β βββ geminiTranslate.ts # AI
β β βββ [utilities]/
β β
β βββ types/ # TypeScript types
β βββ contexts/ # React contexts
β βββ data/ # Static data
β βββ __tests__/ # Tests
β
βββ public/ # Static files
βββ docs/ # Documentation
βββ .github/ # GitHub config
βββ package.json
βββ tsconfig.json
βββ tailwind.config.js
βββ jest.config.js
βββ next.config.js
- Strict mode enabled
- Path aliases configured:
@/*β./src/* - React JSX support
- Custom colors for farming theme
- Responsive design
- Dark mode support
- React Testing Library
- jsdom environment
- Coverage collection
- Next.js recommended rules
- TypeScript support
- Code quality checks
# Kill process on port 3000
# macOS/Linux:
lsof -ti:3000 | xargs kill -9
# Windows:
netstat -ano | findstr :3000
taskkill /PID [PID] /F
# Or use different port:
npm run dev -- -p 3001# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install# Check connection string in .env.local
# Verify MongoDB is running
# Test with MongoDB Compass
# If using local MongoDB:
mongod # Start MongoDB server
# If using MongoDB Atlas:
# - Check IP whitelist
# - Verify username/password
# - Check connection string format# Regenerate key at https://ai.google.dev/
# Ensure key is in .env.local
# Verify NEXT_PUBLIC_ prefix for client-side keys# Run tests with verbose output
npm test -- --verbose
# Run specific test file
npm test -- useSpeechRecognition.test.jsx
# Check for console errors
# Review test output for specific errors- Read CONTRIBUTING.md - Learn contribution process
- Check ARCHITECTURE.md - Understand codebase
- Review CODING_STANDARDS.md - Code style
- Find Good First Issues - Start contributing
- π Documentation
- π¬ GitHub Discussions
- π Report Issues
- π§ Email Support
Ready to start developing? Create your first PR!