# brindapuri/ai-based-animal-recognition architecture

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

- Interactive diagram: https://gitdiagram.com/brindapuri/ai-based-animal-recognition
- Repository: https://github.com/brindapuri/ai-based-animal-recognition

## Overview

This is a camera-trap animal-recognition web app. Users upload images, run YOLOv8 to separate animal from no-animal images, then classify detected animals with a choice of ResNet or ViT. The app also supports classification charts, CSV download, sorting images into folders, and testing custom ResNet weights. The README documents the frontend/backend workflow; source excerpts show backend model calls and filesystem outputs. Some endpoint wiring and frontend request details were omitted, so those links are documented at the product level rather than inferred per endpoint.

Main entry points: [`flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py) (Upload and API routes), [`flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py`](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py) (Model inference helpers), [`flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/App.js`](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/App.js) (Workflow interface), [`flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js`](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js) (React bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web interface"]
  node_webapp["Workflow interface<br/>[App.js]"]
  node_bootstrap["React bootstrap<br/>[index.js]"]
  node_metrics["Performance reporting<br/>[reportWebVitals.js]"]
end

subgraph group_service["Flask service"]
  node_api["Upload and API routes<br/>[app.py]"]
  node_detection["Animal detection<br/>[app.py]"]
  node_resnetstage["ResNet classification<br/>[app.py]"]
  node_vitstage["ViT classification<br/>[app.py]"]
  node_reporting["Charts and CSV<br/>[app.py]"]
  node_sorting["Image sorting<br/>[app.py]"]
  node_weightcheck["ResNet weight check<br/>[app.py]"]
end

subgraph group_inference["Inference models"]
  node_modelruntime["Model inference helpers<br/>[ML.py]"]
  node_modelweights["Model weights and labels"]
end

subgraph group_outputs["Results and files"]
  node_imageuploads["Uploaded images<br/>[app.py]"]
  node_resultdata["Image result data<br/>[app.py]"]
  node_exports["CSV and sorted folders<br/>[app.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"uploads images"| node_webapp
node_webapp -->|"sends requests"| node_api
node_bootstrap -->|"renders"| node_webapp
node_bootstrap -->|"invokes"| node_metrics
node_api -->|"saves uploads"| node_imageuploads
node_api -->|"dispatches"| node_detection
node_detection -->|"calls YOLO"| node_modelruntime
node_api -->|"dispatches"| node_resnetstage
node_api -->|"dispatches"| node_vitstage
node_resnetstage -->|"calls ResNet"| node_modelruntime
node_vitstage -->|"calls ViT"| node_modelruntime
node_modelruntime -->|"loads models"| node_modelweights
node_detection -->|"updates results"| node_resultdata
node_resnetstage -->|"writes results"| node_resultdata
node_vitstage -->|"writes results"| node_resultdata
node_api -->|"dispatches"| node_reporting
node_reporting -->|"reads results"| node_resultdata
node_reporting -->|"writes CSV"| node_exports
node_api -->|"dispatches"| node_sorting
node_sorting -->|"reads results"| node_resultdata
node_sorting -->|"copies images"| node_exports
node_api -->|"dispatches"| node_weightcheck
node_weightcheck -->|"loads and tests"| node_modelruntime

click node_webapp "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/App.js"
click node_bootstrap "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js"
click node_metrics "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/reportWebVitals.js"
click node_api "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_detection "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_resnetstage "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_vitstage "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_reporting "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_sorting "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_weightcheck "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_modelruntime "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py"
click node_modelweights "https://github.com/brindapuri/ai-based-animal-recognition/tree/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/weights"
click node_imageuploads "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_resultdata "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py"
click node_exports "https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.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_bootstrap,node_metrics toneBlue
class node_api,node_detection,node_resnetstage,node_vitstage,node_reporting,node_sorting,node_weightcheck toneAmber
class node_modelruntime,node_modelweights toneMint
class node_imageuploads,node_resultdata,node_exports toneRose
class node_researcher toneIndigo
```

## Components

### Web interface

- [Workflow interface](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/App.js): `flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/App.js`
- [React bootstrap](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js): `flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js`
- [Performance reporting](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/reportWebVitals.js): `flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/reportWebVitals.js`

### Flask service

- [Upload and API routes](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [Animal detection](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [ResNet classification](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [ViT classification](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [Charts and CSV](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [Image sorting](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [ResNet weight check](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`

### Inference models

- [Model inference helpers](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py`
- [Model weights and labels](https://github.com/brindapuri/ai-based-animal-recognition/tree/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/weights): `flask-webapp/DeployAnmialDetection/animalDetection/backend/weights`

### Results and files

- [Uploaded images](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [Image result data](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`
- [CSV and sorted folders](https://github.com/brindapuri/ai-based-animal-recognition/blob/main/flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py): `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`

### Other components

- **Researcher**

## Connections

- Researcher → Workflow interface: uploads images (evidence: `README.md`)
- Workflow interface → Upload and API routes: sends requests (evidence: `README.md`)
- React bootstrap → Workflow interface: renders (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js`)
- React bootstrap → Performance reporting: invokes (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/frontend/src/index.js`)
- Upload and API routes → Uploaded images: saves uploads (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Upload and API routes → Animal detection: dispatches (evidence: `README.md`)
- Animal detection → Model inference helpers: calls YOLO (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Upload and API routes → ResNet classification: dispatches (evidence: `README.md`)
- Upload and API routes → ViT classification: dispatches (evidence: `README.md`)
- ResNet classification → Model inference helpers: calls ResNet (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- ViT classification → Model inference helpers: calls ViT (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Model inference helpers → Model weights and labels: loads models (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/ML.py`)
- Animal detection → Image result data: updates results (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- ResNet classification → Image result data: writes results (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- ViT classification → Image result data: writes results (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Upload and API routes → Charts and CSV: dispatches (evidence: `README.md`)
- Charts and CSV → Image result data: reads results (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Charts and CSV → CSV and sorted folders: writes CSV (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Upload and API routes → Image sorting: dispatches (evidence: `README.md`)
- Image sorting → Image result data: reads results (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Image sorting → CSV and sorted folders: copies images (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- Upload and API routes → ResNet weight check: dispatches (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
- ResNet weight check → Model inference helpers: loads and tests (evidence: `flask-webapp/DeployAnmialDetection/animalDetection/backend/app.py`)
