Enterprise multi-camera retail intelligence, loss prevention & store analytics platform.
SmartRetail AI converts existing CCTV infrastructure into an explainable, event-aware retail analytics system — understanding people, products, shelves, carts, staff, checkout events, and camera relationships to surface store intelligence and loss-prevention decision support.
It is a decision-support and human-review platform. It never autonomously declares a person guilty: every alert is scored, explained with evidence (who, what, when, where, which camera, which product, why, how confident), and reviewed by a human operator.
Observe → Track → Associate → Understand → Score → Explain → Alert → Human Review → Learn
CCTV Cameras (RTSP / ONVIF / Files)
│
▼
┌──────────────────────┐ ┌──────────────────────┐
│ Video Ingestion │ │ Detection & │
│ (services/ │───────▶│ Tracking │
│ ingestion) │ │ (detection/tracking│
└──────────────────────┘ └──────────┬───────────┘
│
▼
┌──────────────────────────┐
│ Multi-Camera Tracking / │
│ Re-ID / Camera Handoff │
└──────────┬───────────────┘
│
▼
┌──────────────────────────┐
│ Event Understanding │
│ (events, product, │
│ interaction) │
└──────────┬───────────────┘
│
▼
┌──────────────────────────┐
│ Risk Engine │
│ (risk-engine) │
└──────────┬───────────────┘
│
▼
┌──────────────────────────┐
│ Dashboard / Alerting │
│ (frontend, notifications)│
└──────────────────────────┘
┌───────────────┬──────────────┬──────────────┬──────────────┐
│ PostgreSQL │ Redis │ Worker │ Analytics │
│ (persistence) │ (cache/bus) │ (async jobs)│ (aggregation)│
└───────────────┴──────────────┴──────────────┴──────────────┘
Event flow: detection → tracking → interaction → behavior → risk → alert.
| Path | What lives here |
|---|---|
apps/ |
Deployable applications: backend/ (FastAPI API), frontend/ (dashboard), worker/ (async jobs), ai-services/ (CV/ML inference). |
services/ |
Domain service packages: ingestion, detection, tracking, reid, product, interaction, events, risk-engine, analytics, notifications. |
models/ |
ML model artifacts: detection, tracking, reid, pose, action. |
datasets/ |
Data: raw, annotations, processed, splits. |
database/ |
migrations/ (Alembic) and seeds/. |
infrastructure/ |
docker/, kubernetes/ (stubbed until Phase 19), monitoring/. |
tests/ |
unit/, integration/, scenarios/, performance/. |
docs/ |
architecture/ (living overview), api/, models/, deployment/. |
scripts/ |
Dev/test/lint/migrate helpers (shell + PowerShell). |
Every folder above is self-documenting via its own README.md.
RELOAD flagRationale and the full decision record: docs/architecture/overview.md.
Prerequisites: Docker with Docker Compose (v2). For local (non-Docker) backend dev: Python 3.13+.
Clone the repo
git clone <repository-url> smartretail-ai
cd smartretail-ai
Copy the environment file
cp .env.example .env
Everything has sane defaults for local dev; edit if you want different ports
or credentials. .env is gitignored.
Start the stack
docker compose up --build
(or make up, or scripts/dev.ps1 / scripts/dev.sh.) This brings up:
localhost:5432 with a named volumelocalhost:6379Confirm the stack
curl http://localhost:8000/health
Expect a structured JSON body with each dependency reported individually:
{
"status": "ok",
"service": "SmartRetail AI Backend",
"version": "0.1.0",
"checks": {
"database": "ok",
"redis": "ok"
},
"timestamp": "..."
}
curl http://localhost:8000/version reports the running git commit and build
tag — useful once multiple services are deployed independently.
Run the test suite
python -m venv .venv
.venv/Scripts/pip install -r apps/backend/requirements-dev.txt # PowerShell
# or: make install
.venv/Scripts/python -m pytest # PowerShell
# or: make test (or scripts/test.ps1 / scripts/test.sh)
Lint: make lint (or scripts/lint.ps1 / scripts/lint.sh).
Migrations: make migrate (or scripts/migrate.ps1 / scripts/migrate.sh).
| Task | Command |
|---|---|
| Start stack | docker compose up --build / make up |
| Stop stack | docker compose down |
| Tail logs | docker compose logs -f |
| Tests | make test |
| Lint | make lint |
| Format | make format |
| Migrate | make migrate |
BACKEND_PORT, POSTGRES_PORT, REDIS_PORT
in .env./health shows degraded — the backend is up but cannot reach a
dependency; check docker compose ps and the per-dependency checks fields.database/migrations/ (Alembic). There are no
revisions yet; they arrive with Phase 2.All 10 Specification Roadmap Phases (spec §100; engineering phases 1-21 in docs) are complete and verified end-to-end:
Run the complete multi-camera scenario from spec §101:
# Standalone CLI execution
python scripts/run_demo_scenario.py
# Or: make demo / scripts/run_demo.ps1 / scripts/run_demo.sh
# To execute and persist all live entities directly into PostgreSQL:
python scripts/run_demo_scenario.py --persist-db
make dev (or uvicorn app.main:app) then open:
# Run unit tests
pytest tests/unit
# Run end-to-end scenario tests
pytest tests/scenarios
# Run performance and throughput benchmarks
pytest tests/performance
# Run all test suites
pytest
Integration tests run against \smartretail_v3\ by default (see conftest.py). The reset path uses ordered DELETE — do NOT reintroduce TRUNCATE … CASCADE (wedges indefinitely on PostgreSQL 18 under this workload).