# maihan88/anthea architecture

> Architecture diagram of the GitHub repository maihan88/anthea, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maihan88/anthea
- Repository: https://github.com/maihan88/anthea

## Overview

Anthea is a Flask website for identifying images as one of five flower classes and exploring flower information and classification history. A user submits an image through the website; the API validates it, asks the CNN service for ranked predictions, stores the image and prediction, and exposes results and history to the browser. A separate data-preparation branch collects, cleans, screens, splits, and imports training-image metadata. The README documents the browser/API arrangement and optional Cloudinary storage; some individual page-to-endpoint mappings are not shown in the excerpts.

Main entry points: [`app/app.py`](https://github.com/maihan88/anthea/blob/main/app/app.py) (Flask API), [`data_tool/common.py`](https://github.com/maihan88/anthea/blob/main/data_tool/common.py) (Dataset utilities), [`app/config.py`](https://github.com/maihan88/anthea/blob/main/app/config.py) (App configuration), [`app/database.py`](https://github.com/maihan88/anthea/blob/main/app/database.py) (Flower and prediction models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Website"]
  node_browser["Browser pages"]
  node_frontend["Page scripts"]
  node_api["Flask API<br/>[app.py]"]
end

subgraph group_ml["Classification and storage"]
  node_classifier["CNN inference<br/>[model_service.py]"]
  node_model["Trained flower CNN<br/>[flower_cnn.keras]"]
  node_image_store["Uploaded image storage<br/>[storage.py]"]
end

subgraph group_data["Dataset preparation"]
  node_data_common["Dataset utilities<br/>[common.py]"]
  node_crawler["Image collection<br/>[crawl.py]"]
  node_cleaner["Image cleaning<br/>[clean.py]"]
  node_screen["CLIP screening<br/>[screen.py]"]
  node_splitter["Dataset splitting<br/>[split.py]"]
  node_manifest["Manifest import<br/>[import_manifest.py]"]
end

subgraph group_setup["Database setup"]
  node_config["App configuration<br/>[config.py]"]
  node_schema["Flower and prediction models<br/>[database.py]"]
  node_seed["Flower catalog seeding<br/>[seed.py]"]
end

node_visitor(("Website user"))
node_mysql[("MySQL database")]
node_cloudinary[("Cloudinary")]
node_inat["iNaturalist"]

node_visitor -->|"uses"| node_browser
node_browser -->|"requests JSON"| node_api
node_frontend -->|"calls endpoints"| node_api
node_api -->|"loads settings"| node_config
node_api -->|"queries and stores"| node_schema
node_api -->|"requests predictions"| node_classifier
node_classifier -->|"loads model"| node_model
node_api -->|"saves and deletes images"| node_image_store
node_image_store -.->|"uploads optionally"| node_cloudinary
node_api -.->|"persists records"| node_mysql
node_seed -->|"creates catalog"| node_schema
node_seed -->|"loads settings"| node_config
node_crawler -->|"fetches observations"| node_inat
node_crawler -->|"uses utilities"| node_data_common
node_cleaner -->|"uses utilities"| node_data_common
node_cleaner -->|"precedes screening"| node_screen
node_screen -->|"precedes splitting"| node_splitter
node_splitter -->|"uses utilities"| node_data_common
node_manifest -->|"imports metadata"| node_schema
node_manifest -->|"loads settings"| node_config

click node_browser "https://github.com/maihan88/anthea/tree/main/app/pages"
click node_frontend "https://github.com/maihan88/anthea/tree/main/app/static/js"
click node_api "https://github.com/maihan88/anthea/blob/main/app/app.py"
click node_config "https://github.com/maihan88/anthea/blob/main/app/config.py"
click node_schema "https://github.com/maihan88/anthea/blob/main/app/database.py"
click node_classifier "https://github.com/maihan88/anthea/blob/main/app/model_service.py"
click node_model "https://github.com/maihan88/anthea/blob/main/models/flower_cnn.keras"
click node_image_store "https://github.com/maihan88/anthea/blob/main/app/storage.py"
click node_seed "https://github.com/maihan88/anthea/blob/main/app/seed.py"
click node_data_common "https://github.com/maihan88/anthea/blob/main/data_tool/common.py"
click node_crawler "https://github.com/maihan88/anthea/blob/main/data_tool/crawl.py"
click node_cleaner "https://github.com/maihan88/anthea/blob/main/data_tool/clean.py"
click node_screen "https://github.com/maihan88/anthea/blob/main/data_tool/screen.py"
click node_splitter "https://github.com/maihan88/anthea/blob/main/data_tool/split.py"
click node_manifest "https://github.com/maihan88/anthea/blob/main/data_tool/import_manifest.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_browser,node_frontend,node_api,node_visitor toneBlue
class node_classifier,node_model,node_image_store,node_mysql,node_cloudinary toneAmber
class node_data_common,node_crawler,node_cleaner,node_screen,node_splitter,node_manifest toneMint
class node_config,node_schema,node_seed toneRose
class node_inat toneIndigo
```

## Components

### Website

- [Browser pages](https://github.com/maihan88/anthea/tree/main/app/pages): `app/pages`
- [Page scripts](https://github.com/maihan88/anthea/tree/main/app/static/js): `app/static/js`
- [Flask API](https://github.com/maihan88/anthea/blob/main/app/app.py): `app/app.py`

### Classification and storage

- [CNN inference](https://github.com/maihan88/anthea/blob/main/app/model_service.py): `app/model_service.py`
- [Trained flower CNN](https://github.com/maihan88/anthea/blob/main/models/flower_cnn.keras): `models/flower_cnn.keras`
- [Uploaded image storage](https://github.com/maihan88/anthea/blob/main/app/storage.py): `app/storage.py`

### Dataset preparation

- [Dataset utilities](https://github.com/maihan88/anthea/blob/main/data_tool/common.py): `data_tool/common.py`
- [Image collection](https://github.com/maihan88/anthea/blob/main/data_tool/crawl.py): `data_tool/crawl.py`
- [Image cleaning](https://github.com/maihan88/anthea/blob/main/data_tool/clean.py): `data_tool/clean.py`
- [CLIP screening](https://github.com/maihan88/anthea/blob/main/data_tool/screen.py): `data_tool/screen.py`
- [Dataset splitting](https://github.com/maihan88/anthea/blob/main/data_tool/split.py): `data_tool/split.py`
- [Manifest import](https://github.com/maihan88/anthea/blob/main/data_tool/import_manifest.py): `data_tool/import_manifest.py`

### Database setup

- [App configuration](https://github.com/maihan88/anthea/blob/main/app/config.py): `app/config.py`
- [Flower and prediction models](https://github.com/maihan88/anthea/blob/main/app/database.py): `app/database.py`
- [Flower catalog seeding](https://github.com/maihan88/anthea/blob/main/app/seed.py): `app/seed.py`

### Other components

- **Website user**
- **MySQL database**
- **Cloudinary**
- **iNaturalist**

## Connections

- Website user → Browser pages: uses (evidence: `README.md`)
- Browser pages → Flask API: requests JSON (evidence: `README.md`)
- Page scripts → Flask API: calls endpoints (evidence: `README.md`)
- Flask API → App configuration: loads settings (evidence: `app/app.py`)
- Flask API → Flower and prediction models: queries and stores (evidence: `app/app.py`)
- Flask API → CNN inference: requests predictions (evidence: `app/app.py`)
- CNN inference → Trained flower CNN: loads model (evidence: `app/model_service.py`)
- Flask API → Uploaded image storage: saves and deletes images (evidence: `app/app.py`)
- Uploaded image storage → Cloudinary: uploads optionally (evidence: `app/storage.py`)
- Flask API → MySQL database: persists records (evidence: `README.md`)
- Flower catalog seeding → Flower and prediction models: creates catalog (evidence: `app/seed.py`)
- Flower catalog seeding → App configuration: loads settings (evidence: `app/seed.py`)
- Image collection → iNaturalist: fetches observations (evidence: `data_tool/crawl.py`)
- Image collection → Dataset utilities: uses utilities (evidence: `data_tool/crawl.py`)
- Image cleaning → Dataset utilities: uses utilities (evidence: `data_tool/clean.py`)
- Image cleaning → CLIP screening: precedes screening (evidence: `data_tool/screen.py`)
- CLIP screening → Dataset splitting: precedes splitting (evidence: `data_tool/split.py`)
- Dataset splitting → Dataset utilities: uses utilities (evidence: `data_tool/split.py`)
- Manifest import → Flower and prediction models: imports metadata (evidence: `data_tool/import_manifest.py`)
- Manifest import → App configuration: loads settings (evidence: `data_tool/import_manifest.py`)
