# ravikumarr1802/aiguardian architecture

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

- Interactive diagram: https://gitdiagram.com/ravikumarr1802/aiguardian
- Repository: https://github.com/ravikumarr1802/aiguardian

## Overview

AI Guardian is a Django moderation assistant: creators manage monitored videos and review comment statistics in a web dashboard, while comment-fetching commands retrieve YouTube comments, classify them, and store moderation outcomes. Human review and moderation actions can update comment status and feed the retraining queue; the dashboard also exposes per-video analytics and video management. The graph includes both web and command-line ingestion paths, reclassification, YouTube deletion, and model retraining. Some views and project configuration were only partially sampled, so unverified wiring is omitted.

Main entry points: [`comments/views.py`](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/views.py) (Dashboard and actions), [`comments/management/commands/fetch_all_comments.py`](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/fetch_all_comments.py) (Fetch all comments), [`comments/youtube_service.py`](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/youtube_service.py) (YouTube API client), [`comments/models.py`](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/models.py) (Video and comment records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_routes["Web routes<br/>[urls.py]"]
  node_views["Dashboard and actions<br/>[views.py]"]
  node_templates["Dashboard views"]
  node_video_context["Video context"]
end

subgraph group_moderation["Comment moderation"]
  node_ingest_all["Fetch all comments"]
  node_ingest_one["Fetch video comments<br/>[fetch_comments.py]"]
  node_reclassify["Reclassify video"]
  node_delete_command["Delete comment command<br/>[delete_comment.py]"]
  node_records[("Video and comment records<br/>[models.py]")]
  node_video_config["Fallback video list<br/>[video_config.py]"]
end

subgraph group_ml["Toxicity model"]
  node_review_queue["Retraining queue<br/>[retrain_queue.csv]"]
  node_inference["Toxicity inference<br/>[bert_infer.py]"]
  node_retrain["Model retraining<br/>[retrain_model.py]"]
end

subgraph group_integrations["External services"]
  node_youtube_service["YouTube API client<br/>[youtube_service.py]"]
  node_youtube{{"YouTube"}}
  node_hf_model{{"Hugging Face model"}}
end

node_creator(("Content creator"))
node_operator(("Command-line operator"))

node_creator -->|"uses dashboard"| node_routes
node_routes -->|"routes requests"| node_views
node_views -->|"renders pages"| node_templates
node_views -->|"reads and updates"| node_records
node_video_context -->|"reads videos"| node_records
node_video_context -->|"falls back to"| node_video_config
node_views -->|"dispatches fetch"| node_ingest_one
node_views -->|"appends labels"| node_review_queue
node_views -->|"runs retraining"| node_retrain
node_operator -->|"runs command"| node_ingest_all
node_operator -->|"runs command"| node_ingest_one
node_operator -->|"runs command"| node_reclassify
node_operator -->|"runs command"| node_delete_command
node_ingest_all -->|"stores comments"| node_records
node_ingest_all -->|"loads fallback list"| node_video_config
node_ingest_all -->|"gets API client"| node_youtube_service
node_ingest_all -->|"classifies comments"| node_inference
node_ingest_all -->|"queues reviews"| node_review_queue
node_ingest_one -->|"gets API client"| node_youtube_service
node_ingest_one -->|"stores comments"| node_records
node_ingest_one -->|"classifies comments"| node_inference
node_reclassify -->|"reads and updates"| node_records
node_reclassify -->|"reclassifies comments"| node_inference
node_reclassify -.->|"optionally gets client"| node_youtube_service
node_delete_command -->|"gets API client"| node_youtube_service
node_delete_command -->|"marks deleted"| node_records
node_views -->|"deletes comments"| node_youtube_service
node_youtube_service -->|"calls API"| node_youtube
node_inference -->|"loads classifier"| node_hf_model

click node_routes "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/urls.py"
click node_views "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/views.py"
click node_templates "https://github.com/ravikumarr1802/aiguardian/tree/main/comments/templates/comments"
click node_video_context "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/context_processors.py"
click node_ingest_all "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/fetch_all_comments.py"
click node_ingest_one "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/fetch_comments.py"
click node_reclassify "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/reclassify_video.py"
click node_delete_command "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/delete_comment.py"
click node_records "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/models.py"
click node_video_config "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/video_config.py"
click node_review_queue "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/retrain_queue.csv"
click node_inference "https://github.com/ravikumarr1802/aiguardian/blob/main/toxicity_models/transformers/bert_infer.py"
click node_retrain "https://github.com/ravikumarr1802/aiguardian/blob/main/toxicity_models/retrain_model.py"
click node_youtube_service "https://github.com/ravikumarr1802/aiguardian/blob/main/comments/youtube_service.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_routes,node_views,node_templates,node_video_context toneBlue
class node_ingest_all,node_ingest_one,node_reclassify,node_delete_command,node_records,node_video_config toneAmber
class node_review_queue,node_inference,node_retrain toneMint
class node_youtube_service,node_youtube,node_hf_model toneRose
class node_creator,node_operator toneIndigo
```

## Components

### Web application

- [Web routes](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/urls.py): `comments/urls.py`
- [Dashboard and actions](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/views.py): `comments/views.py`
- [Dashboard views](https://github.com/ravikumarr1802/aiguardian/tree/main/comments/templates/comments): `comments/templates/comments`
- [Video context](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/context_processors.py): `comments/context_processors.py`

### Comment moderation

- [Fetch all comments](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/fetch_all_comments.py): `comments/management/commands/fetch_all_comments.py`
- [Fetch video comments](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/fetch_comments.py): `comments/management/commands/fetch_comments.py`
- [Reclassify video](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/reclassify_video.py): `comments/management/commands/reclassify_video.py`
- [Delete comment command](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/management/commands/delete_comment.py): `comments/management/commands/delete_comment.py`
- [Video and comment records](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/models.py): `comments/models.py`
- [Fallback video list](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/video_config.py): `comments/video_config.py`

### Toxicity model

- [Retraining queue](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/retrain_queue.csv): `comments/retrain_queue.csv`
- [Toxicity inference](https://github.com/ravikumarr1802/aiguardian/blob/main/toxicity_models/transformers/bert_infer.py): `toxicity_models/transformers/bert_infer.py`
- [Model retraining](https://github.com/ravikumarr1802/aiguardian/blob/main/toxicity_models/retrain_model.py): `toxicity_models/retrain_model.py`

### External services

- [YouTube API client](https://github.com/ravikumarr1802/aiguardian/blob/main/comments/youtube_service.py): `comments/youtube_service.py`
- **YouTube**
- **Hugging Face model**

### Other components

- **Content creator**
- **Command-line operator**

## Connections

- Content creator → Web routes: uses dashboard (evidence: `README.md`)
- Web routes → Dashboard and actions: routes requests (evidence: `comments/urls.py`)
- Dashboard and actions → Dashboard views: renders pages (evidence: `comments/views.py`)
- Dashboard and actions → Video and comment records: reads and updates (evidence: `comments/views.py`)
- Video context → Video and comment records: reads videos (evidence: `comments/context_processors.py`)
- Video context → Fallback video list: falls back to (evidence: `comments/context_processors.py`)
- Dashboard and actions → Fetch video comments: dispatches fetch (evidence: `comments/views.py`)
- Dashboard and actions → Retraining queue: appends labels (evidence: `comments/views.py`)
- Dashboard and actions → Model retraining: runs retraining (evidence: `comments/views.py`)
- Command-line operator → Fetch all comments: runs command (evidence: `comments/management/commands/fetch_all_comments.py`)
- Command-line operator → Fetch video comments: runs command (evidence: `comments/management/commands/fetch_comments.py`)
- Command-line operator → Reclassify video: runs command (evidence: `comments/management/commands/reclassify_video.py`)
- Command-line operator → Delete comment command: runs command (evidence: `comments/management/commands/delete_comment.py`)
- Fetch all comments → Video and comment records: stores comments (evidence: `comments/management/commands/fetch_all_comments.py`)
- Fetch all comments → Fallback video list: loads fallback list (evidence: `comments/management/commands/fetch_all_comments.py`)
- Fetch all comments → YouTube API client: gets API client (evidence: `comments/management/commands/fetch_all_comments.py`)
- Fetch all comments → Toxicity inference: classifies comments (evidence: `comments/management/commands/fetch_all_comments.py`)
- Fetch all comments → Retraining queue: queues reviews (evidence: `comments/management/commands/fetch_all_comments.py`)
- Fetch video comments → YouTube API client: gets API client (evidence: `comments/management/commands/fetch_comments.py`)
- Fetch video comments → Video and comment records: stores comments (evidence: `comments/management/commands/fetch_comments.py`)
- Fetch video comments → Toxicity inference: classifies comments (evidence: `comments/management/commands/fetch_comments.py`)
- Reclassify video → Video and comment records: reads and updates (evidence: `comments/management/commands/reclassify_video.py`)
- Reclassify video → Toxicity inference: reclassifies comments (evidence: `comments/management/commands/reclassify_video.py`)
- Reclassify video → YouTube API client: optionally gets client (evidence: `comments/management/commands/reclassify_video.py`)
- Delete comment command → YouTube API client: gets API client (evidence: `comments/management/commands/delete_comment.py`)
- Delete comment command → Video and comment records: marks deleted (evidence: `comments/management/commands/delete_comment.py`)
- Dashboard and actions → YouTube API client: deletes comments (evidence: `comments/views.py`)
- YouTube API client → YouTube: calls API (evidence: `comments/youtube_service.py`)
- Toxicity inference → Hugging Face model: loads classifier (evidence: `toxicity_models/transformers/bert_infer.py`)
