A Django-based backend system for processing large CSV files and providing real-time analytics APIs.
- File Upload: Accept CSV files up to 3GB with instant task queuing
- Streaming Processing: Memory-efficient processing using Celery workers
- Analytics APIs: 7 comprehensive analytics endpoints
- Performance Tracking: Real-time metrics and progress monitoring
- Docker Support: Complete containerized setup
-
Clone and Setup
git clone <repo-url> cd analytic-engine cp .env.example .env
-
Run with Docker
docker-compose up --build
-
Initialize Database
docker-compose exec web python src/manage.py migrate -
Generate Test Data
python scripts/generate_test_data.py
POST /api/uploads/- Upload CSV fileGET /api/performance-stats/{task_id}/- Get processing metrics
GET /api/analytics/zone-leaderboard/- Top 20 zones by performanceGET /api/analytics/category-distribution/- Category percentage distributionGET /api/analytics/dormant-merchants/- Merchants with zero transactionsGET /api/analytics/hourly-pattern/- 24-hour activity patternGET /api/analytics/anomalies/- Transactions > 3 stddev above meanGET /api/analytics/customer-retention/- Repeat customer analysisGET /api/analytics/full-report/- Combined analytics report
- Django + Django Ninja: REST API framework
- MySQL: Primary database with optimized indexes
- Celery + Redis: Background task processing
- Streaming CSV Processing: Memory-efficient file handling
- Docker: Containerized deployment
| File Size | Records | Processing Time | Memory Usage | Throughput |
|---|---|---|---|---|
| 10MB | 100K | ~30s | ~50MB | 3.3K/s |
| 100MB | 1M | ~5min | ~80MB | 3.3K/s |
| 1GB | 10M | ~50min | ~100MB | 3.3K/s |
-
Local Setup
python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt
-
Run Services
# Terminal 1: Django python src/manage.py runserver # Terminal 2: Celery celery -A config worker --loglevel=info
Visit http://localhost:8000/api/docs/ for interactive Swagger documentation.
- Streaming CSV processing (never loads full file)
- Bulk database operations (1000 records per batch)
- Connection pooling
- Optimized database indexes
- 512MB Docker memory limit compliance