# nikamathw/pest-classification-and-detection-system-using-deep-learning architecture

> Architecture diagram of the GitHub repository nikamathw/pest-classification-and-detection-system-using-deep-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikamathw/pest-classification-and-detection-system-using-deep-learning
- Repository: https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning

## Overview

This is a Flask pest-identification and information system. A user submits an image through the web interface; the Flask route runs a loaded vision model, maps its class ID to a pest name, looks up pest details in MongoDB, and renders a result. Separate routes support pest-detail editing and user queries. The source also contains a pest-information dictionary and a ResNet9 implementation, but the sampled application imports neither; its active predictor is a ViT defined in user/user.py. The README documents the broader database and treatment-information capability; unsampled UI and database behavior is not expanded beyond that evidence.

Main entry points: [`user/user.py`](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py) (Flask routes), [`user/templates`](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/tree/main/user/templates) (Web templates), [`main.py`](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/main.py) (Application entry), [`user/utils/pestid.py`](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/utils/pestid.py) (Pest ID map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_entry["Application entry<br/>[main.py]"]
  node_flask["Flask routes<br/>[user.py]"]
  node_webui["Web templates"]
end

subgraph group_vision["Pest identification"]
  node_predictor["Image predictor<br/>[user.py]"]
  node_vit["ViT classifier<br/>[user.py]"]
  node_classmap["Pest ID map<br/>[pestid.py]"]
  node_resnet["ResNet9 model<br/>[model.py]"]
end

subgraph group_knowledge["Pest information"]
  node_pestdb[("Pest details")]
  node_catalog["Pest reference data<br/>[pests.py]"]
end

subgraph group_admin["Administration"]
  node_querydata[("User queries")]
  node_uploads["Uploaded pest images"]
end

node_visitor(("Web user"))
node_mongodb[("MongoDB")]
node_officer(("Officer"))

node_visitor -->|"uses"| node_webui
node_webui -->|"submits requests"| node_flask
node_entry -->|"starts app"| node_flask
node_flask -->|"renders pages"| node_webui
node_flask -->|"predicts image"| node_predictor
node_predictor -->|"runs inference"| node_vit
node_flask -->|"maps class ID"| node_classmap
node_flask -->|"looks up pest"| node_mongodb
node_mongodb -->|"stores details"| node_pestdb
node_flask -->|"shows prediction"| node_webui
node_officer -->|"uses admin pages"| node_webui
node_flask -->|"updates pest"| node_mongodb
node_flask -->|"saves images"| node_uploads
node_flask -->|"inserts and reads queries"| node_mongodb
node_mongodb -->|"stores queries"| node_querydata

click node_entry "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/main.py"
click node_flask "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py"
click node_webui "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/tree/main/user/templates"
click node_predictor "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py"
click node_vit "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py"
click node_classmap "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/utils/pestid.py"
click node_resnet "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/utils/model.py"
click node_catalog "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/utils/pests.py"
click node_uploads "https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/tree/main/user/static"

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_entry,node_flask,node_webui,node_visitor toneBlue
class node_predictor,node_vit,node_classmap,node_resnet,node_mongodb toneAmber
class node_pestdb,node_catalog toneMint
class node_querydata,node_uploads toneRose
class node_officer toneIndigo
```

## Components

### Web application

- [Application entry](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/main.py): `main.py`
- [Flask routes](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py): `user/user.py`
- [Web templates](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/tree/main/user/templates): `user/templates`

### Pest identification

- [Image predictor](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py): `user/user.py`
- [ViT classifier](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/user.py): `user/user.py`
- [Pest ID map](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/utils/pestid.py): `user/utils/pestid.py`
- [ResNet9 model](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/utils/model.py): `utils/model.py`

### Pest information

- **Pest details**
- [Pest reference data](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/blob/main/user/utils/pests.py): `user/utils/pests.py`

### Administration

- **User queries**
- [Uploaded pest images](https://github.com/nikamathw/pest-classification-and-detection-system-using-deep-learning/tree/main/user/static): `user/static`

### Other components

- **Web user**
- **MongoDB**
- **Officer**

## Connections

- Web user → Web templates: uses (evidence: `README.md`)
- Web templates → Flask routes: submits requests (evidence: `README.md`)
- Application entry → Flask routes: starts app (evidence: `main.py`)
- Flask routes → Web templates: renders pages (evidence: `user/user.py`)
- Flask routes → Image predictor: predicts image (evidence: `user/user.py`)
- Image predictor → ViT classifier: runs inference (evidence: `user/user.py`)
- Flask routes → Pest ID map: maps class ID (evidence: `user/user.py`)
- Flask routes → MongoDB: looks up pest (evidence: `user/user.py`)
- MongoDB → Pest details: stores details (evidence: `README.md`)
- Flask routes → Web templates: shows prediction (evidence: `user/user.py`)
- Officer → Web templates: uses admin pages (evidence: `README.md`)
- Flask routes → MongoDB: updates pest (evidence: `user/user.py`)
- Flask routes → Uploaded pest images: saves images (evidence: `user/user.py`)
- Flask routes → MongoDB: inserts and reads queries (evidence: `user/user.py`)
- MongoDB → User queries: stores queries
