# dat0309/do-an-nay-bi-quy-am architecture

> Architecture diagram of the GitHub repository dat0309/do-an-nay-bi-quy-am, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dat0309/do-an-nay-bi-quy-am
- Repository: https://github.com/dat0309/do-an-nay-bi-quy-am

## Overview

##### Project type and purpose
- This is a full-stack plant identification system combining:
- A Python ML/REST backend (FastAPI + YOLO/ONNX models + training pipeline)
- Two React front-end apps (a user-facing “clientapp” and an admin “dashboard”)
- A Flutter mobile app for cross-platform scanning
- Containerization (Docker + docker-compose + Nginx as API gateway)

##### File structure
- Top-level modules:
- backend/ – Python services & ML models
– FASTAPI-AGRICULTURE-IDENTITY & BE-agriculture-identity: REST endpoints for identify/classify
– yolo-identity-agriculture: abstraction over ONNX/PT models & processing functions
– train/: scripts & data for generating .h5 classification models
- frontend/
– clientapp/: React SPA for end users to upload or take plant images and view results
– dashboard/: React SPA for administrators—plants data, metrics, usage cards, sidebar
- mobile/plant_identification_app/: Flutter app (controllers → services → views widgets)
- dockerfiles/ & docker-compose.yml: service definitions, Nginx reverse proxy, multi-container setup
- nginx/: nginx.conf for routing API calls and serving static assets

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        ClientApp["Web Client<br/>(React)"]:::ui
        Dashboard["Web Admin<br/>(React)"]:::ui
        MobileApp["Mobile App<br/>(Flutter)"]:::ui
    end

    %% Edge/API Gateway
    subgraph "Edge / API Gateway"
        direction TB
        Nginx["Nginx<br/>(Reverse Proxy)"]:::api
    end

    %% Backend Tier
    subgraph "Backend Tier"
        direction TB
        FastAPI["FastAPI Service<br/>(Python)"]:::api
        subgraph "Inference Service"
            direction TB
            YOLOModule["YOLO-Identity Module<br/>(ONNX/PyTorch)"]:::ml
        end
        subgraph "Training Pipeline"
            direction TB
            Training["Training Pipeline<br/>(h5 & ONNX)"]:::ml
        end
        Database["Database<br/>(PostgreSQL/MongoDB)"]:::data
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        ModelStorage["Model Storage<br/>(.h5, ONNX, PT)"]:::data
    end

    %% Containerization
    subgraph "Containerization"
        direction TB
        DockerCompose["docker-compose.yml"]:::container
        DockerBackend["agriculture-identity.dockerfile"]:::container
        DockerFrontend["frontend.dockerfile"]:::container
        DockerNginx["nginx.dockerfile"]:::container
    end

    %% Connections
    ClientApp -->|"HTTP/REST"| Nginx
    Dashboard -->|"HTTP/REST"| Nginx
    MobileApp -->|"HTTP/REST"| Nginx

    Nginx -->|"forwards /api"| FastAPI

    FastAPI -->|"invoke inference"| YOLOModule
    YOLOModule -->|"predictions"| FastAPI
    FastAPI -->|"query/update"| Database

    Dashboard -->|"via FastAPI"| Database

    Training -->|"write .h5"| ModelStorage
    ModelStorage -->|"loaded by"| YOLOModule

    %% Container links (visual grouping)
    DockerCompose --> DockerBackend
    DockerCompose --> DockerFrontend
    DockerCompose --> DockerNginx

    %% Click Events
    click ClientApp "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/frontend/clientapp"
    click Dashboard "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/frontend/dashboard"
    click MobileApp "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/mobile/plant_identification_app"
    click Nginx "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/nginx/nginx.conf"
    click DockerCompose "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/docker-compose.yml"
    click DockerBackend "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/dockerfiles/agriculture-identity.dockerfile"
    click DockerFrontend "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/dockerfiles/frontend.dockerfile"
    click DockerNginx "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/dockerfiles/nginx.dockerfile"
    click FastAPI "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/FASTAPI-AGRICULTURE-IDENTITY"
    click FastAPI "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/BE-agriculture-identity"
    click YOLOModule "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/backend/yolo-identity-agriculture/main.py"
    click YOLOModule "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/yolo-identity-agriculture/ONNXModel"
    click YOLOModule "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/yolo-identity-agriculture/onnx_folder"
    click YOLOModule "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/yolo-identity-agriculture/pt_folder"
    click YOLOModule "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/yolo-identity-agriculture/yolo_function"
    click Training "https://github.com/dat0309/do-an-nay-bi-quy-am/tree/main/backend/train"
    click Training "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/backend/train/training_model.py"
    click Training "https://github.com/dat0309/do-an-nay-bi-quy-am/blob/main/backend/train/detect.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef api fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef ml fill:#FFE0B3,stroke:#333,stroke-width:1px
    classDef data fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef container fill:#F0D9FF,stroke:#333,stroke-width:1px
```
