How atharvk-28/amd-slingshot works
What this project is (type + purpose)
CrowdSense AI is a full-stack, real-time “computer vision → risk scoring → decision support dashboard” system.
• Frontend: React 18 (Vite) command-center UI that visualizes live telemetry (CPI, surge, chaos, routing) and likely renders dashboards and alerts.
• Backend: Python FastAPI “edge node” that runs the computer vision pipeline (OpenCV + Ultralytics YOLOv8), computes the risk metrics (CPI, ΔCPI, chaos multiplier), and streams processed outputs over WebSockets (JSON data and possibly video).
Architecturally, this is a real-time streaming system (not a request/response CRUD app): the important flows are continuous frames → inference → metrics → streaming → UI.
Read the repository structure as architecture hints
From the tree:
Top-level
• CMADS_App/frontend/ and CMADS_App/backend/ clearly indicate a two-tier system with a realtime channel between them.
• README.md explicitly confirms: *React command center* + *FastAPI WebSocket backend*.
• Deployment hints:
• frontend/vercel.json → frontend deploy target is Vercel.
• README mentions backend on Render.
Backend
• backend/main.py → likely contains:
• FastAPI app initialization
• WebSocket endpoint (e.g., /ws)
• CV pipeline loop and serialization to JSON
Frontend
• frontend/src/pages/* indicates UI “screens”:
• Dashboard.tsx → main telemetry view (charts, alerts)
• Login.tsx → implies auth might exist or is planned (include as optional/placeholder if it’s not wired end-to-end)
• Picker.tsx → might select camera feed / scenario / venue
• Recharts mentioned in README → indicates the dashboard consumes time-series metrics.
• .env.example and README variable VITE_WS_URL → explicit dependency: frontend must know the backend WebSocket URL.
Client-side (Browser)
• Operator / Public Safety Authority (human actor)
• React Command Center (Vite app)
• Pages: Dashboard, Architecture, Login, Picker
• Live telemetry charts (Recharts)
• Alert UI state (SURGE WARNING, Red Choke Point)
• Route visualization (A* output)
Backend (Edge Node / Server)
• FastAPI App
• WebSocket endpoint /ws (as per README env var)
• Any REST endpoints if present (unknown from tree; keep optional)
• Vision Pipeline Module (conceptual even if in one file)
• Video input capture (camera / file / RTSP—represent generically as “Video Source”)
• Preprocessing (OpenCV; canny/edges, frame differencing)
• YOLOv8 inference (Ultralytics + PyTorch)
• Optical Flow (Lucas-Kanade grid flow)
• Risk/Decision Engine
• CPI computation
• ΔCPI surge detection (rolling memory queue, 3-second threshold)
• Chaos Multiplier (std dev of movement angles)
• Choke point classification (“Red Zone”)
• Routing Engine
• A* pathfinding recomputation
• Output: recommended safe route(s)
External / Infrastructure
• Video Source (CCTV camera, drone feed, recorded video)
• Deployment
• Vercel hosting the frontend
• Render hosting the backend
• Hardware Acceleration (AMD EPYC / ROCm)
Frontend → Backend (WebSocket)
Even if not implemented, it’s a typical WebSocket bi-directional pattern; include if it matches your UI (Picker suggests it might).
Optional / “to confirm”
• Login/Auth:
• If Login.tsx is only UI, show it as “UI placeholder”.
• If auth exists (not visible here), add Auth Provider + token validation in backend.
Architectural patterns to emphasize (specific to this repo)
• Edge-first processing: inference and CV run on the backend close to the camera feed; only derived telemetry is streamed outward.
• Streaming/event-driven UI: WebSocket-driven updates powering charts and alerts.
Context (Level 1)
• Actor: Safety Operator
• System: CrowdSense AI
• External: CCTV/Camera Feed
• Hosting: Vercel (UI), Render/Edge Server (backend)
Container (Level 2)
• Browser: React App (Dashboard/Login/Picker)
• Backend: FastAPI App
• Link: WebSocket /ws
• Input: Video Source
• Compute: AMD ROCm acceleration under inference
Dynamic (Sequence)
Frontend updates charts + warnings + route overlay
Before finalizing, quickly open:
• backend/main.py:
• exact WebSocket path (/ws per README, confirm)
• whether backend also serves video frames or only JSON
• whether it ingests from webcam/rtsp/file
• message schema fields
• frontend/src/pages/Dashboard.tsx and Picker.tsx:
• confirm whether frontend sends messages to backend (bi-directional WS)
• frontend/.env.example:
• confirm env var names (likely VITE_WS_URL)