01Problem
What was broken
Farmers needed a fast, low-latency way to diagnose plant disease from a photo, without specialized agricultural equipment or reliable network access in rural areas.
02Impact
What it does now
A CNN trained on roughly 87,000 leaf images across 38 disease classes reaches about 95% accuracy on held-out images. The Next.js frontend never talks to the model directly; it goes through a proxy that keeps the FastAPI endpoint and its keys off the client.
03Architecture
How it is built
Training happens offline and produces a standard .h5 model file. In production, the Next.js server proxy holds the API keys and forwards requests to a FastAPI service running on Railway, which loads that Keras model into memory and serves inference from it.
Modules
- CNN Model Builder
- Vercel UI Proxy
- FastAPI Inference Node
- Heuristic Rejector
04Intelligence
Where the AI sits
A heuristic check rejects non-leaf images before inference runs, so a photo of a hand or a wall doesn't come back as a confident wrong diagnosis. A Gemini-powered companion then suggests organic treatment options for whatever gets identified.
05Decisions
Trade-offs I chose
- 01
Proxy Security Layer
The FastAPI endpoints and API keys never reach the browser. The Next.js API layer forwards multipart form data to Railway, so a client can't hit the inference endpoint directly or see what key it's using.
- 02
Single Source Data Pipeline
config.py and data_pipeline.py are the single source for preprocessing constraints, used both when the dataset gets compiled and when a live image gets validated. The same resize and normalization logic runs in training and production, so there's no drift between the two.
