# erickosanchezj/madness-schedule architecture

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

- Interactive diagram: https://gitdiagram.com/erickosanchezj/madness-schedule
- Repository: https://github.com/erickosanchezj/madness-schedule

## Overview

##### Project type and purpose
- This is a full-stack Progressive Web App (PWA) for fitness studios, with two web front-ends (member app and admin panel), a real-time backend built on Firebase (Firestore, Auth, Cloud Functions), and offline/caching support via a service worker.

##### File structure
- Top-level UI assets:
- index.html (member experience)
- admin.html (staff dashboard)
- service-worker.js, manifest.json, vendor/, images/
- Firebase hosting and config:
- firebase.json, .firebaserc, firebase-config.js, sw-firebase-config.js
- build-config.js
- Serverless backend (Cloud Functions) in /functions:
- src/… .js for class generation and notifications
- lib/ pruning scripts
- functions/package.json
- Security & rules:
- firestore.rules, firestore.indexes.json
- Supporting files:
- AGENTS.md, admin-manifest.json, CNAME for custom domain

##### README for additional insights
- Two distinct user roles (members vs staff)
- Real-time data sync, push notifications, offline support
- Automated jobs for generating classes & reminders

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        direction TB
        subgraph "Member PWA" 
            direction TB
            MPWA_HTML["index.html"]:::frontend
            MPWA_MANIFEST["manifest.json"]:::frontend
            MPWA_SW["service-worker.js"]:::frontend
            MPWA_VENDOR["vendor/"]:::frontend
            MPWA_IMAGES["images/"]:::frontend
            MPWA_CFG["firebase-config.js"]:::frontend
            MPWA_SWCFG["sw-firebase-config.js"]:::frontend
        end
        subgraph "Admin PWA"
            direction TB
            APWA_HTML["admin.html"]:::frontend
            APWA_MANIFEST["admin-manifest.json"]:::frontend
            APWA_SW["service-worker.js"]:::frontend
            APWA_CFG["firebase-config.js"]:::frontend
            APWA_SWCFG["sw-firebase-config.js"]:::frontend
        end
    end

    %% Hosting & CDN
    FB_HOST["Firebase Hosting & CDN"]:::infra

    %% Data Services
    subgraph "Data Services"
        direction TB
        AUTH["Firebase Authentication"]:::data
        FIRESTORE["Cloud Firestore"]:::data
        RULES["Security Rules\nfirestore.rules"]:::note
        INDEXES["Indexes\nfirestore.indexes.json"]:::note
    end

    %% Serverless Logic
    subgraph "Serverless Logic"
        direction TB
        CF_INDEX["functions/index.js"]:::serverless
        subgraph "Business Logic Functions"
            direction TB
            CF_GEN["generateDailyClasses.js"]:::serverless
            CF_BOOK["bookingReminders.js"]:::serverless
            CF_TOTAL["totalPassReminders.js"]:::serverless
            CF_UNLOCK["userUnlockNotifications.js"]:::serverless
            CF_WAIT["waitlistNotifications.js"]:::serverless
        end
        CF_PRUNE["pruneTokenInUsers.js"]:::serverless
        CF_PKG["functions/package.json"]:::serverless
    end

    %% External Services
    FCM["Firebase Cloud Messaging"]:::external

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        BUILD_CFG["build-config.js"]:::infra
        ROOT_PKG["package.json"]:::infra
        ROOT_LOCK["package-lock.json"]:::infra
        FIRE_RC[".firebaserc"]:::infra
        FIRE_JSON["firebase.json"]:::infra
    end

    %% Relationships
    MPWA_HTML -->|serves via| FB_HOST
    APWA_HTML -->|serves via| FB_HOST
    MPWA_SW -->|caches assets & API| MPWA_HTML
    APWA_SW -->|caches assets & API| APWA_HTML

    MPWA_HTML -->|"Auth & Data calls"| AUTH
    APWA_HTML -->|"Auth & Data calls"| AUTH

    MPWA_HTML -->|"Read/Write"| FIRESTORE
    APWA_HTML -->|"Read/Write"| FIRESTORE

    FIRESTORE -->|triggers| CF_INDEX
    CF_INDEX --> CF_GEN
    CF_INDEX --> CF_BOOK
    CF_INDEX --> CF_TOTAL
    CF_INDEX --> CF_UNLOCK
    CF_INDEX --> CF_WAIT
    CF_GEN --> FCM
    CF_BOOK --> FCM
    CF_TOTAL --> FCM
    CF_UNLOCK --> FCM
    CF_WAIT --> FCM

    FCM -->|push notifications| MPWA_SW
    FCM -->|push notifications| APWA_SW

    BUILD_CFG -->|build & deploy| FB_HOST
    BUILD_CFG -->|build & deploy| CF_INDEX

    FIRE_JSON --> FB_HOST
    FIRE_RC --> FB_HOST

    FIRESTORE --- RULES
    FIRESTORE --- INDEXES

    %% Click Events - Client Side
    click MPWA_HTML "https://github.com/erickosanchezj/madness-schedule/blob/main/index.html"
    click MPWA_MANIFEST "https://github.com/erickosanchezj/madness-schedule/blob/main/manifest.json"
    click MPWA_SW "https://github.com/erickosanchezj/madness-schedule/blob/main/service-worker.js"
    click MPWA_VENDOR "https://github.com/erickosanchezj/madness-schedule/tree/main/vendor/"
    click MPWA_IMAGES "https://github.com/erickosanchezj/madness-schedule/tree/main/images/"
    click MPWA_CFG "https://github.com/erickosanchezj/madness-schedule/blob/main/firebase-config.js"
    click MPWA_SWCFG "https://github.com/erickosanchezj/madness-schedule/blob/main/sw-firebase-config.js"

    click APWA_HTML "https://github.com/erickosanchezj/madness-schedule/blob/main/admin.html"
    click APWA_MANIFEST "https://github.com/erickosanchezj/madness-schedule/blob/main/admin-manifest.json"
    click APWA_SW "https://github.com/erickosanchezj/madness-schedule/blob/main/service-worker.js"
    click APWA_CFG "https://github.com/erickosanchezj/madness-schedule/blob/main/firebase-config.js"
    click APWA_SWCFG "https://github.com/erickosanchezj/madness-schedule/blob/main/sw-firebase-config.js"

    %% Click Events - Hosting & Deployment
    click FIRE_JSON "https://github.com/erickosanchezj/madness-schedule/blob/main/firebase.json"
    click FIRE_RC "https://github.com/erickosanchezj/madness-schedule/blob/main/.firebaserc"

    %% Click Events - Data Services
    click RULES "https://github.com/erickosanchezj/madness-schedule/blob/main/firestore.rules"
    click INDEXES "https://github.com/erickosanchezj/madness-schedule/blob/main/firestore.indexes.json"

    %% Click Events - Serverless Logic
    click CF_INDEX "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/index.js"
    click CF_PKG "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/package.json"
    click CF_GEN "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/src/generateDailyClasses.js"
    click CF_BOOK "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/src/bookingReminders.js"
    click CF_TOTAL "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/src/totalPassReminders.js"
    click CF_UNLOCK "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/src/userUnlockNotifications.js"
    click CF_WAIT "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/src/waitlistNotifications.js"
    click CF_PRUNE "https://github.com/erickosanchezj/madness-schedule/blob/main/functions/lib/pruneTokenInUsers.js"

    %% Click Events - Build & Deployment
    click BUILD_CFG "https://github.com/erickosanchezj/madness-schedule/blob/main/build-config.js"
    click ROOT_PKG "https://github.com/erickosanchezj/madness-schedule/blob/main/package.json"
    click ROOT_LOCK "https://github.com/erickosanchezj/madness-schedule/blob/main/package-lock.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef serverless fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef infra fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef note fill:#FFFFFF,stroke-dasharray: 2 2,stroke:#666
```
