How ksaikiran2004/tric works
1. Overall shape
This is a locally hosted, Flask-style real-time monitoring system. The repo is split into a Python backend that ingests/derives events and a browser frontend that renders the operator dashboard. The main runtime entrypoints appear to be app.py, run_tric.py, and backend/main.py.
2. User-facing layer
The frontend/ folder is a server-rendered UI with HTML templates plus vanilla JS/CSS. The JavaScript modules are split by concern: map loading, sensor rendering, alert panels, incident tables, video streaming, and path animation. The frontend is mostly a consumer of live state delivered from the backend via HTTP and WebSockets.
3. API and realtime transport
backend/api/routes.py and backend/api/demo_routes.py provide HTTP endpoints, while backend/api/websocket_manager.py handles push updates. This is the boundary where backend events are exposed to the dashboard, so it is the key integration point between state changes and UI updates.
4. Core orchestration
backend/orchestrator/alert_orchestrator.py and backend/orchestrator/event_manager.py are the coordination layer. They take incoming telemetry, detections, and confirmations, then decide when something becomes an alert or incident. Architecturally, this is the central “decision bus” between ingestion, tracking, and persistence.
5. Sensor and telemetry ingestion
The repo supports both real and synthetic sensor inputs. backend/simulation/ generates test nodes and trigger events, which is useful for offline validation; backend/api and backend/surveillance are the likely live ingress paths for actual telemetry and video-related events. The presence of data/sensors.json suggests sensor state/config is also persisted locally.
6. Video and vision pipeline
backend/surveillance/ handles camera/image capture, and backend/vision_processor.py plus backend/detection/yolo_inference.py run local object detection with the bundled yolov8s.pt model. backend/detection/detection_parser.py appears to normalize model output into domain events that the orchestrator can understand.
7. Tracking and movement reasoning
backend/tracking/ contains the path/direction/intrusion logic. path_builder.py, intrusion_tracker.py, and direction_classifier.py together turn raw detections into trajectories and movement classifications. This is the stage that converts “a detection happened” into “a target is moving along a path.”
8. Alert confirmation
backend/confirmation/ provides a multi-sensor confirmation step before escalation. multi_sensor_confirmation.py and alert_engine.py imply the system tries to reduce false positives by requiring corroboration across inputs before the orchestrator logs or broadcasts a higher-confidence alert.
9. Persistence and audit trail
Runtime records are stored under data/ as JSON snapshots: active_alerts.json, incidents.json, and sensors.json. backend/database_manager.py, backend/logging_system/incident_logger.py, and backend/logging_system/log_formatter.py suggest a lightweight local persistence/auditing layer rather than a separate database service. backend/utils/file_lock.py is important here because it indicates concurrent file writes are expected and guarded.
10. Domain model boundary
backend/models/ defines the shared data shapes for alerts, incidents, paths, and sensors. These model classes sit between the event-processing subsystems and the UI/persistence layers, giving the system a consistent schema for alerts, trajectories, and sensor state.
11. Geospatial and visualization assets
frontend/geo/border_line.geojson and the static assets under frontend/static/assets/ support map-based visualization and sensor icons. The README references offline map rendering and a 3D “holotable” view; in the repository, that visual layer is represented by the map and animation JS modules rather than a separate backend service.
12. Configuration and utilities
config/settings.py and backend/config.py centralize runtime settings, while backend/utils/ provides shared helpers for IDs, timestamps, geospatial math, and locking. These are supporting modules that reduce coupling across the ingestion, orchestration, and persistence code.
13. End-to-end data flow
The dominant flow is: sensor/video input or simulation event → parsing/detection → tracking/confirmation → alert orchestration → logging/persistence → WebSocket/HTTP update to the dashboard. The system is therefore event-driven, with the backend acting as the processing core and the frontend acting as a live operator display.
14. Operational boundary
The repository is designed as a self-contained local system with no obvious dependency on external cloud services in the code tree. That makes the main architectural constraint not network integration, but keeping realtime ingestion, file-based persistence, and frontend updates synchronized inside one air-gapped process boundary.
Main entry points: dashboard.html Dashboard · websocket_manager.py WebSocket mgr · database_manager.py DB manager · alert_orchestrator.py Alert orchestrator
Components 34
Entrypoints
Process launch points for the local monitoring system.
- app.py · Main Flask-style application bootstrap.
app.py - run_tric.py · Alternate runtime launcher for the system.
run_tric.py
Backend core
Event processing, orchestration, detection, tracking, and persistence.
- backend/main.py · Backend process entrypoint and runtime wiring.
backend/main.py - API routes · Primary HTTP endpoints for dashboard and system interaction.
backend/api/routes.py - Demo routes · Supplementary demo or testing endpoints.
backend/api/demo_routes.py - WebSocket mgr · Pushes live state updates to the browser frontend.
backend/api/websocket_manager.py - Event manager · Central event coordination and dispatch.
backend/orchestrator/event_manager.py - Alert orchestrator · Turns tracked events into alerts and incidents.
backend/orchestrator/alert_orchestrator.py - Alert engine · Escalation logic for alerts based on corroboration.
backend/confirmation/alert_engine.py - Multi-sensor confirm · Requires multiple inputs before confirming an alert.
backend/confirmation/multi_sensor_confirmation.py - Vision processor · Coordinates camera frames and detection processing.
backend/vision_processor.py - YOLO inference · Runs local object detection using the bundled model.
backend/detection/yolo_inference.py - Detection parser · Converts model output into domain events.
backend/detection/detection_parser.py - Path builder · Builds movement paths from detections.
backend/tracking/path_builder.py - Intrusion tracker · Tracks intrusion state over time.
backend/tracking/intrusion_tracker.py - Direction classifier · Infers movement direction from tracks.
backend/tracking/direction_classifier.py - DB manager · Manages local file-backed runtime state.
backend/database_manager.py - Incident logger · Formats and records incident history.
backend/logging_system/incident_logger.py - Simulation ctl · Drives offline simulation runs.
backend/simulation/simulation_controller.py - Sensor generator · Creates simulated sensor nodes and events.
backend/simulation/sensor_generator.py - Trigger engine · Emits synthetic trigger sequences.
backend/simulation/sensor_trigger_engine.py
Frontend UI
Dashboard templates and browser-side rendering modules.
- Dashboard · Main operator dashboard template.
frontend/templates/dashboard.html - Index · Landing or shell template.
frontend/templates/index.html - Alert panel · Renders active alerts and notifications.
frontend/static/js/alert_panel.js - Incident table · Displays incident records and history.
frontend/static/js/incident_table.js - Map loader · Initializes map and geospatial layers.
frontend/static/js/map_loader.js - Sensor renderer · Draws sensor state on the dashboard.
frontend/static/js/sensor_renderer.js - Path animator · Animates tracked movement paths.
frontend/static/js/path_animator.js - Video streamer · Handles live video playback in the browser.
frontend/static/js/video_streamer.js - Holotable · Supports alternate 3D-style visualization.
frontend/static/js/holotable.js
State & assets
Local JSON state and visualization assets used by the system.
- Active alerts · Current alert snapshot.
data/active_alerts.json - Incidents · Persisted incident history.
data/incidents.json - Sensors · Local sensor registry and state.
data/sensors.json - Border geo · Geospatial boundary used by the map view.
frontend/geo/border_line.geojson
Connections 40
- app.py → API routes: serves · Application bootstrap exposes the primary HTTP API.
- app.py → Dashboard: renders · Main app serves the operator dashboard template.
- run_tric.py → backend/main.py: launches · Alternate launcher starts backend runtime.
- backend/main.py → Event manager: starts · Backend runtime initializes event coordination.
- API routes → WebSocket mgr: updates · HTTP actions trigger live push updates.
- Demo routes → Simulation ctl: drives · Demo endpoints can exercise synthetic scenarios.
- Vision processor → YOLO inference: invokes · Frames are passed into the local detector.
- YOLO inference → Detection parser: emits · Model output is normalized into domain events.
- Detection parser → Path builder: feeds · Parsed detections enter movement reasoning.
- Path builder → Direction classifier: classifies · Built paths are classified by direction.
- Path builder → Intrusion tracker: tracks · Trajectory data updates intrusion state.
- Intrusion tracker → Multi-sensor confirm: correlates · Tracking output is checked against other sensors.
- Multi-sensor confirm → Alert engine: confirms · Cross-sensor confirmation raises confidence.
- Alert engine → Alert orchestrator: escalates · Confirmed alerts are handed to orchestration.
- Event manager → Alert orchestrator: dispatches · Central event bus routes telemetry to decision logic.
- Alert orchestrator → DB manager: persists · Alerts and incidents are stored locally.
- Alert orchestrator → Incident logger: logs · Orchestrator records incident audit entries.
- DB manager → Active alerts: writes · Active alert snapshots are file-backed.
- DB manager → Incidents: writes · Incident history is file-backed.
- DB manager → Sensors: reads · Sensor configuration/state is loaded from local JSON.
- Incident logger → Incidents: appends · Logging layer contributes to incident history.
- Simulation ctl → Sensor generator: creates · Simulation controller builds synthetic sensor data.
- Sensor generator → Trigger engine: triggers · Generated sensors feed trigger sequences.
- Trigger engine → Event manager: injects · Synthetic events enter the same coordination path as live data.
- API routes → Dashboard: serves · Routes return the main dashboard UI.
- Dashboard → Map loader: loads · Dashboard includes map initialization code.
- Dashboard → Sensor renderer: loads · Dashboard includes sensor rendering code.
- Dashboard → Alert panel: loads · Dashboard includes alert panel code.
- Dashboard → Incident table: loads · Dashboard includes incident table code.
- Dashboard → Path animator: loads · Dashboard includes path animation code.
- Dashboard → Video streamer: loads · Dashboard includes video playback code.
- Dashboard → Holotable: loads · Dashboard includes alternate visualization code.
- Map loader → Border geo: uses · Map layer uses local geospatial boundary data.
- Sensor renderer → Sensors: reads · Browser UI renders sensor state from backend-provided data.
- Alert panel → Active alerts: reads · Alert panel reflects current alert state.
- Incident table → Incidents: reads · Incident table displays historical incident records.
- WebSocket mgr → Alert panel: pushes · Realtime updates refresh the alert panel.
- WebSocket mgr → Sensor renderer: pushes · Realtime updates refresh sensor visuals.
- WebSocket mgr → Path animator: pushes · Realtime updates refresh path animation.
- WebSocket mgr → Video streamer: pushes · Realtime updates coordinate video playback state.