# 5.3.7 Motion Events Notifications and Audit Trail

## Motion Event Lifecycle

```mermaid
flowchart TD
    Trigger[Manual trigger or browser motion detector]
    Start[/POST /events/motion/start/]
    Event[(events table)]
    Links[(device_links)]
    RT[Realtime motion:detected]
    Push[Queued push notification]
    End[/POST /events/:id/motion/end/]

    Trigger --> Start
    Start --> Event
    Start --> Links
    Links --> RT
    Links --> Push
    RT --> End
    Push --> End
    End --> Event
```

## Activity and Audit Flow

```mermaid
flowchart LR
    Camera[Camera Device]
    Event[(events)]
    Notif[(notifications)]
    Delivery[(notification_deliveries)]
    Audit[(audit_logs)]
    Client[Client Device]

    Camera --> Event
    Event --> Notif
    Event --> Delivery
    Event --> Audit
    Notif --> Client
    Delivery --> Client
```
