# sabtain-dev/multimodal-ai-content-detection-agent architecture

> Architecture diagram of the GitHub repository sabtain-dev/multimodal-ai-content-detection-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sabtain-dev/multimodal-ai-content-detection-agent
- Repository: https://github.com/sabtain-dev/multimodal-ai-content-detection-agent

## Overview

This repository implements a file-based agent for AI-content detection in text, images, and audio; video detection is planned. The user workflow starts with a file, routes by extension, then returns a unified modality-specific result. Text uses preprocessing, three sequential model runs, and majority voting; audio combines two model predictions with a threshold-based primary decision; image decisions use supplied scores rather than agent-run image inference. Edges reflect shown calls or documented routing; unsampled video behavior is not inferred.

Main entry points: [`src/agent/multimodal_agent.py`](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/agent/multimodal_agent.py) (Multimodal agent), [`src/detectors/text/ensemble.py`](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/ensemble.py) (Text ensemble), [`src/detectors/text/detector.py`](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/detector.py) (Text model detector), [`src/detectors/audio/ensemble.py`](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/ensemble.py) (Audio ensemble)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent routing"]
  node_agent["Multimodal agent"]
  node_router["Extension router<br/>[modality_router.py]"]
end

subgraph group_text["Text detection"]
  node_text_ensemble["Text ensemble<br/>[ensemble.py]"]
  node_text_detector["Text model detector<br/>[detector.py]"]
  node_text_preprocessing["Text preprocessing<br/>[preprocessing.py]"]
  node_text_schemas["Text result schemas<br/>[schemas.py]"]
end

subgraph group_image["Image detection"]
  node_image_adapter["Image detector adapter<br/>[image_detectors.py]"]
  node_image_ensemble["Image decision ensemble<br/>[ensemble.py]"]
  node_image_labels["Image label normalization"]
end

subgraph group_audio["Audio detection"]
  node_audio_ensemble["Audio ensemble<br/>[ensemble.py]"]
  node_audio_model["Audio model inference<br/>[audio_detectors.py]"]
  node_audio_labels["Audio label normalization"]
end

subgraph group_video["Video planned"]
  node_video_detector["Video detector<br/>[video_detectors.py]"]
  node_video_processor["Video processor<br/>[video_processor.py]"]
end

node_user(("File submitter"))

node_user -->|"submits file"| node_agent
node_agent -->|"detects modality"| node_router
node_agent -->|"runs text detection"| node_text_ensemble
node_agent -->|"requests score decision"| node_image_adapter
node_agent -->|"runs audio detection"| node_audio_ensemble
node_text_ensemble -->|"runs sequentially"| node_text_detector
node_text_detector -->|"cleans and chunks"| node_text_preprocessing
node_text_detector -->|"builds results"| node_text_schemas
node_text_ensemble -->|"builds ensemble result"| node_text_schemas
node_audio_ensemble -->|"runs both models"| node_audio_model
node_audio_model -->|"normalizes prediction"| node_audio_labels

click node_agent "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/agent/multimodal_agent.py"
click node_router "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/agent/modality_router.py"
click node_text_ensemble "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/ensemble.py"
click node_text_detector "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/detector.py"
click node_text_preprocessing "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/preprocessing.py"
click node_text_schemas "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/schemas.py"
click node_image_adapter "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/image_detectors.py"
click node_image_ensemble "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/ensemble.py"
click node_image_labels "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/label_normalization.py"
click node_audio_ensemble "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/ensemble.py"
click node_audio_model "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/audio_detectors.py"
click node_audio_labels "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/label_normalization.py"
click node_video_detector "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/video/video_detectors.py"
click node_video_processor "https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/video/video_processor.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_agent,node_router toneBlue
class node_text_ensemble,node_text_detector,node_text_preprocessing,node_text_schemas toneAmber
class node_image_adapter,node_image_ensemble,node_image_labels toneMint
class node_audio_ensemble,node_audio_model,node_audio_labels toneRose
class node_video_detector,node_video_processor,node_user toneIndigo
```

## Components

### Agent routing

- [Multimodal agent](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/agent/multimodal_agent.py): `src/agent/multimodal_agent.py`
- [Extension router](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/agent/modality_router.py): `src/agent/modality_router.py`

### Text detection

- [Text ensemble](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/ensemble.py): `src/detectors/text/ensemble.py`
- [Text model detector](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/detector.py): `src/detectors/text/detector.py`
- [Text preprocessing](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/preprocessing.py): `src/detectors/text/preprocessing.py`
- [Text result schemas](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/text/schemas.py): `src/detectors/text/schemas.py`

### Image detection

- [Image detector adapter](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/image_detectors.py): `src/detectors/image/image_detectors.py`
- [Image decision ensemble](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/ensemble.py): `src/detectors/image/ensemble.py`
- [Image label normalization](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/image/label_normalization.py): `src/detectors/image/label_normalization.py`

### Audio detection

- [Audio ensemble](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/ensemble.py): `src/detectors/audio/ensemble.py`
- [Audio model inference](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/audio_detectors.py): `src/detectors/audio/audio_detectors.py`
- [Audio label normalization](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/audio/label_normalization.py): `src/detectors/audio/label_normalization.py`

### Video planned

- [Video detector](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/video/video_detectors.py): `src/detectors/video/video_detectors.py`
- [Video processor](https://github.com/sabtain-dev/multimodal-ai-content-detection-agent/blob/main/src/detectors/video/video_processor.py): `src/detectors/video/video_processor.py`

### Other components

- **File submitter**

## Connections

- File submitter → Multimodal agent: submits file (evidence: `README.md`)
- Multimodal agent → Extension router: detects modality (evidence: `src/agent/multimodal_agent.py`)
- Multimodal agent → Text ensemble: runs text detection (evidence: `src/agent/multimodal_agent.py`)
- Multimodal agent → Image detector adapter: requests score decision (evidence: `src/agent/multimodal_agent.py`)
- Multimodal agent → Audio ensemble: runs audio detection (evidence: `src/agent/multimodal_agent.py`)
- Text ensemble → Text model detector: runs sequentially (evidence: `src/detectors/text/ensemble.py`)
- Text model detector → Text preprocessing: cleans and chunks (evidence: `src/detectors/text/detector.py`)
- Text model detector → Text result schemas: builds results (evidence: `src/detectors/text/detector.py`)
- Text ensemble → Text result schemas: builds ensemble result (evidence: `src/detectors/text/ensemble.py`)
- Audio ensemble → Audio model inference: runs both models (evidence: `src/detectors/audio/ensemble.py`)
- Audio model inference → Audio label normalization: normalizes prediction (evidence: `src/detectors/audio/audio_detectors.py`)
