How mounseflit/salamtyai works
Project type and purpose
• This is a full-stack real-time video analytics application for industrial safety.
• Frontend: React web dashboard & monitoring UI.
• Backend/API: Flask services for video processing, model inference, and data persistence.
• ML components: YOLOv8-based safety-gear detection & hand-gesture detection.
• Database: Firebase Firestore for incident logs and statistics.
• Edge integration: Raspberry Pi or camera feed for live video input.
File structure
• Top-level directories:
• Backend (legacy or auxiliary Flask code under Backend/)
• flask_api (primary Flask app: app.py, credentials, model.json)
• Frontend (React app: package.json, src/, public/)
• models (Python scripts & model artifacts for detection)
• Docs & images (project docs and assets)
• Configuration: requirements.txt, package.json, Firebase admin SDK JSON
• Patterns: Monolithic Flask API hosting multiple ML modules, React single-page app, integration via REST & WebSocket.
Key README insights
• Live video feed ingestion → ML inference → alerts & dashboard updates
• Tech stack: Python, OpenCV, TensorFlow, YOLOv8, Flask, React, Firebase, RaspberryPi
• Features: real-time detection, proactive alerts, historical statistics
a. Main components:
1. Video Source (Industrial cameras / Raspberry Pi sensor agent)
2. Edge Agent (optional Pi service sending frames to backend)
3. Flask API Server (flask_api/app.py)
– Authentication & Authorization (via Firebase Admin SDK)
– REST endpoints (e.g., /detect, /stats)
– WebSocket or Server-Sent Events for real-time updates
4. Model Inference Layer
– Safety Gear Detection (YOLOv8 model under models/)
– Hand Gesture Detection (hand_gesture scripts & saved_model)
5. Data Store
– Firebase Firestore (NoSQL) for incident logs, user data, statistics
6. Frontend React App
– Components: LoginPage, Dashboard (EventCard, GestureCard, Statistics, etc.), WebSocket client, UserContext
– Firebase SDK for auth & data sync
7. Notification Service (could be integrated in Flask API or a separate microservice)
– Push alerts (email, SMS, on-screen)
b. Relationships & interactions:
• Video Source → (HTTP or gRPC) → Flask API → Inference Layer →
• Results → Firestore (persist)
• Results → WebSocket → React UI (Dashboard)
• React UI ↔ REST API for user operations (login, fetch historical stats)
• Flask API ↔ Firebase Admin SDK for data writes/reads & auth
• Models loaded at API startup, invoked per frame/request
c. Architectural patterns & design principles:
• Layered architecture: Presentation (React), API (Flask), Business/Inference (ML models), Data (Firestore)
• Single-page application (SPA) frontend
• Monolithic service for inference; consider splitting inference into microservices if scaling needed
• Real-time data propagation via WebSocket or SSE
• External service integration (Firebase, camera hardware)
d. Key technologies & libraries:
• Flask (flask_api/app.py)
• TensorFlow / YOLOv8 (models/fire_detection_script.py, hand_gesture_detection.py)
• OpenCV (video frame capture/processing)
• React & react-scripts (Frontend/src)
• Firebase Admin SDK (Backend/ibm-safety-net-firebase-adminsdk.json)
• WebSocket client in React (Frontend/src/components/WebSocket.js)
• Frontend (blue)
• Backend/API (green)
• ML modules (orange)
• External services (grey)
Detail
• CRUD endpoint or WebSocket channel name if known (e.g., /api/detect, /api/stats).
• Model loading at API startup (e.g., “load_model('models/hand_gest/...')”).
• If using Raspberry Pi code for sensor integration, note that as an edge service.