# aldenhallak/fishes architecture

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

- Interactive diagram: https://gitdiagram.com/aldenhallak/fishes
- Repository: https://github.com/aldenhallak/fishes

## Overview

##### Project type and purpose
- DrawAFish.com is a browser‐based, client‐heavy interactive drawing application. It uses an ONNX neural network in the browser for real-time fish drawing validation, Firebase for real-time data sync, and a serverless backend (`fish-be`) for image processing, persistence, and moderation endpoints.

##### File structure
- Root HTML pages (index.html, tank.html, rank.html, login.html, moderation.html, etc.) form distinct UI “views.”
- `src/js/` contains page controllers and shared utilities:
- `app.js` drives the drawing canvas and ONNX inference.
- `tank.js`, `rank.js`, `login.js`, `moderation.js`, etc., each handle a specific view’s logic.
- `firebase-init.js` and `fish-utils.js` initialize Firebase and encapsulate all API/Firestore calls.
- `src/css/` holds style definitions scoped by page or component.
- `fish_doodle_classifier.onnx` is the client-side ML model.
- No monolithic backend code here: it’s a static site that calls out to a separate serverless backend (`fish-be`).

##### Key insights from the README
- The ONNX model runs entirely in the browser (ONNX Runtime Web).
- Firebase/Firestore is used for real-time updates (community tank, votes, profiles).
- A serverless backend (Cloud Run or equivalent) handles uploads, moderation endpoints, and persists canonical images.
- Static assets are deployed to a CDN or static hosting service (e.g., Netlify, Vercel, Firebase Hosting).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CDN Layer
    CDN["CDN / Static Host"]:::external
    CDN -->|"HTTPS"| Browser

    %% Client Browser
    subgraph "Browser (Client)" 
        direction TB
        subgraph "HTML Views" 
            direction TB
            Index["index.html"]:::frontend
            TankPage["tank.html"]:::frontend
            Fishtanks["fishtanks.html"]:::frontend
            FishtankView["fishtank-view.html"]:::frontend
            Rank["rank.html"]:::frontend
            Login["login.html"]:::frontend
            ResetPwd["reset-password.html"]:::frontend
            ProfilePage["profile.html"]:::frontend
            ModerationPage["moderation.html"]:::frontend
            SwipeMod["swipe-moderation.html"]:::frontend
        end
        subgraph "JS Controllers & Utilities"
            direction TB
            App["app.js\n(Canvas & Inference)"]:::frontend
            TankJS["tank.js"]:::frontend
            FishtanksJS["fishtanks.js"]:::frontend
            FishtankViewJS["fishtank-view.js"]:::frontend
            RankJS["rank.js"]:::frontend
            LoginJS["login.js"]:::frontend
            ResetJS["reset-password.js"]:::frontend
            ProfileJS["profile.js"]:::frontend
            ModJS["moderation.js"]:::frontend
            SwipeModJS["swipe-moderation.js"]:::frontend
            FirebaseInit["firebase-init.js"]:::frontend
            FishUtils["fish-utils.js"]:::frontend
            FooterUtils["footer-utils.js"]:::frontend
            ModalUtils["modal-utils.js"]:::frontend
        end
        ONNXModel["fish_doodle_classifier.onnx"]:::ml
    end

    %% Firebase Services
    subgraph "Firebase Services" 
        direction TB
        Auth["Authentication"]:::dataServices
        Firestore["Firestore Database"]:::dataServices
        Storage["Cloud Storage"]:::dataServices
    end

    %% Serverless Backend
    subgraph "Serverless Backend (fish-be)" 
        direction TB
        API["Image API & Moderation"]:::backend
    end

    %% External ML Training
    MLTrainer["fish-trainer (Model Training)"]:::external

    %% Relationships
    Browser -->|"Firebase SDK"| Auth
    Browser -->|"Firebase SDK"| Firestore
    Browser -->|"Firebase SDK"| Storage
    Browser -->|"ONNX Runtime Web"| ONNXModel
    Browser -->|"HTTPS / REST"| API
    API -->|"Writes approved submissions"| Firestore
    MLTrainer -->|"Produces model"| ONNXModel

    %% Click Events for HTML
    click Index "https://github.com/aldenhallak/fishes/blob/main/index.html"
    click TankPage "https://github.com/aldenhallak/fishes/blob/main/tank.html"
    click Fishtanks "https://github.com/aldenhallak/fishes/blob/main/src/js/fishtanks.js"
    click FishtankView "https://github.com/aldenhallak/fishes/blob/main/fishtank-view.html"
    click Rank "https://github.com/aldenhallak/fishes/blob/main/rank.html"
    click Login "https://github.com/aldenhallak/fishes/blob/main/login.html"
    click ResetPwd "https://github.com/aldenhallak/fishes/blob/main/reset-password.html"
    click ProfilePage "https://github.com/aldenhallak/fishes/blob/main/profile.html"
    click ModerationPage "https://github.com/aldenhallak/fishes/blob/main/moderation.html"
    click SwipeMod "https://github.com/aldenhallak/fishes/blob/main/swipe-moderation.html"

    %% Click Events for JS
    click App "https://github.com/aldenhallak/fishes/blob/main/src/js/app.js"
    click TankJS "https://github.com/aldenhallak/fishes/blob/main/src/js/tank.js"
    click FishtanksJS "https://github.com/aldenhallak/fishes/blob/main/src/js/fishtanks.js"
    click FishtankViewJS "https://github.com/aldenhallak/fishes/blob/main/src/js/fishtank-view.js"
    click RankJS "https://github.com/aldenhallak/fishes/blob/main/src/js/rank.js"
    click LoginJS "https://github.com/aldenhallak/fishes/blob/main/src/js/login.js"
    click ResetJS "https://github.com/aldenhallak/fishes/blob/main/src/js/reset-password.js"
    click ProfileJS "https://github.com/aldenhallak/fishes/blob/main/src/js/profile.js"
    click ModJS "https://github.com/aldenhallak/fishes/blob/main/src/js/moderation.js"
    click SwipeModJS "https://github.com/aldenhallak/fishes/blob/main/src/js/swipe-moderation.js"
    click FirebaseInit "https://github.com/aldenhallak/fishes/blob/main/src/js/firebase-init.js"
    click FishUtils "https://github.com/aldenhallak/fishes/blob/main/src/js/fish-utils.js"
    click FooterUtils "https://github.com/aldenhallak/fishes/blob/main/src/js/footer-utils.js"
    click ModalUtils "https://github.com/aldenhallak/fishes/blob/main/src/js/modal-utils.js"
    click ONNXModel "https://github.com/aldenhallak/fishes/blob/main/fish_doodle_classifier.onnx"

    %% Styles
    classDef frontend fill:#D6E9FF,stroke:#2B70D6,color:#000
    classDef dataServices fill:#D5E8D4,stroke:#2E7D32,color:#000
    classDef backend fill:#FFE5CC,stroke:#EF6C00,color:#000
    classDef ml fill:#E2D5E7,stroke:#6A1B9A,color:#000
    classDef external fill:#F0F0F0,stroke:#888,color:#000
```
