# jonashcroft/nowify architecture

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

- Interactive diagram: https://gitdiagram.com/jonashcroft/nowify
- Repository: https://github.com/jonashcroft/nowify

## Overview

##### Project type and purpose
- Nowify is a Jamstack‐style, client‐only Single Page Application (SPA) built with Vue.js.
- It’s meant to run as a static site (hosted on Netlify or similar), fetch your currently playing Spotify track via the Spotify Web API, and display it on a display device (e.g., Raspberry Pi).

##### File structure
- Top‐level files:
- package.json, babel.config.js, .eslintrc.js, .prettierrc → build tool configuration
- .env.sample → names of env vars (SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET)
- public/index.html → host page template
- assets/ → static images for README preview
- src/
- main.js → Vue app bootstrap
- App.vue → root component
- components/ → UI pieces: Authorise.vue, NowPlaying.vue
- utils/ → helper functions and prop definitions (e.g., token handling, API calls)
- styles/ → Sass organization (global variables, base styles, component styles)

##### Key details from the README
- Deploys via Netlify (CI/CD): on push to GitHub, Netlify builds & deploys.
- Requires two Spotify API credentials as environment variables at build time.
- On load, the client SPA handles OAuth flow with Spotify, requests “currently playing” endpoint, and renders cover art + vibrant background.

##### Main components & interactions (
a. Developer Workflow & CI/CD
- GitHub repo
- Netlify Build & Deploy (CI)
- Environment Variables injected at build time
- Output: static assets (HTML, JS, CSS) → CDN distribution
b. Client Side
- Browser or Raspberry Pi WebView loads index.html + bundled JS/CSS
- Vue.js SPA (App.vue → NowPlaying.vue / Authorise.vue)
- OAuth flow: SPA → Spotify Authorization Endpoint → user login → redirect back with code/token
- Token management in utils (access & refresh tokens) stored in browser (localStorage/cookies)
- Fetch “currently playing” REST call to Spotify Web API
c. External Service
- Spotify Web API (Authorization & Playback endpoints)

##### Architectural patterns & principles
- Jamstack: pre-built static assets + client-side rendering
- Component-based UI (Vue.js)
- Externalized configuration (env vars)
- Unidirectional data flow: utils → components → view

##### Technologies & frameworks
- Vue.js (SPA framework)
- Sass/SCSS (styles)
- Netlify (CI/CD + static hosting)
- Spotify Web API (OAuth 2.0 + REST endpoints)
- Babel, ESLint, Prettier (tooling)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Build Environment
    subgraph "Build Environment"
        Dev["Developer"]:::infra
        Repo["GitHub Repo"]:::infra
        EnvSample[".env.sample"]:::infra
        NetlifyBuild["Netlify Build & Deploy"]:::infra
    end

    %% CDN & Hosting
    subgraph "CDN & Hosting"
        CDN["CDN (Static Assets)"]:::infra
    end

    %% Runtime Environment
    subgraph "Runtime Environment"
        Browser["Browser / WebView"]:::client
        Index["public/index.html"]:::client
        SPA["Vue SPA"]:::client
        Main["main.js"]:::client
        App["App.vue"]:::client
        Authorise["Authorise.vue"]:::client
        NowPlaying["NowPlaying.vue"]:::client
        Utils["utils.js"]:::client
        Props["props.js"]:::client

        subgraph "Global Styles"
            Variables["variables.scss"]:::client
            Reset["reset.scss"]:::client
            Base["base.scss"]:::client
            Typography["typography.scss"]:::client
            AppStyles["app.scss"]:::client
        end

        subgraph "Component Styles"
            AuthStyle["authorise.scss"]:::client
            NowStyle["now-playing.scss"]:::client
            BtnStyle["buttons.scss"]:::client
        end
    end

    %% External Services
    SpotifyAuth["Spotify Authorization Endpoint"]:::external
    SpotifyAPI["Spotify Playback Endpoint"]:::external

    %% Connections
    Dev --> Repo
    Repo --> NetlifyBuild
    EnvSample --> NetlifyBuild
    NetlifyBuild --> CDN
    CDN --> Browser
    Browser --> Index
    Index --> SPA
    SPA --> Main
    Main --> App
    App --> Authorise
    App --> NowPlaying
    Authorise --> Utils
    NowPlaying --> Utils
    Utils --> Props
    SPA --> Variables
    SPA --> Reset
    SPA --> Base
    SPA --> Typography
    SPA --> AppStyles
    SPA --> AuthStyle
    SPA --> NowStyle
    SPA --> BtnStyle
    Browser --> SpotifyAuth
    SpotifyAuth --> Browser
    Browser --> SpotifyAPI
    SpotifyAPI --> Browser

    %% Click Events
    click Utils "https://github.com/jonashcroft/nowify/blob/main/src/utils/utils.js"
    click Props "https://github.com/jonashcroft/nowify/blob/main/src/utils/props.js"
    click Main "https://github.com/jonashcroft/nowify/blob/main/src/main.js"
    click App "https://github.com/jonashcroft/nowify/blob/main/src/App.vue"
    click Authorise "https://github.com/jonashcroft/nowify/blob/main/src/components/Authorise.vue"
    click NowPlaying "https://github.com/jonashcroft/nowify/blob/main/src/components/NowPlaying.vue"
    click Index "https://github.com/jonashcroft/nowify/blob/main/public/index.html"
    click EnvSample "https://github.com/jonashcroft/nowify/blob/main/.env.sample"
    click Variables "https://github.com/jonashcroft/nowify/blob/main/src/styles/global/variables.scss"
    click Reset "https://github.com/jonashcroft/nowify/blob/main/src/styles/global/reset.scss"
    click Base "https://github.com/jonashcroft/nowify/blob/main/src/styles/global/base.scss"
    click Typography "https://github.com/jonashcroft/nowify/blob/main/src/styles/global/typography.scss"
    click AppStyles "https://github.com/jonashcroft/nowify/blob/main/src/styles/global/app.scss"
    click AuthStyle "https://github.com/jonashcroft/nowify/blob/main/src/styles/components/authorise.scss"
    click NowStyle "https://github.com/jonashcroft/nowify/blob/main/src/styles/components/now-playing.scss"
    click BtnStyle "https://github.com/jonashcroft/nowify/blob/main/src/styles/components/buttons.scss"
    click Package "https://github.com/jonashcroft/nowify/blob/main/package.json"
    click Babel "https://github.com/jonashcroft/nowify/blob/main/babel.config.js"
    click ESLint "https://github.com/jonashcroft/nowify/blob/main/.eslintrc.js"
    click Prettier "https://github.com/jonashcroft/nowify/blob/main/.prettierrc"
    click Browsers "https://github.com/jonashcroft/nowify/blob/main/ .browserslistrc"
    click Assets "https://github.com/jonashcroft/nowify/tree/main/assets/"

    %% Styles
    classDef infra fill:#AED6F1,stroke:#2E86C1,color:#1B4F72
    classDef client fill:#ABEBC6,stroke:#239B56,color:#186A3B
    classDef external fill:#F5CBA7,stroke:#E67E22,color:#873600
    classDef code fill:#E5E7E9,stroke:#A6ACAF,color:#424949
```
