# adityaraj1910/marine-animal-classification architecture

> Architecture diagram of the GitHub repository adityaraj1910/marine-animal-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adityaraj1910/marine-animal-classification
- Repository: https://github.com/adityaraj1910/marine-animal-classification

## Overview

##### Project Type and Purpose
- This is a full-stack web application:
- Frontend: TailwindCSS + HTML/JavaScript
- Backend: Flask (Python)
- ML inference: TensorFlow Keras models (InceptionV3, ResNet, VGG16)
- Purpose: allow users to upload marine animal images and receive a classification (23 classes) with confidence scores.

##### Main Architectural Components
a. Client (Web Browser)
- index.html (templates/index.html)
- JavaScript code for drag-and-drop, preview, AJAX calls
- TailwindCSS for styling (static/css)
b. Web Server / Flask App
- Entry point: app.py (or server.py)
- Route definitions (upload endpoint, health check)
- Jinja2 template rendering for GET /
- JSON response for POST /classify
c. Model Inference Modules
- inception_execution.py
- resnet_execution.py
- vgg16_execution.py
Each module:
- Loads pretrained Keras model + custom quantum-like layer
- Preprocesses the image (resize, scale)
- Runs model.predict and returns class + confidence
d. Data Storage
- Local file system for temporarily storing uploaded images
- “dataset” folder (used offline for training, not served in production)
e. Runtime Environment
- Python 3.8+ virtual environment
- requirements.txt (Flask, TensorFlow, etc.)

##### Component Interactions and Data Flow
1. User drags/drops an image → browser UI
2. Browser sends HTTP POST /classify with image via AJAX
3. Flask receives the request → saves temp image → forwards it to chosen inference module
4. Inference module loads model (cached in memory) → preprocesses image → predicts class
5. Model returns {label, confidence} → Flask wraps into JSON
6. Browser receives JSON → updates UI with results

##### Architectural Patterns and Principles
- MVC-style separation:
- Model: TensorFlow modules
- View: HTML + CSS + JS
- Controller: Flask route handlers
- Single-process monolith (no external microservices)
- Lazy model loading or warm-up on first request (optimization point)
- Clear separation between static assets and dynamic endpoints

##### Technologies and Frameworks
- Backend: Python + Flask + Jinja2
- ML: TensorFlow Keras (InceptionV3, ResNet, VGG16)
- Frontend: HTML5, JavaScript, TailwindCSS
- DevOps: requirements.txt for pip; run via `python app.py`

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        UI["templates/index.html"]:::frontend
        Static["static/"]:::frontend
        UI -->|"loads CSS/JS"| Static
    end

    %% Backend Layer
    subgraph "Flask Backend"
        direction TB
        App["app.py"]:::backend
        Server["server.py"]:::backend
        Main["main.py"]:::backend
        Classify["POST /classify"]:::backend
        Health["GET /health"]:::backend
        App -->|imports routes| Classify
        App -->|imports routes| Health
        App -->|bootstrap via| Main
    end

    %% Model Modules
    subgraph "Model Inference Modules"
        direction TB
        Inception["inception_execution.py"]:::ml
        Resnet["resnet_execution.py"]:::ml
        VGG["vgg16_execution.py"]:::ml
    end

    %% Data Storage
    subgraph "Data Storage"
        direction TB
        Temp["Temp Image Storage"]:::storage
        Dataset["dataset/"]:::storage
    end

    %% Other Artifacts
    subgraph "Other Artifacts"
        direction TB
        Req["requirements.txt"]:::docs
        GitIgnore[".gitignore"]:::docs
        README["README.md"]:::docs
    end

    %% Data Flow
    UI -->|"POST /classify (AJAX)"| Classify
    Classify -->|"save image"| Temp
    Classify -->|"predict(image)"| Inception
    Classify -->|"predict(image)"| Resnet
    Classify -->|"predict(image)"| VGG
    Inception -->|"result {label,confidence}"| Classify
    Resnet -->|"result {label,confidence}"| Classify
    VGG -->|"result {label,confidence}"| Classify
    Classify -->|"JSON response"| UI

    %% Click Events
    click UI "https://github.com/adityaraj1910/marine-animal-classification/blob/main/templates/index.html"
    click Static "https://github.com/adityaraj1910/marine-animal-classification/tree/main/static/"
    click App "https://github.com/adityaraj1910/marine-animal-classification/blob/main/app.py"
    click Server "https://github.com/adityaraj1910/marine-animal-classification/blob/main/server.py"
    click Main "https://github.com/adityaraj1910/marine-animal-classification/blob/main/main.py"
    click Classify "https://github.com/adityaraj1910/marine-animal-classification/blob/main/app.py"
    click Health "https://github.com/adityaraj1910/marine-animal-classification/blob/main/app.py"
    click Inception "https://github.com/adityaraj1910/marine-animal-classification/blob/main/inception_execution.py"
    click Resnet "https://github.com/adityaraj1910/marine-animal-classification/blob/main/resnet_execution.py"
    click VGG "https://github.com/adityaraj1910/marine-animal-classification/blob/main/vgg16_execution.py"
    click Dataset "https://github.com/adityaraj1910/marine-animal-classification/tree/main/dataset/"
    click Req "https://github.com/adityaraj1910/marine-animal-classification/blob/main/requirements.txt"
    click GitIgnore "https://github.com/adityaraj1910/marine-animal-classification/blob/main/.gitignore"
    click README "https://github.com/adityaraj1910/marine-animal-classification/blob/main/README.md"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:1px;
    classDef backend fill:#E8F5E9,stroke:#43A047,stroke-width:1px;
    classDef ml fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px;
    classDef storage fill:#ECEFF1,stroke:#90A4AE,stroke-width:1px;
    classDef docs fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px;
```
