A FastAPI application that generates uptime/downtime reports for restaurant stores based on polling data.
- Docker and Docker Compose
- 8GB+ RAM (for processing large datasets)
- Start the services:
docker-compose up -d- Load the data:
docker-compose exec app python scripts/load_data.py- Generate a report:
curl -X POST http://localhost:8000/api/v1/trigger_report- Check report status (use the report_id from step 3):
curl http://localhost:8000/api/v1/get_report/{report_id}POST /api/v1/trigger_report- Start report generationGET /api/v1/get_report/{report_id}- Get report status or download CSVGET /api/v1/stats- System statisticsGET /api/v1/health- Health checkGET /docs- API documentation
The system generates CSV reports with the following columns:
store_iduptime_last_hour(minutes)uptime_last_day(hours)uptime_last_week(hours)downtime_last_hour(minutes)downtime_last_day(hours)downtime_last_week(hours)
- Business Hours Filtering: Only counts uptime/downtime during store operating hours
- Timezone Support: Handles stores across different timezones with DST awareness
- Smart Interpolation: Extrapolates uptime/downtime from sparse polling data
- Background Processing: Report generation runs asynchronously via Celery
- Caching: Redis caching for improved performance on large datasets
- Batch Processing: Efficiently handles thousands of stores without memory issues
The system:
- Downloads store polling data, business hours, and timezone information
- Calculates uptime/downtime using business hours filtering
- Interpolates status between sparse polling observations
- Generates reports with metrics for last hour, day, and week
The application automatically downloads the official dataset from: https://storage.googleapis.com/hiring-problem-statements/store-monitoring-data.zip
Check if everything is working:
# Health check
curl http://localhost:8000/health
# System stats
curl http://localhost:8000/api/v1/stats
# Generate and download a report
REPORT_ID=$(curl -s -X POST http://localhost:8000/api/v1/trigger_report | jq -r .report_id)
curl http://localhost:8000/api/v1/get_report/$REPORT_ID- API: FastAPI server on port 8000
- Database: PostgreSQL for data storage
- Cache: Redis for performance
- Workers: Celery for background report generation
docker-compose down