# sahvsergio/treehouse_full-stack_javascript_techdegree_unit1 architecture

> Architecture diagram of the GitHub repository sahvsergio/treehouse_full-stack_javascript_techdegree_unit1, 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/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1
- Repository: https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1

## Overview

##### Project type and purpose
- This is a small, single-page, static front-end application: a “Random Quote Generator.”
- It does not include a backend or database; all code and data live in the browser as HTML, CSS, and JavaScript.
- Purpose: on each button click, pick a random quote from an in-memory JS array and render it in the DOM.

##### File structure
- index.html: the entry point and UI skeleton.
- css/normalize.css + css/styles.css: reset and custom styling.
- js/script.js: application logic, event handlers, and quote data.
- No server-side code, build scripts, or external dependencies.

##### README
- Confirms it’s a learning project for basic JS syntax and data structures.
- No mention of REST APIs or backends.
- Core functionality: pick and display a new quote on demand.

a. Main components
- User’s Web Browser (Client)
- Static File Server (optional – e.g., GitHub Pages or local dev server)
- index.html (UI container)
- CSS Layer (normalize.css + styles.css)
- JS Logic Module (script.js)
- In-memory Quote Data Array

b. Relationships and interactions
1. Browser requests index.html (and CSS/JS assets) from the Static File Server.
2. Browser loads HTML → applies CSS → executes JS.
3. User clicks “New Quote” button in the UI.
4. JS event listener triggers:
– Picks random index from the Quote Data Array
– Updates the DOM (innerText/innerHTML of a quote container)
5. Browser re-renders updated quote on the page.

c. Architectural patterns/design principles
- Single-page, event-driven front-end.
- Clear separation of concerns:
- HTML as structure
- CSS for presentation
- JS for behavior & data
- Data kept in simple array (no persistence beyond page life).

d. Relevant technologies
- HTML5
- CSS3 (normalize + custom styles)
- Vanilla JavaScript (ES5/ES6)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Static File Server"
        Server["Static File Server"]:::server
    end
    Server -->|"serves assets"| Browser["Web Browser"]:::client

    subgraph "Browser"
        Browser -->|"loads"| HTML["index.html"]:::asset
        HTML -->|"includes"| CSSreset["normalize.css"]:::asset
        HTML -->|"includes"| CSScustom["styles.css"]:::asset
        HTML -->|"includes script"| JS["script.js"]:::logic

        subgraph "UI Elements"
            Button["New Quote Button"]:::logic
            Display["Quote Display Area"]:::asset
        end

        JS -->|"contains"| QuoteArray["In-Memory Quote Array"]:::data
        JS -->|"attaches listener to"| Button
        Button -->|"click event"| JS
        JS -->|"updates DOM"| Display
        Display -->|"renders quote"| Browser
    end

    Docs["README.md"]:::docs

    click HTML "https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1/blob/main/index.html"
    click CSSreset "https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1/blob/main/css/normalize.css"
    click CSScustom "https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1/blob/main/css/styles.css"
    click JS "https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1/blob/main/js/script.js"
    click Docs "https://github.com/sahvsergio/treehouse_full-stack_javascript_techdegree_unit1/blob/main/README.md"

    classDef asset fill:#ADD8E6,stroke:#000;
    classDef logic fill:#90EE90,stroke:#000;
    classDef data fill:#FFA500,stroke:#000;
    classDef server fill:#D3D3D3,stroke:#000;
    classDef client fill:#FFFFFF,stroke:#000;
    classDef docs fill:#DCDCDC,stroke:#000;
```
