# tinaduo/fishydex architecture

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

- Interactive diagram: https://gitdiagram.com/tinaduo/fishydex
- Repository: https://github.com/tinaduo/fishydex

## Overview

##### Main Components
- Backend Server: Represented by server.js, which sets up an Express.js server.
- Frontend: Consists of static assets (found in the public directory such as CSS, images, fonts, and audio files) and dynamic EJS templates (located under views/pages).
- Database: PostgreSQL (with details in the README) accessed possibly through Supabase as an external service.
- Data Files: The fish.csv file indicates that there may be initial data or seed data for the fish species.

##### Relationships and Interactions
- The Express.js server (server.js) acts as the central hub, managing HTTP requests, routing, and middleware.
- The server dynamically renders views using EJS templates (e.g., add.ejs, fish.ejs, home.ejs, index.ejs, project-info.ejs) that form the user interface.
- Static assets in the public folder are served to enrich the website with style and interactivity.
- The backend communicates with the PostgreSQL database (and possibly uses Supabase credentials from the .env file) to fetch, insert, and update fish data.
- Form submissions and API calls likely flow from the frontend to backend endpoints, and from there, queries run against the database.

##### Architectural Patterns and Design Principles
- Model-View-Controller (MVC) Pattern:
- Views: EJS templates and public assets.
- Controller: The Express.js routing logic in server.js.
- Model: The data layer with PostgreSQL, with potential ORM or explicit SQL queries.
- Separation of Concerns: Frontend and backend are clearly separated via the public and views directories versus server.js handling route logic.

##### Relevant Technologies
- Express.js and Node.js manage server-side logic.
- EJS templates are used for dynamic HTML generation.
- PostgreSQL (and possibly Supabase as a hosting or connection layer) for the database.
- HTML, CSS, and JavaScript for the client-side experience.
- Additional external assets like audio files highlight enhanced user experience features (e.g., sound effects).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser("Web Browser"):::client
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Server("Express.js Server (server.js)"):::server
        CSV("Data Seed (fish.csv)"):::asset
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        Views("Dynamic Views (views/pages)"):::frontend
        Assets("Static Assets (public/...)"):::asset
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["PostgreSQL Database"]:::db
        Supabase("Supabase Service"):::external
    end

    %% Connections
    Browser -->|"HTTP_Request/Response"| Server
    Server -->|"Renders"| Views
    Server -->|"Serves"| Assets
    Server -->|"Seeds_Data"| CSV
    Server <-->|"CRUD_Operations"| DB
    DB ---|"Managed_By"| Supabase

    %% Click Events
    click Server "https://github.com/tinaduo/fishydex/blob/main/server.js"
    click Views "https://github.com/tinaduo/fishydex/tree/main/views/pages"
    click Assets "https://github.com/tinaduo/fishydex/tree/main/public"
    click CSV "https://github.com/tinaduo/fishydex/blob/main/fish.csv"

    %% Styles
    classDef client fill:#dce8ef,stroke:#333,stroke-width:2px;
    classDef server fill:#f9d3b4,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bde0fe,stroke:#333,stroke-width:2px;
    classDef asset fill:#ffc6ff,stroke:#333,stroke-width:2px;
    classDef db fill:#caffbf,stroke:#333,stroke-width:2px;
    classDef external fill:#f4a261,stroke:#333,stroke-width:2px;
```
