# kadapalanikith/underwater-fish-classification-yolov8 architecture

> Architecture diagram of the GitHub repository kadapalanikith/underwater-fish-classification-yolov8, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kadapalanikith/underwater-fish-classification-yolov8
- Repository: https://github.com/kadapalanikith/underwater-fish-classification-yolov8

## Overview

1. **Overall shape**
   - This repo is a two-tier computer-vision application: a **React + Vite frontend** in `client/` and a **FastAPI inference backend** in `server/`.
   - The core ML asset is the trained YOLOv8 weights file at `models/best.pt`, which both local and containerized deployments depend on.

2. **Primary user-facing workflow**
   - The main flow is: user opens the web UI, uploads an underwater fish image, the frontend sends that image to the backend, and the backend returns detection/classification results with bounding boxes, labels, and confidence scores.
   - The demo/inference experience is the central product path; the other pages are informational.

3. **Frontend subsystem**
   - `client/src/App.jsx` acts as the app shell/router, switching between `HomePage`, `DemoPage`, `ResearchPage`, and `ContactPage`.
   - `DemoPage.jsx` is the key interaction surface for inference; `HomePage.jsx` is the landing page; `ResearchPage.jsx` serves the paper and metrics; `ContactPage.jsx` provides team info.
   - Styling is centralized in `index.css` and `style.css`, with shared layout pieces in `Navbar.jsx` and `Footer.jsx`.

4. **Frontend-to-backend boundary**
   - The frontend is configured with a single backend base URL via `VITE_API_URL` in `client/.env`, so the UI is decoupled from the API host.
   - This boundary is important for deployment: the frontend can be hosted separately from the model server as long as it knows the API URL.

5. **Backend inference service**
   - `server/main.py` is the FastAPI service that loads the YOLOv8 model and exposes the prediction endpoint.
   - The README indicates the service responds at `/` with a status payload and exposes `/docs` for interactive API exploration.
   - The inference endpoint accepts uploaded image files and runs model prediction on them before returning structured detection output.

6. **Model layer**
   - `models/best.pt` is the trained detector/classifier and is the only heavy ML artifact in the repo.
   - The repository is organized around serving this artifact rather than training it at runtime; training appears to have been done offline, with notebooks retained in `notebooks/` for experimentation and reproducibility.

7. **Static assets and research content**
   - The `client/public/research/` folder contains the research paper PDF used by the Research page, while `client/src/assets/` also includes a paper copy used by the app.
   - This content is served statically by the frontend build and does not pass through the backend.

8. **Deployment modes**
   - There are three container entry points:
     - `Dockerfile` for the unified self-hosted build,
     - `Dockerfile.render` for backend-only deployment on Render,
     - `Dockerfile.huggingface` for backend-only deployment on Hugging Face Spaces.
   - This means the architecture supports both **combined serving** and **split frontend/backend hosting** depending on platform.

9. **Serving topology**
   - In local development, the frontend runs on Vite dev server `5173` and the backend on FastAPI/Uvicorn `8000`.
   - In the all-in-one Docker mode, FastAPI also serves the built frontend, collapsing the system into a single exposed port.

10. **External/runtime dependencies that matter architecturally**
   - The backend depends on Python, PyTorch, Ultralytics/YOLOv8, and FastAPI; these determine model loading, inference latency, and API shape.
   - The frontend depends on React 19 and Vite, which makes the UI a static SPA that talks to the inference service over HTTP.

11. **Legacy and auxiliary code**
   - `server/archive/app_legacy.py` suggests an older backend implementation kept for reference rather than active use.
   - `test_sample/` and the notebooks are supporting artifacts, not part of the primary request path.

12. **Diagram-friendly summary**
   - The best architecture diagram should show:
     - browser/user → React SPA (`client`)
     - React SPA → FastAPI inference API (`server/main.py`)
     - FastAPI API → YOLOv8 model weights (`models/best.pt`)
     - FastAPI API → JSON/image-annotated prediction response back to the UI
     - optional static delivery of research PDFs from the frontend build
     - deployment variants via Docker, Render, and Hugging Face Spaces.

