Ghana AI Hackathon 2025 Submission
A comprehensive AI-powered crop disease detection and community outbreak tracking system designed specifically for Ghanaian farmers. Sonu combines computer vision, geospatial analysis, and Progressive Web App (PWA) technology to create a national agricultural "immune system."
- π― Project Overview
- ποΈ System Architecture
- π Key Features
- π οΈ Technology Stack
- π± Application Structure
- π€ AI/ML Implementation
- πΊοΈ Community Outbreak Mapping
- π² PWA Implementation
- π Getting Started
- π Dataset & Model
- π¨ UI/UX Design
- π§ Development
- π Impact & Innovation
Sonu addresses critical challenges in Ghana's agricultural sector by providing:
- Instant Disease Detection: AI-powered analysis of crop photos with 96% accuracy
- Treatment Recommendations: Localized treatment plans with organic and chemical options
- Community Intelligence: Real-time outbreak mapping and early warning system
- Offline Capability: Full functionality without internet connectivity
- Farmer-Centric Design: Optimized for low-end smartphones and poor connectivity
- Beyond Detection: Complete treatment ecosystem, not just identification
- Community-Powered: Crowd-sourced outbreak data for preventive action
- Accessibility First: PWA design for universal smartphone access
- Local Context: Tailored for Ghana's agricultural ecosystem and farmer needs
graph TB
subgraph "Frontend Layer"
PWA[Progressive Web App]
UI[React Components]
SW[Service Worker]
end
subgraph "AI Processing Layer"
ONNX[ONNX Runtime Web]
MODEL[EfficientNet Model]
PROC[Image Preprocessing]
end
subgraph "Data Layer"
DISEASES[Disease Database]
TREATMENTS[Treatment Database]
OUTBREAKS[Outbreak Data]
end
subgraph "Geospatial Layer"
MAP[Leaflet Maps]
GPS[Location Services]
CLUSTER[Disease Clustering]
end
subgraph "Storage Layer"
CACHE[Browser Cache]
IDB[IndexedDB]
LOCAL[Local Storage]
end
PWA --> UI
UI --> ONNX
ONNX --> MODEL
MODEL --> PROC
UI --> DISEASES
UI --> TREATMENTS
UI --> MAP
MAP --> GPS
MAP --> CLUSTER
SW --> CACHE
SW --> IDB
UI --> LOCAL
class PWA,UI,SW frontend
class ONNX,MODEL,PROC ai
class DISEASES,TREATMENTS,OUTBREAKS data
class MAP,GPS,CLUSTER geo
class CACHE,IDB,LOCAL storage
- Image Capture: Camera/upload β Image preprocessing β ONNX model inference
- Disease Detection: Model output β Disease mapping β Treatment recommendations
- Community Data: Location services β Outbreak reporting β Geospatial clustering
- Offline Support: Service worker β Cache management β IndexedDB storage
-
πΈ Instant Disease Detection
- Camera integration with real-time capture
- Support for 4 major crops (Cassava, Maize, Tomato, Cashew)
- 22 disease types with 96% accuracy
- Batch processing for multiple images
-
π Treatment Advisory System
- Personalized treatment recommendations
- Organic vs chemical treatment options
- Cost estimation in Ghana Cedis (GHS)
- Safety warnings and precautions
-
πΊοΈ Community Outbreak Mapping
- Real-time disease outbreak visualization
- GPS-based location tracking
- Disease clustering and trend analysis
- Anonymous reporting system
-
π± Progressive Web App
- Installable on any smartphone
- Full offline functionality
- Push notifications for outbreaks
- Native app-like experience
- π€ AI Chat Assistant: Interactive guidance and support
- π Analytics Dashboard: Disease trends and statistics
- π₯ Educational Content: Treatment videos and tutorials
- π Multi-language Support: English and Twi (framework ready)
- Framework: Next.js 15 with App Router
- UI Library: React 19 with TypeScript
- Styling: Tailwind CSS with custom components
- Icons: Lucide React
- Animations: Framer Motion
- Runtime: ONNX Runtime Web
- Model: Fine-tuned EfficientNet on CCMT dataset
- Processing: Canvas API for image preprocessing
- Inference: Client-side model execution
- Service Worker: Custom caching strategies
- Storage: IndexedDB for offline data
- Manifest: Full PWA compliance
- Installation: Cross-platform support
- Maps: Leaflet.js with OpenStreetMap
- Location: Geolocation API
- Clustering: Custom outbreak detection algorithms
- Visualization: Interactive disease heatmaps
- Language: TypeScript for type safety
- Linting: ESLint with Next.js config
- Formatting: Prettier integration
- Build: Turbopack for fast development
Sonu-ai-frontend/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β β βββ location/ # Location services
β β βββ outbreaks/ # Outbreak data
β β βββ predictions/ # AI predictions
β β βββ report-outbreak/ # Outbreak reporting
β βββ map/ # Outbreak mapping page
β βββ scan/ # Disease detection page
β βββ layout.tsx # Root layout with PWA setup
β βββ page.tsx # Landing page
βββ components/ # React Components
β βββ common/ # Shared components
β βββ map/ # Map-related components
β βββ scan/ # Scanning components
β βββ ui/ # UI primitives
βββ lib/ # Utilities & Logic
β βββ constants/ # Disease & treatment data
β βββ types/ # TypeScript definitions
β βββ utils/ # Helper functions
βββ public/ # Static assets
β βββ icons/ # PWA icons
β βββ models/ # ONNX model files
β βββ manifest.json # PWA manifest
βββ CCMT Dataset/ # Training dataset
βββ Cashew/ # Cashew disease images
βββ Cassava/ # Cassava disease images
βββ Maize/ # Maize disease images
βββ Tomato/ # Tomato disease images
graph LR
INPUT[Image Input] --> PREP[Preprocessing]
PREP --> RESIZE[Resize 224x224]
RESIZE --> NORM[Normalization]
NORM --> MODEL[EfficientNet-B0]
MODEL --> SOFTMAX[Softmax Layer]
SOFTMAX --> OUTPUT[22 Disease Classes]
class INPUT input
class PREP,RESIZE,NORM process
class MODEL model
class SOFTMAX,OUTPUT output
The system supports 4 major crops with 22 disease classes:
Cashew (5 classes)
- Anthracnose, Gumosis, Healthy, Leaf Miner, Red Rust
Cassava (5 classes)
- Bacterial Blight, Brown Spot, Green Mite, Healthy, Mosaic
Maize (7 classes)
- Fall Armyworm, Grasshopper, Healthy, Leaf Beetle, Leaf Blight, Leaf Spot, Streak Virus
Tomato (5 classes)
- Healthy, Leaf Blight, Leaf Curl, Septoria Leaf Spot, Verticillium Wilt
- Accuracy: 96% on validation set
- Inference Time: <3 seconds on mobile devices
- Model Size: Optimized for web deployment
- Confidence Scoring: Probabilistic output with uncertainty handling
graph TB
subgraph "Data Collection"
REPORT[Disease Reports]
GPS[GPS Coordinates]
TIME[Timestamp]
end
subgraph "Processing"
CLUSTER[Clustering Algorithm]
FILTER[Temporal Filtering]
ANON[Anonymization]
end
subgraph "Visualization"
HEATMAP[Disease Heatmap]
MARKERS[Outbreak Markers]
STATS[Statistics Panel]
end
REPORT --> CLUSTER
GPS --> CLUSTER
TIME --> FILTER
CLUSTER --> ANON
FILTER --> HEATMAP
ANON --> MARKERS
MARKERS --> STATS
class REPORT,GPS,TIME collect
class CLUSTER,FILTER,ANON process
class HEATMAP,MARKERS,STATS visual
- Data Collection: Anonymous GPS coordinates with disease type
- Spatial Clustering: DBSCAN algorithm for outbreak identification
- Temporal Analysis: Time-series analysis for trend detection
- Risk Assessment: Severity scoring based on cluster density
- Early Warning: Automated alerts for high-risk areas
- π± Installable: Add to home screen on any device
- π Offline-First: Full functionality without internet
- β‘ Fast Loading: Service worker caching strategies
- π Push Notifications: Outbreak alerts and reminders
- π Background Sync: Data synchronization when online
// Cache-first for static assets
// Network-first for dynamic data
// Offline fallback for critical features- Android: Chrome install prompt or "Add to Home Screen"
- iOS: Safari "Add to Home Screen" option
- Desktop: Browser install prompt in address bar
- Node.js 18+ and npm/yarn
- Modern web browser with camera support
- HTTPS for PWA features (development:
npm run dev:ssl)
# Clone the repository
git clone https://github.com/your-username/Sonu-ai-frontend.git
cd Sonu-ai-frontend
# Install dependencies
npm install
# Generate PWA icons (choose one method)
npm run generate-icons
# OR use the browser-based generator
open public/generate-icons.html
# Start development server
npm run dev
# OR with HTTPS for PWA testing
npm run dev:sslnpm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run generate-icons # Generate PWA iconsCreate a .env.local file:
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_ENABLE_PWA=true- Total Images: 24,881 high-quality crop images
- Crops: Cashew, Cassava, Maize, Tomato
- Disease Classes: 22 different diseases + healthy classes
- Image Quality: Professional agricultural photography
- Annotations: Expert-verified disease labels
- Data Preprocessing: Image augmentation and normalization
- Model Architecture: EfficientNet-B0 fine-tuned for crop diseases
- Training Strategy: Transfer learning with frozen backbone
- Optimization: Quantization for web deployment
- Validation: Cross-validation with held-out test set
- Mobile-First: Optimized for smartphone usage
- High Contrast: Readable in bright sunlight
- Large Touch Targets: Easy one-handed operation
- Minimal Cognitive Load: Simple, intuitive interface
- Offline Indicators: Clear connectivity status
- Screen Reader Support: Semantic HTML and ARIA labels
- Keyboard Navigation: Full keyboard accessibility
- Color Contrast: WCAG 2.1 AA compliance
- Text Scaling: Responsive typography
- Voice Commands: Framework ready for voice input
- Color Palette: Green-focused agricultural theme
- Typography: Montserrat for headings, system fonts for body
- Icons: Lucide React icon library
- Animations: Subtle Framer Motion transitions
- Layout: CSS Grid and Flexbox for responsive design
// Type-safe disease detection
interface ScanResult {
id: string;
detectionResult: DetectionResult;
disease: Disease;
treatments: Treatment[];
recommendations: {
primary: Treatment;
alternatives: Treatment[];
prevention: string[];
};
}
// Component architecture
const ScanPage = () => {
const [scanResult, setScanResult] = useState<ScanResult | null>(null);
// ... component logic
};- CameraCapture: Camera integration with image preprocessing
- AIProcessor: ONNX model inference and result processing
- OutbreakMap: Interactive disease mapping with clustering
- TreatmentRecommendations: Personalized treatment advice
- PWAInstallPrompt: Cross-platform installation guidance
- Unit Tests: Component and utility function testing
- Integration Tests: API endpoint and workflow testing
- E2E Tests: Full user journey testing
- Performance Tests: Model inference and loading time tests
- PWA Tests: Offline functionality and installation tests
- Holistic Approach: Detection + Treatment + Prevention + Community
- Offline-First: Works in remote areas without internet
- Community Intelligence: Crowd-sourced outbreak detection
- Local Context: Designed specifically for Ghanaian agriculture
- Accessibility: No hardware requirements, works on any smartphone
- Individual Farmers: Instant disease diagnosis and treatment guidance
- Community Level: Early outbreak detection and prevention
- National Scale: Agricultural disease surveillance system
- Economic Benefits: Reduced crop losses and treatment costs
- Knowledge Transfer: Educational content and best practices
- Multi-Modal AI: Computer vision + geospatial analysis
- Progressive Enhancement: Works on any device, enhanced on modern browsers
- Privacy-Preserving: Anonymous data collection with local processing
- Scalable Architecture: Ready for national deployment
- Open Source Ready: Extensible for other regions and crops
- Voice Interface: Local language voice commands
- Weather Integration: Climate-based risk assessment
- Market Integration: Treatment cost optimization
- Extension Services: Integration with agricultural extension programs
- Research Platform: Data collection for agricultural research
Team: Mohammed Nuruddin Alhassan & Solomon Eshun
Category: Agriculture & Food Security
Technology: AI/ML, Computer Vision, PWA, Geospatial Analysis
Live Demo: https://sonu-ai.vercel.app
GitHub: https://github.com/soloeinsteinmit/Sonu-ai-frontend
Sonu - Protecting Ghana's crops, one photo at a time. πΎπ±π€