# syedhissamkazmi/ai-image-detector architecture

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

- Interactive diagram: https://gitdiagram.com/syedhissamkazmi/ai-image-detector
- Repository: https://github.com/syedhissamkazmi/ai-image-detector

## Overview

AI Image Authenticity Detector accepts images through a FastAPI web interface or a separate Streamlit demo, then reports probabilistic AI-authenticity results. The main workflow validates and optionally resizes an upload, extracts image details, runs two detectors concurrently, combines available predictions, and returns a structured report for the frontend. The README also documents model transparency, fallback behavior, dominant colours, and EXIF metadata. Some route and analyzer excerpts are incomplete, so uncertain internal wiring is omitted; the Streamlit path is documented only where its sampled source supports it.

Main entry points: [`app/api/routes.py`](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/routes.py) (Analyze route), [`app/services/analyzer.py`](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/services/analyzer.py) (Image analyzer), [`frontend/app.js`](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/frontend/app.js) (Upload frontend), [`app/detector/model.py`](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/model.py) (Detector ensemble)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["FastAPI app<br/>[main.py]"]
  node_frontend["Upload frontend<br/>[app.js]"]
  node_streamlit["Streamlit demo<br/>[streamlit_app.py]"]
end

subgraph group_analysis["Image analysis"]
  node_validation["Upload validation<br/>[routes.py]"]
  node_uploads[("Temporary uploads")]
  node_analyzer["Image analyzer<br/>[analyzer.py]"]
  node_features["Image features<br/>[analyzer.py]"]
end

subgraph group_inference["Model inference"]
  node_ensemble["Detector ensemble<br/>[model.py]"]
  node_ateeq["Ateeq detector<br/>[ateeq_detector.py]"]
  node_wkaandemir["Wkaandemir detector"]
end

subgraph group_shared["API and configuration"]
  node_routes["Analyze route<br/>[routes.py]"]
  node_response["Analysis response<br/>[schemas.py]"]
end

node_browser(("Browser user"))
node_hf["Hugging Face model hub"]

node_browser -->|"selects image"| node_frontend
node_frontend -->|"posts upload"| node_routes
node_webapp -->|"serves interface"| node_frontend
node_webapp -->|"mounts routes"| node_routes
node_routes -->|"validates and resizes"| node_validation
node_routes -->|"writes temporary image"| node_uploads
node_routes -->|"requests analysis"| node_analyzer
node_analyzer -->|"extracts metadata and colours"| node_features
node_analyzer -->|"reads image file"| node_uploads
node_analyzer -->|"requests predictions"| node_ensemble
node_ensemble -->|"runs prediction"| node_ateeq
node_ensemble -->|"runs prediction"| node_wkaandemir
node_ateeq -.->|"loads model"| node_hf
node_wkaandemir -.->|"downloads weights"| node_hf
node_analyzer -->|"builds report"| node_response
node_routes -->|"returns JSON"| node_frontend
node_frontend -->|"renders results"| node_browser
node_browser -->|"uploads image"| node_streamlit
node_streamlit -->|"requests predictions"| node_ensemble

click node_webapp "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/main.py"
click node_frontend "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/frontend/app.js"
click node_streamlit "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/streamlit_app.py"
click node_routes "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/routes.py"
click node_validation "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/routes.py"
click node_uploads "https://github.com/syedhissamkazmi/ai-image-detector/tree/main/uploads"
click node_analyzer "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/services/analyzer.py"
click node_features "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/services/analyzer.py"
click node_response "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/schemas.py"
click node_ensemble "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/model.py"
click node_ateeq "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/ateeq_detector.py"
click node_wkaandemir "https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/wkaandemir_detector.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_webapp,node_frontend,node_streamlit,node_browser toneBlue
class node_validation,node_uploads,node_analyzer,node_features toneAmber
class node_ensemble,node_ateeq,node_wkaandemir toneMint
class node_routes,node_response toneRose
class node_hf toneIndigo
```

## Components

### Web experience

- [FastAPI app](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/main.py): `app/main.py`
- [Upload frontend](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/frontend/app.js): `frontend/app.js`
- [Streamlit demo](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/streamlit_app.py): `streamlit_app.py`

### Image analysis

- [Upload validation](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/routes.py): `app/api/routes.py`
- [Temporary uploads](https://github.com/syedhissamkazmi/ai-image-detector/tree/main/uploads): `uploads`
- [Image analyzer](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/services/analyzer.py): `app/services/analyzer.py`
- [Image features](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/services/analyzer.py): `app/services/analyzer.py`

### Model inference

- [Detector ensemble](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/model.py): `app/detector/model.py`
- [Ateeq detector](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/ateeq_detector.py): `app/detector/ateeq_detector.py`
- [Wkaandemir detector](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/detector/wkaandemir_detector.py): `app/detector/wkaandemir_detector.py`

### API and configuration

- [Analyze route](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/routes.py): `app/api/routes.py`
- [Analysis response](https://github.com/syedhissamkazmi/ai-image-detector/blob/main/app/api/schemas.py): `app/api/schemas.py`

### Other components

- **Browser user**
- **Hugging Face model hub**

## Connections

- Browser user → Upload frontend: selects image
- Upload frontend → Analyze route: posts upload
- FastAPI app → Upload frontend: serves interface
- FastAPI app → Analyze route: mounts routes
- Analyze route → Upload validation: validates and resizes
- Analyze route → Temporary uploads: writes temporary image
- Analyze route → Image analyzer: requests analysis
- Image analyzer → Image features: extracts metadata and colours
- Image analyzer → Temporary uploads: reads image file
- Image analyzer → Detector ensemble: requests predictions
- Detector ensemble → Ateeq detector: runs prediction
- Detector ensemble → Wkaandemir detector: runs prediction
- Ateeq detector → Hugging Face model hub: loads model
- Wkaandemir detector → Hugging Face model hub: downloads weights
- Image analyzer → Analysis response: builds report
- Analyze route → Upload frontend: returns JSON
- Upload frontend → Browser user: renders results
- Browser user → Streamlit demo: uploads image
- Streamlit demo → Detector ensemble: requests predictions