Main entry points: [`client/src/App.jsx`](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/App.jsx) (App Shell), [`server/main.py`](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/server/main.py) (FastAPI Server), [`client/src/pages/DemoPage.jsx`](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/DemoPage.jsx) (Demo), [`client/src/pages/ResearchPage.jsx`](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/ResearchPage.jsx) (Research)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_app_shell["App Shell<br/>SPA router<br/>[App.jsx]"]
  node_home_page["Home<br/>page<br/>[HomePage.jsx]"]
  node_demo_page["Demo<br/>inference UI<br/>[DemoPage.jsx]"]
  node_research_page["Research<br/>content page<br/>[ResearchPage.jsx]"]
  node_contact_page["Contact<br/>info page<br/>[ContactPage.jsx]"]
  node_navbar["Navbar<br/>layout<br/>[Navbar.jsx]"]
  node_footer["Footer<br/>layout<br/>[Footer.jsx]"]
  node_styles["Styles<br/>css<br/>[index.css]"]
  node_api_url["API URL<br/>env config"]
end

subgraph group_server["Inference API"]
  node_api_server["FastAPI Server<br/>inference api<br/>[main.py]"]
  node_upload_input["Image Upload<br/>request payload"]
  node_response["Predictions<br/>json response"]
end

subgraph group_assets["Model & Content"]
  node_research_pdf["Paper PDF<br/>static asset<br/>[RE_Paper.pdf]"]
  node_model_weights[("YOLOv8 Weights<br/>ml artifact<br/>[best.pt]")]
end

subgraph group_deploy["Deployment"]
  node_docker_main["Docker Build<br/>container"]
  node_docker_render["Render Build<br/>container<br/>[Dockerfile.render]"]
  node_docker_hf["HF Build<br/>container"]
end

subgraph group_support["Supporting"]
  node_legacy_backend["Legacy App<br/>archive<br/>[app_legacy.py]"]
  node_notebooks["Notebooks<br/>experimentation"]
end

node_browser(("User Browser<br/>runtime"))

node_browser -->|"loads UI"| node_app_shell
node_app_shell -->|"routes to"| node_home_page
node_app_shell -->|"routes to"| node_demo_page
node_app_shell -->|"routes to"| node_research_page
node_app_shell -->|"routes to"| node_contact_page
node_app_shell -->|"uses"| node_navbar
node_app_shell -->|"uses"| node_footer
node_app_shell -->|"styled by"| node_styles
node_demo_page -->|"reads"| node_api_url
node_demo_page -->|"posts"| node_upload_input
node_upload_input -->|"sent to"| node_api_server
node_research_page -->|"serves"| node_research_pdf
node_api_server -->|"loads"| node_model_weights
node_api_server -->|"returns"| node_response
node_api_server -->|"serves results to"| node_browser
node_api_server -.->|"replaces"| node_legacy_backend
node_docker_main -->|"packages"| node_api_server
node_docker_render -->|"packages"| node_api_server
node_docker_hf -->|"packages"| node_api_server
node_notebooks -.->|"produced offline"| node_model_weights

