CropDx is a field-first crop disease detection assistant. A farmer uploads a leaf photograph and receives a confidence-rated disease prediction, plain-language explanations, and practical next steps.
The product combines:
CropDx does not use a CNN or MobileNetV2 for its final inference pipeline.


The short reference video shows the current desktop and mobile preview states, including the voice-guide entry point and the photo-first diagnosis flow.
Download or watch the CropDx testing reference video
This is a visual reference, not a replacement for the API and browser test steps below.
The startup voice guide uses the browser/device speech engine and curated translations. It requires no paid AI credits or API key. Voice availability depends on the user’s browser and phone; the written guide remains available when no device voice is exposed.
React/Vite frontend
│
├── GET /api/health
├── GET /api/whop/status
├── POST /api/predict
└── POST /api/whop/checkout
│
Flask API
│
┌───────────┼────────────┐
│ │ │
SVM SQLite Whop proxy
inference database (server-side)
| Layer | Technology |
|---|---|
| Frontend | React, TypeScript, Vite, Tailwind utilities |
| Backend | Python, Flask, Flask-CORS |
| Image features | OpenCV, scikit-image, NumPy |
| Classifier | scikit-learn RBF SVM, StandardScaler |
| Data | SQLite |
| Training dataset | PlantVillage through TensorFlow Datasets |
| Billing | Whop hosted checkout through a Replit connection |
| Voice guide | Browser/device SpeechSynthesis API |
artifacts/crop-disease-app/
src/App.tsx Main product shell and Field Pass UI
src/components/LanguageAgent.tsx
Free multilingual voice guide
src/components/UploadView.tsx Photo upload and diagnosis flow
src/lib/api.ts Frontend API client and response types
backend/
app.py Flask application entry point
routes/predict.py Upload validation, inference, logging
routes/health.py Model and API health endpoints
routes/whop.py Whop status and checkout endpoints
model/features.py 113-feature image extractor
model/inference.py SVM/scaler/label loading and prediction
train_model.py CPU-friendly training pipeline
database/ SQLite schema and query helpers
svm_model.joblib Trained SVM artifact
scaler.joblib Feature scaler artifact
labels.json Class index ordering
docs/
screenshots/ Current desktop/mobile product images
videos/ Visual testing reference video
pnpm install
pip install -r backend/requirements.txt
cd backend
python app.py
The API listens on the workflow PORT (usually 8080 when started directly).
In Replit, the API workflow is already configured as:
cd /home/runner/workspace/backend && python app.py
From the project root:
pnpm --filter @workspace/crop-disease-app run dev
In Replit, select the Crop Disease Detection artifact in the preview dropdown.
GET /api/health
GET /api/healthz
Example:
curl http://localhost:80/api/health
Expected healthy response:
{
"status": "ok",
"model_loaded": true
}
POST /api/predict
Content-Type: multipart/form-data
Example:
curl -X POST http://localhost:80/api/predict \
-F "image=@/path/to/leaf.jpg" \
-F "crop_type=Tomato"
Successful responses include:
disease_nameconfidencedescriptionsymptomsrecommendations grouped by categoryThe API uses a 65% confidence threshold. Below that threshold, it recommends consulting an agricultural expert instead of returning treatment recommendations.
GET /api/whop/status
POST /api/whop/checkout
Whop checkout is intentionally fail-closed:
WHOP_COMPANY_ID and WHOP_PLAN_ID
are configured and the connected Whop account has the required company
permissions.python backend/train_model.py
Training:
StandardScaler.backend/svm_model.joblibbackend/scaler.joblibbackend/labels.jsonbackend/confusion_matrix.pngKeep the ordering in labels.json aligned with the trained classifier. If
classes are added or renamed, reseed the SQLite disease database.
Start the API once so the SQLite schema exists, then run:
python backend/seed_db.py
The seed operation is idempotent and creates plain-language recommendations in chemical, biological, cultural, and preventive categories.
python -m py_compile \
backend/app.py \
backend/model/inference.py \
backend/routes/predict.py \
backend/routes/whop.py
pnpm --filter @workspace/crop-disease-app run typecheck
git diff --check
curl http://localhost:80/api/health
curl http://localhost:80/api/whop/status
For an end-to-end prediction:
curl -X POST http://localhost:80/api/predict \
-F "image=@/path/to/leaf.jpg" \
-F "crop_type=Tomato"
docs/screenshots/.CropDx provides decision support, not a guaranteed agricultural diagnosis. Low-confidence results direct the farmer to an agricultural expert. Treatment recommendations should be reviewed against local extension guidance and product labels before use.
Add the project license before distributing the repository publicly.