# phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition architecture

> Architecture diagram of the GitHub repository phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition
- Repository: https://github.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition

## Overview

##### Main Components
- Mobile Application (Android):
- Located in the “App/app” directory. It’s an Android app built with Android Studio and written in Kotlin.
- Contains various UI components (Home, FAQ, Feedback, Search) and ViewModels within the “birds/species/birdsspeciesclassification/ui” subdirectories.
- It interacts with external endpoints (for both name-based and image-based search) as indicated in the README.

- Backend Services (Server):
- Under “Server File,” there are two main submodules:
▪ “Search By Image”: Contains a Dockerfile, Python script (main.py), ensemble TensorFlow Lite model (ensemble_final.tflite), and CSV indices. This endpoint provides image recognition services.
▪ “Search By name of the Bird”: Contains a Dockerfile and app.py to serve name-based searches.

- Website (Web Application):
- Located in the “Website” directory. This is a Flask-based web app (app.py) with templated HTML pages (index.html, results.html, teams.html) and static assets.
- Acts as an alternate front-end for users to interact with the service.

- External Integrations and Cloud Services:
- Google Gemini API: Used for fetching detailed species information.
- Wikimedia Commons: Used for retrieving related bird images.
- Microsoft Azure: Deployed via Docker containers and Azure CLI commands as outlined in the README.
- Docker: For containerizing the backend services and the website.

##### Relationships and Interactions
- Both Mobile and Website Clients:
- They are interfaced with the backend APIs. The mobile app specifically references updating endpoint URLs for both image and name searches.
- Data flows from these front-ends to the relevant backend services via HTTP requests.

- Backend API Services:
- The “Search By Image” service leverages machine learning models (via TensorFlow Lite) to classify bird species based on images.
- The “Search By name of the Bird” service handles textual input and returns search results based on bird names.
- Both services may interact with external APIs (Google Gemini and Wikimedia Commons) to enrich the data with species details and images.

- Deployment and Container Orchestration:
- The Dockerfiles in the Server File and Website directories show that these components are containerized.
- Azure is used to deploy these containers (via Azure Container Registry, App Service Plan, and Web Apps).

##### Architectural Patterns
- Separation of Concerns: The project cleanly separates user interfaces (mobile app and website) from backend services (image-based and text-based search endpoints).
- Microservices-like Structure: Even though the backend is divided into separate directories, each service (image recognition and name search) can be deployed independently in containers.
- API-driven Design: RESTful APIs (evidenced by the endpoints in the mobile code and Python scripts) serve as the contract between frontends and services.

##### Relevant Technologies, Frameworks, and Libraries
- Android (Kotlin, Android Studio)
- TensorFlow Lite (for image recognition)
- Flask (Python web framework used in both backend and Website)
- Docker (for containerization)
- Microsoft Azure (for deployment and container orchestration)
- External APIs (Google Gemini API and Wikimedia Commons)

##### Specific Elements
- Mobile App (Android):
- UI screens (Home, Search, FAQ, Feedback)

- Website (Flask Frontend):
- UI Pages (index, results, teams)

- Server Backends:
- “Search By Image” Service:
▪ A block that shows the TensorFlow Lite model (ensemble_final.tflite) processing images.
▪ Integration with external APIs (Google Gemini for detailed species information).
- “Search By Name” Service:
▪ A block that handles textual bird name queries.

- External Dependencies:
- Google Gemini API (detailed species info)
- Wikimedia Commons (similar images)

- Deployment & Infrastructure:

- Communication Protocols:

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        MA["Mobile Application (Android)"]:::mobile
        WA["Website Application (Flask Frontend)"]:::web
    end

    %% Backend API Layer
    subgraph "Backend API Layer"
        SI["Search By Image Service (TFLite)"]:::backend
        SN["Search By Name Service"]:::backend
    end

    %% External Integration
    subgraph "External Integration"
        GAPI["Google Gemini API"]:::external
        WC["Wikimedia Commons"]:::external
    end

    %% Deployment & Containerization
    subgraph "Deployment & Containerization"
        DC["Docker Containers"]:::docker
        AZ["Azure Cloud"]:::azure
    end

    %% Client to Backend API calls
    MA -->|"image_search"| SI
    MA -->|"name_search"| SN
    WA -->|"image_search"| SI
    WA -->|"name_search"| SN

    %% Backend to External Integrations
    SI -->|"species_info"| GAPI
    SI -->|"related_images"| WC
    SN -->|"species_info"| GAPI
    SN -->|"related_images"| WC

    %% Deployment connections
    SI -.-> DC
    SN -.-> DC
    WA -.-> DC
    DC -->|"Deployed_to"| AZ

    %% Click Events
    click MA "https://github.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition/tree/main/App/app"
    click SI "https://github.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition/tree/main/Server File/Search By Image"
    click SN "https://github.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition/tree/main/Server File/Search By name of the Bird"
    click WA "https://github.com/phantombeast7/birdrecon-a-free-open-source-tool-for-image-based-bird-species-recognition/tree/main/Website"

    %% Styles
    classDef mobile fill:#f1c40f,stroke:#000,stroke-width:2px;
    classDef web fill:#e67e22,stroke:#000,stroke-width:2px;
    classDef backend fill:#2ecc71,stroke:#000,stroke-width:2px;
    classDef external fill:#3498db,stroke:#000,stroke-width:2px;
    classDef docker fill:#9b59b6,stroke:#000,stroke-width:2px;
    classDef azure fill:#34495e,stroke:#fff,stroke-width:2px;
```
