# srajeshwaran227-eng/ads-with-ai architecture

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

- Interactive diagram: https://gitdiagram.com/srajeshwaran227-eng/ads-with-ai
- Repository: https://github.com/srajeshwaran227-eng/ads-with-ai

## Overview

AuthentiGuard is a multimodal content-authenticity service: users submit documents, images, videos, or audio and receive modality-specific detection results. The Flask app registers four analysis routes; each route validates and temporarily stores its upload, invokes analysis, returns a JSON classification, and cleans up the file. Document analysis also extracts and cleans text before plagiarism and AI-text checks. The README describes a browser experience and all four capabilities, but the sampled evidence does not establish how the frontend calls the API. The detector implementations support demo mode and optional model-backed processing.

Main entry points: [`backend/app.py`](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/app.py) (Flask app), [`backend/routes/document_routes.py`](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/document_routes.py) (Document endpoint), [`backend/utils/file_handler.py`](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/utils/file_handler.py) (Upload handling), [`backend/routes/image_routes.py`](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/image_routes.py) (Image endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experience"]
  node_home["Home page<br/>[index.html]"]
  node_upload["Upload page<br/>[upload.html]"]
  node_results["Results page<br/>[results.html]"]
  node_client["Browser client<br/>[script.js]"]
  node_styles["Page styles<br/>[styles.css]"]
end

subgraph group_api["Flask API"]
  node_app["Flask app<br/>[app.py]"]
  node_config["Runtime config<br/>[config.py]"]
  node_docroute["Document endpoint<br/>[document_routes.py]"]
  node_imageroute["Image endpoint<br/>[image_routes.py]"]
  node_videoroute["Video endpoint<br/>[video_routes.py]"]
  node_audioroute["Audio endpoint<br/>[audio_routes.py]"]
end

subgraph group_analysis["Detection services"]
  node_plagiarism["Plagiarism check"]
  node_textai["AI text check"]
  node_imagecheck["Image detection<br/>[image_detector.py]"]
  node_videocheck["Video detection<br/>[video_detector.py]"]
  node_audiocheck["Audio detection<br/>[audio_detector.py]"]
end

subgraph group_shared["Shared processing"]
  node_files["Upload handling<br/>[file_handler.py]"]
  node_preprocess["Text and media preprocessing<br/>[preprocessing.py]"]
end

node_user(("User"))

node_app -->|"loads settings"| node_config
node_app -->|"registers route"| node_docroute
node_app -->|"registers route"| node_imageroute
node_app -->|"registers route"| node_videoroute
node_app -->|"registers route"| node_audioroute
node_docroute -->|"saves and cleans"| node_files
node_imageroute -->|"saves and cleans"| node_files
node_videoroute -->|"saves and cleans"| node_files
node_audioroute -->|"saves and cleans"| node_files
node_docroute -->|"extracts and cleans text"| node_preprocess
node_docroute -->|"checks similarity"| node_plagiarism
node_docroute -->|"checks AI text"| node_textai
node_imageroute -->|"analyzes image"| node_imagecheck
node_videoroute -->|"analyzes video"| node_videocheck
node_audioroute -->|"analyzes audio"| node_audiocheck
node_imagecheck -->|"prepares image"| node_preprocess
node_audiocheck -->|"builds spectrogram"| node_preprocess
node_user -.->|"submits media"| node_upload

click node_home "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/index.html"
click node_upload "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/upload.html"
click node_results "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/results.html"
click node_client "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/script.js"
click node_styles "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/styles.css"
click node_app "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/app.py"
click node_config "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/config.py"
click node_docroute "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/document_routes.py"
click node_imageroute "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/image_routes.py"
click node_videoroute "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/video_routes.py"
click node_audioroute "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/audio_routes.py"
click node_plagiarism "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/plagiarism_service.py"
click node_textai "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/text_ai_detector.py"
click node_imagecheck "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/image_detector.py"
click node_videocheck "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/video_detector.py"
click node_audiocheck "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/audio_detector.py"
click node_files "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/utils/file_handler.py"
click node_preprocess "https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/utils/preprocessing.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_home,node_upload,node_results,node_client,node_styles,node_user toneBlue
class node_app,node_config,node_docroute,node_imageroute,node_videoroute,node_audioroute toneAmber
class node_plagiarism,node_textai,node_imagecheck,node_videocheck,node_audiocheck toneMint
class node_files,node_preprocess toneRose
```

## Components

### Browser experience

- [Home page](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/index.html): `index.html`
- [Upload page](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/upload.html): `upload.html`
- [Results page](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/results.html): `results.html`
- [Browser client](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/script.js): `script.js`
- [Page styles](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/styles.css): `styles.css`

### Flask API

- [Flask app](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/app.py): `backend/app.py`
- [Runtime config](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/config.py): `backend/config.py`
- [Document endpoint](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/document_routes.py): `backend/routes/document_routes.py`
- [Image endpoint](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/image_routes.py): `backend/routes/image_routes.py`
- [Video endpoint](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/video_routes.py): `backend/routes/video_routes.py`
- [Audio endpoint](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/routes/audio_routes.py): `backend/routes/audio_routes.py`

### Detection services

- [Plagiarism check](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/plagiarism_service.py): `backend/services/plagiarism_service.py`
- [AI text check](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/text_ai_detector.py): `backend/services/text_ai_detector.py`
- [Image detection](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/image_detector.py): `backend/services/image_detector.py`
- [Video detection](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/video_detector.py): `backend/services/video_detector.py`
- [Audio detection](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/services/audio_detector.py): `backend/services/audio_detector.py`

### Shared processing

- [Upload handling](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/utils/file_handler.py): `backend/utils/file_handler.py`
- [Text and media preprocessing](https://github.com/srajeshwaran227-eng/ads-with-ai/blob/main/backend/utils/preprocessing.py): `backend/utils/preprocessing.py`

### Other components

- **User**

## Connections

- Flask app → Runtime config: loads settings (evidence: `backend/app.py`)
- Flask app → Document endpoint: registers route (evidence: `backend/app.py`)
- Flask app → Image endpoint: registers route (evidence: `backend/app.py`)
- Flask app → Video endpoint: registers route (evidence: `backend/app.py`)
- Flask app → Audio endpoint: registers route (evidence: `backend/app.py`)
- Document endpoint → Upload handling: saves and cleans (evidence: `backend/routes/document_routes.py`)
- Image endpoint → Upload handling: saves and cleans (evidence: `backend/routes/image_routes.py`)
- Video endpoint → Upload handling: saves and cleans (evidence: `backend/routes/video_routes.py`)
- Audio endpoint → Upload handling: saves and cleans (evidence: `backend/routes/audio_routes.py`)
- Document endpoint → Text and media preprocessing: extracts and cleans text (evidence: `backend/routes/document_routes.py`)
- Document endpoint → Plagiarism check: checks similarity (evidence: `backend/routes/document_routes.py`)
- Document endpoint → AI text check: checks AI text (evidence: `backend/routes/document_routes.py`)
- Image endpoint → Image detection: analyzes image (evidence: `backend/routes/image_routes.py`)
- Video endpoint → Video detection: analyzes video (evidence: `backend/routes/video_routes.py`)
- Audio endpoint → Audio detection: analyzes audio (evidence: `backend/routes/audio_routes.py`)
- Image detection → Text and media preprocessing: prepares image (evidence: `backend/services/image_detector.py`)
- Audio detection → Text and media preprocessing: builds spectrogram (evidence: `backend/services/audio_detector.py`)
- User → Upload page: submits media (evidence: `README.md`)
