Store Intelligence Backend is a FastAPI-based analytics platform for processing retail store events and generating actionable business insights.
The system supports:
- Event ingestion
- Store metrics computation
- Funnel analytics
- Heatmap analytics
- Anomaly detection
- Health monitoring
- Docker deployment
The project also includes a computer vision pipeline that processes CCTV footage, tracks visitors, and generates structured store events.
CCTV Videos
|
v
YOLOv8 Detection
|
v
Multi-Object Tracking
|
v
Event Generation
|
v
FastAPI Ingestion API
|
v
SQLite Database
|
+--------------------+
| |
v v
Analytics APIs Monitoring APIs
The complete system architecture is available in:
docs/architecture.png
- FastAPI
- SQLAlchemy
- SQLite
- Pydantic
- YOLOv8
- OpenCV
- Supervision
- Docker
- Docker Compose
project/
│
├── app/
│ ├── main.py
│ ├── ingestion.py
│ ├── metrics.py
│ ├── funnel.py
│ ├── heatmap.py
│ ├── anomalies.py
│ ├── health.py
│ ├── database.py
│ └── models.py
│
├── pipeline/
│ ├── detect.py
│ ├── detect_visual.py
│ ├── track_cam3.py
│ ├── generate_events_cam1.py
│ └── push_events.py
│
├── output/
│
├── docs/
│
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── README.md
python -m venv venvWindows PowerShell:
.\venv\Scripts\Activate.ps1pip install -r requirements.txtuvicorn app.main:app --reloadOpen:
http://127.0.0.1:8000/docs
Build and start:
docker compose up --buildOpen:
http://127.0.0.1:8000/docs
The detection pipeline converts CCTV footage into structured behavioural events.
python pipeline/detect.pypython pipeline/detect_visual.pypython pipeline/track_cam3.pypython pipeline/generate_events_cam1.pyGenerated events are saved at:
output/events.jsonl
First start the API:
docker compose up --buildThen in another terminal run:
python pipeline/push_events.pyThis sends events from:
output/events.jsonl
to:
POST /events/ingest
GET /health
Returns service health status and database connectivity.
POST /events/ingest
Stores incoming store events.
GET /stores/{store_id}/metrics
Returns:
- Total events
- Unique visitors
- Entries
- Exits
- Conversion rate
- Queue depth
- Average dwell time
- Abandonment rate
GET /stores/{store_id}/funnel
Returns visitor funnel metrics.
GET /stores/{store_id}/heatmap
Returns zone popularity information.
GET /stores/{store_id}/anomalies
Returns operational anomalies.
Processed Store:
STORE_001
Generated Analytics:
- Total Events: 64
- Unique Visitors: 20
- Entries: 20
- Exits: 18
- Heatmap Analytics across multiple store zones
- Automatic anomaly detection
- Visitor dwell-time computation
This submission includes:
- FastAPI backend services
- Event ingestion pipeline
- Store analytics APIs
- Funnel analytics
- Heatmap analytics
- Anomaly detection
- Health monitoring APIs
- SQLite persistence layer
- Dockerized deployment
- Computer vision event generation pipeline
- System design documentation
- Architecture diagram
The project includes automated unit tests for core analytics and monitoring functionality.
pytest5 tests passing
The test suite validates:
- Store metrics computation
- Unique visitor counting
- Staff exclusion logic
- Average dwell time calculations
- Queue depth extraction
- Conversion drop detection
- Billing queue spike detection
- Health monitoring endpoint
=================== test session starts ===================
collected 5 items
tests/test_anomalies.py .. [40%]
tests/test_health.py . [60%]
tests/test_metrics.py .. [100%]
==================== 5 passed ====================
The tests use isolated in-memory SQLite databases to ensure deterministic and repeatable execution without affecting production data.
- Multi-camera identity matching
- Queue estimation
- Real-time event streaming
- Interactive dashboard
- Advanced conversion analytics
- Product-level shopper journey analysis
Soumya Verma
B.Tech Final Year
Madan Mohan Malaviya University of Technology
Store Intelligence Assessment Submission