# juiec/sentinel architecture

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

- Interactive diagram: https://gitdiagram.com/juiec/sentinel
- Repository: https://github.com/juiec/sentinel

## Overview

This repository combines a COCO hard-negative dataset workflow with a local vision-alert pipeline and a separate Sentinel chat web app. The README’s documented dataset path is selecting curated negatives, downloading images, and wiring them into YOLO training data. Sampled sources also show frame processing and alert logging, plus browser-to-server streamed chat. Some dataset utilities and vision internals are only partially sampled, so their connections are limited to documented or directly evidenced relationships.

Main entry points: [`public/js/app.js`](https://github.com/juiec/sentinel/blob/main/public/js/app.js) (Chat UI State), [`server.js`](https://github.com/juiec/sentinel/blob/main/server.js) (Chat Server), [`download_coco_negatives.py`](https://github.com/juiec/sentinel/blob/main/download_coco_negatives.py) (Negative Downloader), [`public/js/api.js`](https://github.com/juiec/sentinel/blob/main/public/js/api.js) (SSE Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dataset["Negative Dataset"]
  node_downloader["Negative Downloader"]
  node_dataset_merge["Dataset Merger<br/>[merge_datasets.py]"]
  node_empty_labels["Empty Label Creator"]
  node_yolo_train["YOLO Trainer<br/>[yolo26_train.py]"]
end

subgraph group_vision["Vision Alerts"]
  node_pipeline["Frame Pipeline<br/>[detection.py]"]
  node_alert_logs["Alert Payload Logger<br/>[backend.py]"]
end

subgraph group_chat["Chat Application"]
  node_web_app["Chat UI State<br/>[app.js]"]
  node_chat_render["Message Renderer<br/>[chat.js]"]
  node_chat_api["SSE Client<br/>[api.js]"]
  node_chat_server["Chat Server<br/>[server.js]"]
  node_history_store[("Browser Storage")]
end

node_trainer(("Dataset Maintainer"))
node_coco[("COCO Images")]
node_frames["Video Frames"]
node_browser_user(("Chat User"))
node_ai_service["OpenAI-Compatible API"]

node_trainer -->|"runs download"| node_downloader
node_coco -->|"provides images"| node_downloader
node_downloader -.->|"supplies negatives"| node_dataset_merge
node_trainer -->|"merges datasets"| node_dataset_merge
node_trainer -->|"creates labels"| node_empty_labels
node_trainer -->|"trains model"| node_yolo_train
node_frames -.->|"processes frames"| node_pipeline
node_pipeline -->|"writes alerts"| node_alert_logs
node_browser_user -->|"submits messages"| node_web_app
node_web_app -->|"renders messages"| node_chat_render
node_web_app -->|"streams chat"| node_chat_api
node_web_app -->|"persists history"| node_history_store
node_chat_api -->|"posts to /chat"| node_chat_server
node_chat_server -->|"requests completions"| node_ai_service
node_chat_server -->|"streams SSE"| node_chat_api

click node_downloader "https://github.com/juiec/sentinel/blob/main/download_coco_negatives.py"
click node_dataset_merge "https://github.com/juiec/sentinel/blob/main/merge_datasets.py"
click node_empty_labels "https://github.com/juiec/sentinel/blob/main/make_label_files.py"
click node_yolo_train "https://github.com/juiec/sentinel/blob/main/yolo26_train.py"
click node_pipeline "https://github.com/juiec/sentinel/blob/main/detection.py"
click node_alert_logs "https://github.com/juiec/sentinel/blob/main/backend.py"
click node_web_app "https://github.com/juiec/sentinel/blob/main/public/js/app.js"
click node_chat_render "https://github.com/juiec/sentinel/blob/main/public/js/chat.js"
click node_chat_api "https://github.com/juiec/sentinel/blob/main/public/js/api.js"
click node_chat_server "https://github.com/juiec/sentinel/blob/main/server.js"

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_downloader,node_dataset_merge,node_empty_labels,node_yolo_train,node_browser_user toneBlue
class node_pipeline,node_alert_logs,node_coco toneAmber
class node_web_app,node_chat_render,node_chat_api,node_chat_server,node_history_store,node_ai_service toneMint
class node_trainer,node_frames toneIndigo
```

## Components

### Negative Dataset

- [Negative Downloader](https://github.com/juiec/sentinel/blob/main/download_coco_negatives.py): `download_coco_negatives.py`
- [Dataset Merger](https://github.com/juiec/sentinel/blob/main/merge_datasets.py): `merge_datasets.py`
- [Empty Label Creator](https://github.com/juiec/sentinel/blob/main/make_label_files.py): `make_label_files.py`
- [YOLO Trainer](https://github.com/juiec/sentinel/blob/main/yolo26_train.py): `yolo26_train.py`

### Vision Alerts

- [Frame Pipeline](https://github.com/juiec/sentinel/blob/main/detection.py): `detection.py`
- [Alert Payload Logger](https://github.com/juiec/sentinel/blob/main/backend.py): `backend.py`

### Chat Application

- [Chat UI State](https://github.com/juiec/sentinel/blob/main/public/js/app.js): `public/js/app.js`
- [Message Renderer](https://github.com/juiec/sentinel/blob/main/public/js/chat.js): `public/js/chat.js`
- [SSE Client](https://github.com/juiec/sentinel/blob/main/public/js/api.js): `public/js/api.js`
- [Chat Server](https://github.com/juiec/sentinel/blob/main/server.js): `server.js`
- **Browser Storage**

### Other components

- **Dataset Maintainer**
- **COCO Images**
- **Video Frames**
- **Chat User**
- **OpenAI-Compatible API**

## Connections

- Dataset Maintainer → Negative Downloader: runs download (evidence: `README.md`)
- COCO Images → Negative Downloader: provides images (evidence: `README.md`)
- Negative Downloader → Dataset Merger: supplies negatives
- Dataset Maintainer → Dataset Merger: merges datasets (evidence: `merge_datasets.py`)
- Dataset Maintainer → Empty Label Creator: creates labels (evidence: `make_label_files.py`)
- Dataset Maintainer → YOLO Trainer: trains model (evidence: `yolo26_train.py`)
- Video Frames → Frame Pipeline: processes frames
- Frame Pipeline → Alert Payload Logger: writes alerts (evidence: `detection.py`)
- Chat User → Chat UI State: submits messages (evidence: `public/js/app.js`)
- Chat UI State → Message Renderer: renders messages (evidence: `public/js/app.js`)
- Chat UI State → SSE Client: streams chat (evidence: `public/js/app.js`)
- Chat UI State → Browser Storage: persists history (evidence: `public/js/app.js`)
- SSE Client → Chat Server: posts to /chat (evidence: `public/js/api.js`)
- Chat Server → OpenAI-Compatible API: requests completions (evidence: `server.js`)
- Chat Server → SSE Client: streams SSE (evidence: `server.js`)
