# SecureCam codebase architecture

```mermaid
flowchart LR
  CAMERA["Camera device
  Mobile camera app / browser simulator"]:::client

  USER["User devices
  Web app / mobile app"]:::client

  subgraph PLATFORM["SecureCam platform"]
    BACKEND["Backend service
    • authentication
    • device coordination
    • live stream control
    • motion events
    • recordings access"]:::backend
  end

  DATA["Core data layer
  PostgreSQL"]:::data

  MEDIA["Media storage
  MinIO / S3-compatible object storage"]:::data

  NOTIFY["Notifications
  push + in-app activity updates"]:::service

  CAMERA -->|"motion, stream, recordings"| BACKEND
  USER -->|"auth, viewing, control"| BACKEND

  BACKEND -->|"app state, users, devices, events"| DATA
  BACKEND -->|"video and recording assets"| MEDIA
  BACKEND -->|"alerts and activity fan-out"| NOTIFY

  NOTIFY --> USER

  classDef client fill:#e8f1ff,stroke:#3b82f6,stroke-width:2px,color:#111827;
  classDef backend fill:#ecfdf3,stroke:#16a34a,stroke-width:2px,color:#111827;
  classDef data fill:#fff7e8,stroke:#f59e0b,stroke-width:2px,color:#111827;
  classDef service fill:#f3e8ff,stroke:#9333ea,stroke-width:2px,color:#111827;
```

## Notes

- This version is intentionally high level.
- It treats the web app, mobile app, and simulator as client surfaces around one backend platform.
- Internal backend modules such as routes, workers, realtime gateway, and media scaffolding are abstracted into a single service block.
