# phoenix1854/ai-detector-videos-extention architecture

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

- Interactive diagram: https://gitdiagram.com/phoenix1854/ai-detector-videos-extention
- Repository: https://github.com/phoenix1854/ai-detector-videos-extention

## Overview

The product is a browser extension backed by a local Flask service that classifies videos from their URLs. Its main workflow detects supported video-page URLs, downloads a video, samples frames for model inference, and displays the returned verdict. The source shows the API and inference implementation; broader platform support is documented in the README.

Main entry points: [`extention-server/backend/app.py`](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/app.py) (Flask API), [`extention-server/backend/detector_logic.py`](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py) (Model Loading), [`extention-server/frontend/content.js`](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.js) (URL Detection and Overlay), [`extention-server/frontend/content.css`](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.css) (Overlay Styles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Browser Extension"]
  node_content_script["URL Detection and Overlay<br/>[content.js]"]
  node_page_styles["Overlay Styles<br/>[content.css]"]
end

subgraph group_backend["API and Download"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_yt_dlp["yt-dlp Downloader"]
  node_temp_video["Temporary Video<br/>[app.py]"]
end

subgraph group_inference["Video Inference"]
  node_model_setup["Model Loading<br/>[detector_logic.py]"]
  node_clip_model["CLIP Image Encoder<br/>[detector_logic.py]"]
  node_clip_processor["CLIP Processor<br/>[detector_logic.py]"]
  node_classifier["MLP Classifier<br/>[detector_logic.py]"]
  node_classifier_weights["Classifier Weights"]
  node_video_analysis["Video Analysis<br/>[detector_logic.py]"]
  node_frame_sampling["Frame Sampling<br/>[detector_logic.py]"]
  node_frame_inference["Frame Inference<br/>[detector_logic.py]"]
  node_image_analysis["Image Analysis<br/>[detector_logic.py]"]
  node_verdict["Aggregated Verdict<br/>[detector_logic.py]"]
end

node_video_page(("Video Page"))

node_video_page -->|"exposes URL"| node_content_script
node_content_script -->|"POSTs URL"| node_flask_api
node_flask_api -->|"downloads video"| node_yt_dlp
node_yt_dlp -->|"writes file"| node_temp_video
node_flask_api -->|"processes file"| node_video_analysis
node_flask_api -->|"loads at startup"| node_model_setup
node_model_setup -->|"reads weights"| node_classifier_weights
node_model_setup -->|"loads model"| node_clip_model
node_model_setup -->|"loads processor"| node_clip_processor
node_model_setup -->|"creates classifier"| node_classifier
node_video_analysis -->|"samples frames"| node_frame_sampling
node_frame_sampling -->|"infers on frames"| node_frame_inference
node_frame_inference -->|"prepares images"| node_clip_processor
node_frame_inference -->|"extracts features"| node_clip_model
node_frame_inference -->|"scores features"| node_classifier
node_video_analysis -->|"aggregates scores"| node_verdict
node_flask_api -->|"returns JSON"| node_content_script
node_content_script -->|"styles overlay"| node_page_styles

click node_content_script "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.js"
click node_page_styles "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.css"
click node_flask_api "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/app.py"
click node_temp_video "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/app.py"
click node_model_setup "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_clip_model "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_clip_processor "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_classifier "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_classifier_weights "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/best_nn_classifier_FINAL.pth"
click node_video_analysis "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_frame_sampling "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_frame_inference "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_image_analysis "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py"
click node_verdict "https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.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_content_script,node_page_styles toneBlue
class node_flask_api,node_yt_dlp,node_temp_video toneAmber
class node_model_setup,node_clip_model,node_clip_processor,node_classifier,node_classifier_weights,node_video_analysis,node_frame_sampling,node_frame_inference,node_image_analysis,node_verdict toneMint
class node_video_page toneIndigo
```

## Components

### Browser Extension

- [URL Detection and Overlay](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.js): `extention-server/frontend/content.js`
- [Overlay Styles](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/frontend/content.css): `extention-server/frontend/content.css`

### API and Download

- [Flask API](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/app.py): `extention-server/backend/app.py`
- **yt-dlp Downloader**
- [Temporary Video](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/app.py): `extention-server/backend/app.py`

### Video Inference

- [Model Loading](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [CLIP Image Encoder](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [CLIP Processor](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [MLP Classifier](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [Classifier Weights](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/best_nn_classifier_FINAL.pth): `extention-server/backend/best_nn_classifier_FINAL.pth`
- [Video Analysis](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [Frame Sampling](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [Frame Inference](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [Image Analysis](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`
- [Aggregated Verdict](https://github.com/phoenix1854/ai-detector-videos-extention/blob/main/extention-server/backend/detector_logic.py): `extention-server/backend/detector_logic.py`

### Other components

- **Video Page**

## Connections

- Video Page → URL Detection and Overlay: exposes URL
- URL Detection and Overlay → Flask API: POSTs URL
- Flask API → yt-dlp Downloader: downloads video
- yt-dlp Downloader → Temporary Video: writes file
- Flask API → Video Analysis: processes file
- Flask API → Model Loading: loads at startup
- Model Loading → Classifier Weights: reads weights
- Model Loading → CLIP Image Encoder: loads model
- Model Loading → CLIP Processor: loads processor
- Model Loading → MLP Classifier: creates classifier
- Video Analysis → Frame Sampling: samples frames
- Frame Sampling → Frame Inference: infers on frames
- Frame Inference → CLIP Processor: prepares images
- Frame Inference → CLIP Image Encoder: extracts features
- Frame Inference → MLP Classifier: scores features
- Video Analysis → Aggregated Verdict: aggregates scores
- Flask API → URL Detection and Overlay: returns JSON
- URL Detection and Overlay → Overlay Styles: styles overlay
