An API for potato price estimation in Kenya
# Potato Price API
A production-ready API for estimating potato prices in Kenya, integrating weather data, market dynamics, and economic factors.
## Features
- **JWT Authentication**: Secure API access with Bcrypt password hashing
- **Price Estimation**: Multi-factor algorithmic pricing with weather integration
- **Weather Integration**: OpenWeatherMap API integration for real-time weather data
- **Market Data**: Support for multiple markets with distance-weighted pricing
- **Celery Tasks**: Background processing for weather data fetching
- **Redis Caching**: High-performance caching and task queue
- **Database**: PostgreSQL with SQLAlchemy ORM and Alembic migrations
## Architecture
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Flask API │ │ Celery │ │ PostgreSQL │
│ (Gunicorn) │◄──►│ Workers │◄──►│ Database │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Redis Cache │ │ OpenWeather │ │ Docker │
│ & Queue │ │ API │ │ Compose │
└─────────────────┘ └─────────────────┘ └─────────────────┘
```
## Quick Start
### Prerequisites
- Docker and Docker Compose
- OpenWeatherMap API key (Get here)
### Setup
1. **Clone and configure**:
```bash
git clone
cd potato-price-api
cp .env.example .env
```
2. **Update environment variables**:
```bash
# Edit .env file with your values
JWT_SECRET=your-super-secret-jwt-key
SECRET_KEY=your-flask-secret-key
WEATHER_API_KEY=your-openweathermap-api-key
```
3. **Start the services**:
```bash
docker compose up --build
```
4. **Initialize database**:
```bash
# Run migrations
docker compose run --rm web flask db upgrade
# Seed with sample data
docker compose run --rm web python seed_data.py
```
## 📚 API Documentation …