# Dr. Crop — AI Crop Disease Detection
A mobile-first Progressive Web App that identifies crop diseases from leaf photos and provides AI-powered treatment recommendations.
**Stack:** Next.js (App Router) · FastAPI · PyTorch · Exa AI · OpenAI · Apify
---
## Quick Start
### Prerequisites
- Node.js 18+
- Python 3.10+
- pip / venv
### 1. Clone & configure
```bash
cp .env.example .env
# Edit .env and add your API keys (optional — app works with fallback mocks)
```
### 2. Backend
```bash
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reload --port 8000
```
Backend runs at **
http://localhost:8000** — try
localhost for interactive API docs.
### 3. Frontend
```bash
cd frontend
npm install
cp .env.example .env.local
npm run dev
```
Frontend runs at **
http://localhost:3000**.
### 4. (Optional) Run both at once
```bash
./scripts/dev.sh
```
---
## Project Structure
```
dr-crop/
├── frontend/ # Next.js PWA
│ ├── src/
│ │ ├── app/ # App Router pages
│ │ ├── components/ # React components
│ │ ├── lib/ # Types, SW registration
│ │ └── services/ # API client
│ └── public/ # manifest.json, sw.js, icons
│
├── backend/ # FastAPI server
│ ├── app/
│ │ ├── main.py # App entrypoint
│ │ ├── config.py # Pydantic settings
│ │ ├── routes/ # /predict, /recommend
│ │ ├── services/ # Exa, LLM, Apify integrations
│ │ └── models/ # Pydantic schemas
│ └── ml/
│ ├── model_loader.py # Load PyTorch model
│ └── inference.py # Preprocessing + prediction
│
├── scripts/ # Dev helpers
├── .env.example
└── README.md
```
---
## API Endpoints
| Method | Path | Description |
| ------ | ------------ | ---------------------------------------- |
| POST …