Phase 1 foundation for a production-grade factory safety platform built for Indian factories. This repo contains:
frontend/: Next.js 14 admin dashboard and worker-facing mobile complaint appbackend/: Flask API, Flask-SocketIO realtime alerts, Celery task stubs, and storage/auth service wiringdocker-compose.yml: local Redis, backend, and frontend setup
Implemented:
- Admin dashboard for incidents, employees, cameras, zones, alerts, media, reports, and settings
- Worker mobile flow for voice complaint submission with native-script language selector
- JWT auth skeleton with refresh token storage in Redis and cookie support
- Role-based access control, rate limiting, consistent API envelopes, soft deletes, audit logs
- Camera heartbeat endpoints, offline camera detection, phone camera registration token and QR generation
- Realtime high/critical alerts over WebSocket
- R2 presign service wiring with safe local fallback
- D1 and Redis service wrappers with development fallback paths
- Celery task enqueue flow for frame and audio jobs
Intentionally stubbed for Phase 2:
backend/app/services/ai_service.py- Actual frame analysis and audio processing task bodies
- AI analysis cards in incident detail UI
- Transcript, translation, and structured report results in report UI
- Copy environment examples if you want custom values.
- Start services:
docker compose up --build- Open:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:5000/api/v1/health
Backend:
cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python run.pyFrontend:
cd frontend
npm install
cp .env.example .env.local
npm run dev- Email:
admin@drishti.local - Password:
password123
Every API response follows:
{
"success": true,
"data": {},
"message": "",
"pagination": null
}- The Flask backend uses an in-memory fallback store in development when D1 is not configured, so the UI can still function locally.
- R2 upload and download flows rely on presigned URLs. Raw storage credentials are never intended for frontend use.
- Public and auth-sensitive endpoints are rate-limited.
- Most destructive actions are soft deletes. Super admin hard-delete flows are not implemented in Phase 1.
- The frontend includes fallback data so page rendering remains stable even if the backend is offline during design/development.
- Replace
ai_service.pystubs with Whisper, GPT-4o, YOLOv8, and Gemini integrations. - Persist all repositories to D1 instead of the in-memory fallback store.
- Move camera frame ingestion to a dedicated streaming/worker path.
- Add full file upload and playback flows around R2 presigned uploads in the frontend.
- Expand tests for auth, RBAC, media validation, and optimistic UI rollback paths.