# amit0119/car-guard-ai architecture

> Architecture diagram of the GitHub repository amit0119/car-guard-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amit0119/car-guard-ai
- Repository: https://github.com/amit0119/car-guard-ai

## Overview

This repository implements a vehicle-security simulation: a browser-based 3D dashboard presents armed standby and distinct loitering, break-in, camera-tamper, tilt/relay, and owner-authentication scenarios. The browser captures webcam frames for backend liveness and tamper analysis, while alerting and remote-command flows connect the dashboard and backend to WhatsApp. Evidence is limited to the supplied excerpts and source index; several frontend scene-dispatch and subsystem relationships are therefore not shown.

Main entry points: [`backend/server.py`](https://github.com/amit0119/car-guard-ai/blob/main/backend/server.py) (Flask API), [`frontend/js/core.js`](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/core.js) (Dashboard Runtime), [`frontend/js/scenes/scene5_tamper.js`](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene5_tamper.js) (Optical Tamper), [`backend/telegram_bot.py`](https://github.com/amit0119/car-guard-ai/blob/main/backend/telegram_bot.py) (WhatsApp Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["3D Dashboard"]
  node_browser["Dashboard Runtime<br/>[core.js]"]
  node_vehicle["Vehicle Builder<br/>[carBuilder.js]"]
end

subgraph group_scenarios["Security Scenarios"]
  node_standby["Armed Standby<br/>[scene1_standby.js]"]
  node_loiter["Perimeter Loitering"]
  node_breakin["Window Break-In<br/>[scene3_breakin.js]"]
  node_cockpit["Owner Cockpit<br/>[scene4_cockpit.js]"]
  node_tamper["Optical Tamper<br/>[scene5_tamper.js]"]
  node_tilt["Tilt / Relay"]
end

subgraph group_backend["Backend Analysis"]
  node_api["Flask API<br/>[server.py]"]
  node_liveness["Face Liveness<br/>[ear_liveness.py]"]
  node_loiter_detector["Loitering Detector<br/>[yolo_loitering.py]"]
end

subgraph group_communications["Remote Communications"]
  node_messaging["WhatsApp Gateway<br/>[telegram_bot.py]"]
end

node_green_api["Green-API Service"]
node_webcam(("Laptop Webcam"))

node_cockpit -->|"posts frames"| node_api
node_tamper -->|"posts frames"| node_api
node_browser -->|"polls commands"| node_api
node_browser -->|"requests SOS"| node_api
node_webcam -->|"provides video"| node_cockpit
node_webcam -->|"provides video"| node_tamper
node_api -->|"processes frames"| node_liveness
node_api -->|"dispatches alerts"| node_messaging
node_messaging -->|"sends messages"| node_green_api
node_green_api -->|"supplies commands"| node_messaging
node_breakin -->|"dispatches SOS"| node_browser
node_tamper -->|"dispatches SOS"| node_browser
node_standby -->|"resets features"| node_vehicle
node_tilt -->|"animates tilt"| node_vehicle

click node_browser "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/core.js"
click node_vehicle "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/carBuilder.js"
click node_standby "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene1_standby.js"
click node_loiter "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene2_loitering.js"
click node_breakin "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene3_breakin.js"
click node_cockpit "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene4_cockpit.js"
click node_tamper "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene5_tamper.js"
click node_tilt "https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene6_tilt_relay.js"
click node_api "https://github.com/amit0119/car-guard-ai/blob/main/backend/server.py"
click node_liveness "https://github.com/amit0119/car-guard-ai/blob/main/backend/ear_liveness.py"
click node_loiter_detector "https://github.com/amit0119/car-guard-ai/blob/main/backend/yolo_loitering.py"
click node_messaging "https://github.com/amit0119/car-guard-ai/blob/main/backend/telegram_bot.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_vehicle toneBlue
class node_standby,node_loiter,node_breakin,node_cockpit,node_tamper,node_tilt toneAmber
class node_api,node_liveness,node_loiter_detector,node_green_api toneMint
class node_messaging toneRose
class node_webcam toneIndigo
```

## Components

### 3D Dashboard

- [Dashboard Runtime](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/core.js): `frontend/js/core.js`
- [Vehicle Builder](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/carBuilder.js): `frontend/js/carBuilder.js`

### Security Scenarios

- [Armed Standby](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene1_standby.js): `frontend/js/scenes/scene1_standby.js`
- [Perimeter Loitering](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene2_loitering.js): `frontend/js/scenes/scene2_loitering.js`
- [Window Break-In](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene3_breakin.js): `frontend/js/scenes/scene3_breakin.js`
- [Owner Cockpit](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene4_cockpit.js): `frontend/js/scenes/scene4_cockpit.js`
- [Optical Tamper](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene5_tamper.js): `frontend/js/scenes/scene5_tamper.js`
- [Tilt / Relay](https://github.com/amit0119/car-guard-ai/blob/main/frontend/js/scenes/scene6_tilt_relay.js): `frontend/js/scenes/scene6_tilt_relay.js`

### Backend Analysis

- [Flask API](https://github.com/amit0119/car-guard-ai/blob/main/backend/server.py): `backend/server.py`
- [Face Liveness](https://github.com/amit0119/car-guard-ai/blob/main/backend/ear_liveness.py): `backend/ear_liveness.py`
- [Loitering Detector](https://github.com/amit0119/car-guard-ai/blob/main/backend/yolo_loitering.py): `backend/yolo_loitering.py`

### Remote Communications

- [WhatsApp Gateway](https://github.com/amit0119/car-guard-ai/blob/main/backend/telegram_bot.py): `backend/telegram_bot.py`

### Other components

- **Green-API Service**
- **Laptop Webcam**

## Connections

- Owner Cockpit → Flask API: posts frames (evidence: `frontend/js/scenes/scene4_cockpit.js`)
- Optical Tamper → Flask API: posts frames (evidence: `frontend/js/scenes/scene5_tamper.js`)
- Dashboard Runtime → Flask API: polls commands (evidence: `frontend/js/core.js`)
- Dashboard Runtime → Flask API: requests SOS (evidence: `frontend/js/core.js`)
- Laptop Webcam → Owner Cockpit: provides video (evidence: `frontend/js/scenes/scene4_cockpit.js`)
- Laptop Webcam → Optical Tamper: provides video (evidence: `frontend/js/scenes/scene5_tamper.js`)
- Flask API → Face Liveness: processes frames (evidence: `backend/server.py`)
- Flask API → WhatsApp Gateway: dispatches alerts (evidence: `backend/server.py`)
- WhatsApp Gateway → Green-API Service: sends messages (evidence: `backend/telegram_bot.py`)
- Green-API Service → WhatsApp Gateway: supplies commands (evidence: `backend/telegram_bot.py`)
- Window Break-In → Dashboard Runtime: dispatches SOS (evidence: `frontend/js/scenes/scene3_breakin.js`)
- Optical Tamper → Dashboard Runtime: dispatches SOS (evidence: `frontend/js/scenes/scene5_tamper.js`)
- Armed Standby → Vehicle Builder: resets features (evidence: `frontend/js/scenes/scene1_standby.js`)
- Tilt / Relay → Vehicle Builder: animates tilt (evidence: `frontend/js/scenes/scene6_tilt_relay.js`)
