# ven12345678/swim-secure-portfolio architecture

> Architecture diagram of the GitHub repository ven12345678/swim-secure-portfolio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ven12345678/swim-secure-portfolio
- Repository: https://github.com/ven12345678/swim-secure-portfolio

## Overview

SwimSecure is a live drowning-risk monitoring product: operators choose a local, uploaded, or remote camera feed; the dashboard streams frames to the backend, which detects and tracks swimmers, estimates risk, and returns results for alerts and incident review. Sessions, frame events, and operator feedback are persisted for the history dashboard. The README also documents configurable thresholds, QR-based remote streaming, and emergency dispatch/location selection. Several backend and UI excerpts are partial or unsampled, so uncertain internal wiring is omitted; the dispatch modal is shown as an operator-facing workflow, not a verified connection to emergency services.

Main entry points: [`backend/main.py`](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/main.py) (FastAPI stream API), [`frontend/src/app/page.tsx`](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/page.tsx) (Live dashboard), [`frontend/src/components/VideoProcessor.tsx`](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/VideoProcessor.tsx) (Video processor), [`backend/inference.py`](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/inference.py) (YOLO and LSTM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Live monitoring"]
  node_dashboard["Live dashboard<br/>[page.tsx]"]
  node_video["Video processor<br/>[VideoProcessor.tsx]"]
  node_camera_page["Remote camera page<br/>[page.tsx]"]
  node_api["FastAPI stream API<br/>[main.py]"]
  node_broadcast["Viewer broadcast<br/>[main.py]"]
end

subgraph group_analysis["Detection and risk"]
  node_inference["YOLO and LSTM<br/>[inference.py]"]
  node_yolo_weights["YOLO weights<br/>[yolo_best.pt]"]
  node_lstm_weights["LSTM weights<br/>[lstm_best_final.pt]"]
  node_tracker["Person tracker<br/>[tracker.py]"]
end

subgraph group_records["Incident records"]
  node_history["Session history<br/>[page.tsx]"]
  node_db_access["Async database access<br/>[database.py]"]
  node_orm["Session event feedback models<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_operator["Operator tools"]
  node_alerts["Alert system<br/>[AlertSystem.tsx]"]
  node_feedback["Alert feedback<br/>[page.tsx]"]
  node_dispatch["Emergency dispatch modal"]
  node_location["Location selector"]
end

node_operator(("Pool operator"))
node_mobile(("Mobile camera"))
node_geocoder(("OpenStreetMap geocoder"))

node_operator -->|"operates"| node_dashboard
node_mobile -->|"captures video"| node_camera_page
node_dashboard -->|"selects source"| node_video
node_video -->|"streams frames"| node_api
node_camera_page -.->|"streams frames"| node_api
node_api -->|"runs detection"| node_inference
node_api -->|"updates tracks"| node_tracker
node_api -->|"broadcasts results"| node_broadcast
node_broadcast -->|"sends remote results"| node_video
node_api -->|"returns results"| node_video
node_inference -->|"loads weights"| node_yolo_weights
node_inference -->|"loads weights"| node_lstm_weights
node_dashboard -->|"updates thresholds"| node_api
node_dashboard -->|"shows risk alerts"| node_alerts
node_alerts -->|"offers verdict"| node_feedback
node_feedback -->|"submits feedback"| node_api
node_dashboard -->|"opens dispatch"| node_dispatch
node_dispatch -->|"sets location"| node_location
node_location -->|"searches address"| node_geocoder
node_dashboard -->|"opens history"| node_history
node_history -->|"requests history"| node_api
node_api -->|"queries and persists"| node_db_access
node_db_access -->|"uses schema"| node_orm
node_db_access -->|"reads and writes"| node_postgres

click node_dashboard "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/page.tsx"
click node_video "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/VideoProcessor.tsx"
click node_camera_page "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/camera/page.tsx"
click node_api "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/main.py"
click node_broadcast "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/main.py"
click node_inference "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/inference.py"
click node_yolo_weights "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models/yolo_best.pt"
click node_lstm_weights "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models/lstm_best_final.pt"
click node_tracker "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/tracker.py"
click node_alerts "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/AlertSystem.tsx"
click node_feedback "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/page.tsx"
click node_dispatch "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/EmergencyDispatchModal.tsx"
click node_location "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/LocationSelector.tsx"
click node_history "https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/history/page.tsx"
click node_db_access "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/database.py"
click node_orm "https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models.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_dashboard,node_video,node_camera_page,node_api,node_broadcast toneBlue
class node_inference,node_yolo_weights,node_lstm_weights,node_tracker toneAmber
class node_history,node_db_access,node_orm,node_postgres toneMint
class node_alerts,node_feedback,node_dispatch,node_location toneRose
class node_operator,node_mobile,node_geocoder toneIndigo
```

## Components

### Live monitoring

- [Live dashboard](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Video processor](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/VideoProcessor.tsx): `frontend/src/components/VideoProcessor.tsx`
- [Remote camera page](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/camera/page.tsx): `frontend/src/app/camera/page.tsx`
- [FastAPI stream API](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/main.py): `backend/main.py`
- [Viewer broadcast](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/main.py): `backend/main.py`

### Detection and risk

- [YOLO and LSTM](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/inference.py): `backend/inference.py`
- [YOLO weights](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models/yolo_best.pt): `backend/models/yolo_best.pt`
- [LSTM weights](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models/lstm_best_final.pt): `backend/models/lstm_best_final.pt`
- [Person tracker](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/tracker.py): `backend/tracker.py`

### Incident records

- [Session history](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/history/page.tsx): `frontend/src/app/history/page.tsx`
- [Async database access](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/database.py): `backend/database.py`
- [Session event feedback models](https://github.com/ven12345678/swim-secure-portfolio/blob/main/backend/models.py): `backend/models.py`
- **PostgreSQL**

### Operator tools

- [Alert system](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/AlertSystem.tsx): `frontend/src/components/AlertSystem.tsx`
- [Alert feedback](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Emergency dispatch modal](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/EmergencyDispatchModal.tsx): `frontend/src/components/EmergencyDispatchModal.tsx`
- [Location selector](https://github.com/ven12345678/swim-secure-portfolio/blob/main/frontend/src/components/LocationSelector.tsx): `frontend/src/components/LocationSelector.tsx`

### Other components

- **Pool operator**
- **Mobile camera**
- **OpenStreetMap geocoder**

## Connections

- Pool operator → Live dashboard: operates
- Mobile camera → Remote camera page: captures video
- Live dashboard → Video processor: selects source
- Video processor → FastAPI stream API: streams frames
- Remote camera page → FastAPI stream API: streams frames
- FastAPI stream API → YOLO and LSTM: runs detection
- FastAPI stream API → Person tracker: updates tracks
- FastAPI stream API → Viewer broadcast: broadcasts results
- Viewer broadcast → Video processor: sends remote results
- FastAPI stream API → Video processor: returns results
- YOLO and LSTM → YOLO weights: loads weights
- YOLO and LSTM → LSTM weights: loads weights
- Live dashboard → FastAPI stream API: updates thresholds
- Live dashboard → Alert system: shows risk alerts
- Alert system → Alert feedback: offers verdict
- Alert feedback → FastAPI stream API: submits feedback
- Live dashboard → Emergency dispatch modal: opens dispatch
- Emergency dispatch modal → Location selector: sets location
- Location selector → OpenStreetMap geocoder: searches address
- Live dashboard → Session history: opens history
- Session history → FastAPI stream API: requests history
- FastAPI stream API → Async database access: queries and persists
- Async database access → Session event feedback models: uses schema
- Async database access → PostgreSQL: reads and writes
