A modern, multi-page agricultural management system with real-time monitoring, market analysis powered by Groq AI, and comprehensive risk assessment.
- Dashboard - Overview with quick stats, storage facility status, and navigation to all sections
- Temperature Monitoring - 24-hour temperature trends with real-time data visualization
- Humidity Tracking - Humidity levels across all storage facilities with historical trends
- Market Analysis - AI-powered crop price analysis with county-based filtering and Groq AI insights
- Risk Assessment - Spoilage risk scoring with mitigation strategies and actionable recommendations
- Modern Color Palette: Purple primary (#262 80% 50%), golden accent (#39 89% 51%) with professional neutrals
- Responsive Layout: Mobile-first design with sidebar on desktop and bottom nav on mobile
- Gradient Backgrounds: Subtle gradients for visual depth and hierarchy
- Accessible Components: Built with shadcn/ui and Radix UI for accessibility
- Stable Market Data: Fixed crop prices to prevent random fluctuations
- Maize: 8,500 KES (trending up)
- Beans: 12,500 KES (trending down)
- Wheat: 15,000 KES (trending up)
- Rice & Sorghum with consistent pricing
- Real-time Polling: 10-second update intervals for sensor and market data
- AI-Powered Analysis: Groq AI market analysis with actionable recommendations
- County-Based Filtering: Market analysis filtered by county selection
- Framework: Next.js 16 with React 19
- UI Components: shadcn/ui with Tailwind CSS v4
- Charts: Recharts for data visualization
- AI Integration: Vercel AI SDK with Groq provider
- Icons: lucide-react for consistent iconography
- Node.js 18+
- GROQ_API_KEY environment variable (for market AI analysis)
# Install dependencies
pnpm install
# Set up environment variables
echo "RAX_API_KEY=your_rax_api_key_here" > .env.local
# Run development server
pnpm devOpen http://localhost:3000 to see the application.
app/
├── page.tsx # Dashboard overview
├── temperature/
│ └── page.tsx # Temperature monitoring
├── humidity/
│ └── page.tsx # Humidity tracking
├── market/
│ └── page.tsx # Market analysis with county filter
├── risk/
│ └── page.tsx # Risk assessment
├── api/
│ ├── sensors/route.ts # Sensor data endpoint
│ ├── market/route.ts # Market data endpoint
│ ├── risk/route.ts # Risk scoring endpoint
│ └── market-analysis/route.ts # AI market analysis
└── layout.tsx # Root layout with sidebar/mobile nav
components/
├── sidebar.tsx # Desktop navigation
├── mobile-nav.tsx # Mobile bottom navigation
├── ai-market-analysis.tsx # Groq AI analysis component
├── market-chart.tsx # Price comparison chart
├── temperature-chart.tsx # Temperature trend chart
├── market-table.tsx # Detailed market data
└── storage-card.tsx # Storage facility cards
lib/
└── mock-data.ts # Stable mock data generators
GET /api/sensors- Current temperature/humidity readingsGET /api/market?county=XX- Crop prices by countyGET /api/risk- Storage spoilage risk assessmentPOST /api/market-analysis- AI-powered market insights (Groq)
Market prices are now fixed to prevent random fluctuations:
const STABLE_PRICES = {
'Maize': { price: 8500, trend: 'up', change: 150 },
'Beans': { price: 12500, trend: 'down', change: -200 },
'Wheat': { price: 15000, trend: 'up', change: 250 },
// ...
}This ensures consistent data for farmers making informed decisions.
- Primary: Purple (#262 80% 50%) - Trust and growth
- Secondary: Light Purple (#263 80% 55%)
- Accent: Golden (#39 89% 51%) - Warmth and agriculture
- Success: Green (#142 72% 29%) - Low risk
- Warning: Amber (#39 89% 51%) - Medium risk
- Danger: Red (#0 84% 60%) - High risk
The Market Analysis page uses Groq AI to generate intelligent insights:
- Select a county to filter market data
- Click "Generate Analysis" button
- Groq AI analyzes crop prices and trends
- Provides recommendations: Buy/Hold/Sell for each crop
- Risk factors and optimal timing suggestions
GROQ_API_KEY=your_api_key_here
SENSOR_MODE=simulation
SUPABASE_URL=your_supabase_project_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_KEY=your_supabase_service_role_key
SENSOR_MODE values:
simulation: Generates location-aware virtual temperature/humidity readings every 10 seconds for demos.live: Reads real sensor rows from Supabase (sensor_readings).
- Hot module replacement (HMR) enabled
- TypeScript strict mode
- Automatic dependency installation with pnpm
- Responsive design tested on mobile, tablet, and desktop
Deploy to Vercel with one click:
pnpm run build
pnpm startMIT