click node_app_shell "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/App.jsx"
click node_home_page "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/HomePage.jsx"
click node_demo_page "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/DemoPage.jsx"
click node_research_page "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/ResearchPage.jsx"
click node_contact_page "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/ContactPage.jsx"
click node_navbar "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/Navbar.jsx"
click node_footer "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/Footer.jsx"
click node_styles "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/index.css"
click node_research_pdf "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/public/research/RE_Paper.pdf"
click node_api_server "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/server/main.py"
click node_model_weights "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/models/best.pt"
click node_legacy_backend "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/server/archive/app_legacy.py"
click node_docker_main "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/tree/master/Dockerfile"
click node_docker_render "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/Dockerfile.render"
click node_docker_hf "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/Dockerfile.huggingface"
click node_notebooks "https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/notebooks/MinorProject COLAB File.ipynb"

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_app_shell,node_home_page,node_demo_page,node_research_page,node_contact_page,node_navbar,node_footer,node_styles,node_api_url toneBlue
class node_api_server,node_upload_input,node_response toneAmber
class node_research_pdf,node_model_weights toneMint
class node_docker_main,node_docker_render,node_docker_hf toneRose
class node_legacy_backend,node_notebooks toneIndigo
class node_browser toneNeutral
```

## Components

### Frontend

React/Vite SPA, shared layout, and static content delivery.

- [App Shell](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/App.jsx): SPA router · Top-level React app that switches between the main pages. · `client/src/App.jsx`
- [Home](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/HomePage.jsx): page · Landing page and overview content. · `client/src/pages/HomePage.jsx`
- [Demo](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/DemoPage.jsx): inference UI · Primary upload-and-predict interaction surface. · `client/src/pages/DemoPage.jsx`
- [Research](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/ResearchPage.jsx): content page · Presents paper and results/metrics. · `client/src/pages/ResearchPage.jsx`
- [Contact](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/pages/ContactPage.jsx): info page · Team and contact information. · `client/src/pages/ContactPage.jsx`
- [Navbar](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/Navbar.jsx): layout · Shared top navigation. · `client/src/Navbar.jsx`
- [Footer](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/Footer.jsx): layout · Shared bottom layout element. · `client/src/Footer.jsx`
- [Styles](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/src/index.css): css · Centralized app styling. · `client/src/index.css`
- **API URL**: env config · Backend base URL configured for the frontend build.

### Inference API

FastAPI service that loads the model and serves predictions.

- [FastAPI Server](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/server/main.py): inference api · Backend service exposing status and prediction endpoints. · `server/main.py`
- **Image Upload**: request payload · Uploaded underwater fish image sent from the demo UI.
- **Predictions**: json response · Detection results with boxes, labels, and confidence scores.

### Model & Content

Trained weights and research artifacts used by the app.

- [Paper PDF](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/client/public/research/RE_Paper.pdf): static asset · Research paper served statically by the frontend build. · `client/public/research/RE_Paper.pdf`
- [YOLOv8 Weights](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/models/best.pt): ml artifact · Trained detector/classifier used for inference. · `models/best.pt`

### Deployment

Container and platform-specific serving entry points.

- [Docker Build](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/tree/master/Dockerfile): container · Unified container entry point for self-hosted deployment. · `Dockerfile`
- [Render Build](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/Dockerfile.render): container · Backend-only container variant for Render. · `Dockerfile.render`
- [HF Build](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/Dockerfile.huggingface): container · Backend-only container variant for Hugging Face Spaces. · `Dockerfile.huggingface`

### Supporting

Legacy, notebooks, and sample artifacts around the core system.

- [Legacy App](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/master/server/archive/app_legacy.py): archive · Older backend implementation kept for reference. · `server/archive/app_legacy.py`
- [Notebooks](https://github.com/kadapalanikith/underwater-fish-classification-yolov8/blob/HEAD/notebooks/MinorProject%20COLAB%20File.ipynb): experimentation · Offline experimentation and reproducibility artifacts. · `notebooks/MinorProject COLAB File.ipynb`

### Other components

- **User Browser**: runtime · End user opens the web UI and uploads fish images.

## Connections

- User Browser → App Shell: loads UI · User opens the React SPA in the browser.
- App Shell → Home: routes to · App shell displays the landing page.
- App Shell → Demo: routes to · App shell displays the main inference workflow.
- App Shell → Research: routes to · App shell displays research content.
- App Shell → Contact: routes to · App shell displays contact information.
- App Shell → Navbar: uses · Shared navigation appears across pages.
- App Shell → Footer: uses · Shared footer appears across pages.
- App Shell → Styles: styled by · Global and shared CSS shape the UI.
- Demo → API URL: reads · Frontend uses the configured backend host.
- Demo → Image Upload: posts · Demo page uploads an image for inference.
- Image Upload → FastAPI Server: sent to · The uploaded image is submitted to the inference API.
- Research → Paper PDF: serves · Research page links to the statically hosted paper.
- FastAPI Server → YOLOv8 Weights: loads · Backend loads the trained YOLOv8 artifact at startup.
- FastAPI Server → Predictions: returns · Prediction endpoint responds with structured detections.
- FastAPI Server → User Browser: serves results to · Annotated predictions are ultimately shown in the UI.
- FastAPI Server → Legacy App: replaces · Legacy backend remains only as reference.
- Docker Build → FastAPI Server: packages · Unified container bundles the backend and built frontend.
- Render Build → FastAPI Server: packages · Render deployment targets the backend service.
- HF Build → FastAPI Server: packages · Hugging Face deployment targets the backend service.
- Notebooks → YOLOv8 Weights: produced offline · Notebooks represent experimentation that led to the trained weights.
