# zyacub/dietnerd-website architecture

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

- Interactive diagram: https://gitdiagram.com/zyacub/dietnerd-website
- Repository: https://github.com/zyacub/dietnerd-website

## Overview

##### Project type and purpose
- This is a static‐frontend web application (“DietNerd”) whose sole purpose is to deliver an evidence‐based diet/nutrition Q&A interface in the browser.
- The project handles query input, result display, reference exploration, PDF exports, and a contact form—but all dynamic data comes from an external backend API (https://github.com/zyacub/dietnerd-backend).

##### File structure
- Top‐level files:
- index.html / index.js / index.css – main Q&A UI
- reference.html / reference.js / reference.css – deep‐dive references viewer
- about.html / about.css – static “About” page
- contact.html / contact.css – contact‐form page
- assets/ – static images (e.g., logo)
- env.js – holds API endpoint and email‐service configuration
- No backend code here; all API calls are performed from the frontend via JavaScript fetch/XHR.

##### README for additional insights
- Confirms the frontend tech stack (HTML/CSS/JS) and points to the backend repo.
- Lists core features: diet Q&A, suggestions, references with PDF generation, contact form.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "DietNerd Frontend UI"
        direction TB
        QueryUI["Query UI<br/>(index.html, index.js, index.css)"]:::frontend
        ReferenceViewer["Reference Viewer<br/>(reference.html, reference.js, reference.css)"]:::frontend
        AboutPage["About Page<br/>(about.html, about.css)"]:::frontend
        ContactForm["Contact Form<br/>(contact.html, contact.css)"]:::frontend
        StaticAssets["Static Assets<br/>(assets/)"]:::frontend
        EnvConfig["Env Config<br/>(env.js)"]:::config
        Documentation["Project Documentation<br/>(README.md)"]:::config
    end

    %% Backend and Services
    BackendAPI["DietNerd Backend API"]:::backend
    DB["Database"]:::db
    EmailService["Email Service"]:::external
    PDFService["PDF Generator"]:::external
    JournalLinks["Scientific Journal Links"]:::external

    %% Connections: Frontend to Backend
    QueryUI -->|"GET /api/query"| BackendAPI
    QueryUI -->|"GET /api/suggestions"| BackendAPI
    ReferenceViewer -->|"GET /api/reference"| BackendAPI
    ContactForm -->|"POST /api/contact"| BackendAPI

    %% Config relation
    EnvConfig -.->|"configures endpoints"| QueryUI
    EnvConfig -.->|"configures endpoints"| ReferenceViewer
    EnvConfig -.->|"configures endpoints"| ContactForm

    %% Backend to internal and external services
    BackendAPI -->|"reads/writes"| DB
    BackendAPI -->|"sends email via API"| EmailService
    BackendAPI -->|"requests PDF generation"| PDFService

    %% Client-side optional PDF
    QueryUI -.->|"uses jsPDF library"| PDFService

    %% Reference links
    ReferenceViewer -->|"opens articles"| JournalLinks

    %% Click events
    click QueryUI "https://github.com/zyacub/dietnerd-website/blob/master/index.html"
    click QueryUI "https://github.com/zyacub/dietnerd-website/blob/master/index.js"
    click QueryUI "https://github.com/zyacub/dietnerd-website/blob/master/index.css"
    click ReferenceViewer "https://github.com/zyacub/dietnerd-website/blob/master/reference.html"
    click ReferenceViewer "https://github.com/zyacub/dietnerd-website/blob/master/reference.js"
    click ReferenceViewer "https://github.com/zyacub/dietnerd-website/blob/master/reference.css"
    click AboutPage "https://github.com/zyacub/dietnerd-website/blob/master/about.html"
    click AboutPage "https://github.com/zyacub/dietnerd-website/blob/master/about.css"
    click ContactForm "https://github.com/zyacub/dietnerd-website/blob/master/contact.html"
    click ContactForm "https://github.com/zyacub/dietnerd-website/blob/master/contact.css"
    click StaticAssets "https://github.com/zyacub/dietnerd-website/tree/master/assets/"
    click EnvConfig "https://github.com/zyacub/dietnerd-website/blob/master/env.js"
    click Documentation "https://github.com/zyacub/dietnerd-website/blob/master/README.md"

    %% Styling
    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef backend fill:#ffcdd2,stroke:#b71c1c,color:#b71c1c;
    classDef db fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20;
    classDef external fill:#e0e0e0,stroke:#424242,color:#424242;
    classDef config fill:#fff9c4,stroke:#f57f17,color:#f57f17;
```
