LexVision is a multi-app traffic violation workflow for citizen submissions, police review, admin oversight, and ML-assisted evidence analysis. AI assists helmet, red-light, and white-line detection, but human police validation remains required before any enforcement action.
apps/citizen-portal: citizen-facing reporting and tracking UI onhttp://localhost:5173apps/police-dashboard: police review and ticketing UI onhttp://localhost:5174apps/admin-dashboard: admin analytics and rules UI onhttp://localhost:5175services/ml: FastAPI backend, worker logic, migrations, and ML integrations onhttp://localhost:8000packages/*: shared UI, types, and API client code
- Node.js 18+
pnpm- Python 3.10+
- PostgreSQL for the preferred backend database
Redis is not required for the current local demo flow. Inference tasks run through FastAPI background tasks.
pnpm installpython3 -m venv .venv
source .venv/bin/activate
pip install -r services/ml/requirements.txtcp services/ml/.env.example services/ml/.env
cp apps/citizen-portal/.env.example apps/citizen-portal/.env.localUpdate the copied files with real values or placeholders appropriate for your demo.
DATABASE_URL: PostgreSQL DSN or SQLite fallbackSECRET_KEY: required for stable JWT auth tokensROBOFLOW_API_KEY: required for live Roboflow inferenceROBOFLOW_HELMET_MODEL_IDROBOFLOW_RED_LIGHT_MODEL_IDROBOFLOW_WHITE_LINE_MODEL_IDHELMET_MODEL_PATH/ANPR_MODEL_PATH: optional local model overridesSMS_PROVIDERand provider-specificSMS_*variables when SMS delivery is enabled
VITE_API_BASE_URLVITE_ADMIN_DASHBOARD_URLVITE_POLICE_DASHBOARD_URL
Run migrations before starting the backend:
cd services/ml
PYTHONPATH="$(cd ../.. && pwd)" python3 -m alembic upgrade head
cd ../..Seed demo admin and police accounts if needed:
PYTHONPATH="$PWD" python3 services/ml/seed_users.pySeeded demo accounts:
- Admin:
admin@lexvision.com/admin123 - Police:
police@lexvision.com/police123
Citizen login uses email and password authentication.
cd services/ml
PYTHONPATH="$(cd ../.. && pwd)" python3 -m uvicorn api.server:app --host 127.0.0.1 --port 8000 --reloadRun each app from the repo root in a separate terminal:
pnpm dev:citizen
pnpm dev:police
pnpm dev:adminThe Vite configs are pinned to these ports:
- Citizen portal:
5173 - Police dashboard:
5174 - Admin dashboard:
5175
- Citizen and legacy reports are saved first, then queued into the in-process worker via FastAPI background tasks.
- The worker selects one violation model based on the claimed violation type:
helmet-> helmet modelred_light-> red-light modelwhite_line-> white-line model
- ANPR runs separately for plate extraction and does not choose the violation family.
- AI results are written to
inference_logsand surfaced to the police dashboard asai_summary. - Low-confidence or configuration-error paths remain in manual review; the system does not auto-validate reports or auto-issue fines.
pnpm --filter citizen-portal lint
pnpm --filter police-dashboard lint
pnpm --filter admin-dashboard lint
pnpm --filter citizen-portal build
pnpm --filter police-dashboard build
pnpm --filter admin-dashboard buildPYTHONPATH="$PWD" python3 -m pytest services/ml/tests -q
cd services/ml && PYTHONPATH="$(cd ../.. && pwd)" python3 -m alembic upgrade headUseful runtime endpoints:
GET /-> service bannerGET /health-> backend and queue-mode statusGET /docs-> FastAPI Swagger UI
- Start the backend and all three frontend apps.
- Log in to the citizen portal with email and password.
- Submit a citizen report with image evidence.
- Open the police dashboard and review the queued report plus AI summary.
- Validate or reject the report manually.
- Issue a ticket only after manual validation.
- Use the admin dashboard for analytics, audit logs, and fine rule management.
- Do not commit
.envfiles, local databases, virtual environments, or temp outputs. - The backend supports SQLite for quick demo use, but PostgreSQL is the preferred persistent database.
- The current health endpoint reports queue mode as
fastapi_background_tasks; Redis is not part of the active local execution path.