# openpowerlifting/openlifter-custom architecture

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

- Interactive diagram: https://gitdiagram.com/openpowerlifting/openlifter-custom
- Repository: https://github.com/openpowerlifting/openlifter-custom

## Overview

##### Project Type and Purpose
- This is not a traditional full‑stack application but a set of prebuilt, static PWA/Electron “client” bundles.
- Each subfolder under `releases/` (e.g. `advanced-training-center`, `blue-collar-barbell`, etc.) is a self‐contained build of the OpenLifter front‑end, packaged both as a Progressive Web App (PWA) and with an Electron wrapper (`electron.js`).
- The repo holds only the build‐output (HTML, CSS, JS, manifests, service worker scripts); the actual source lives on GitLab in “custom-” branches.

##### File Structure Analysis
- Root: `index.html` (likely a landing or redirect page), `README.md`, `CNAME`, `LICENSE`.
- `releases/` top‑level directory: contains one folder per custom client.
- Each release folder contains:
- `index.html` – PWA entrypoint
- `static/` – generated assets (CSS/JS chunks, maps, media)
- `asset-manifest.json`, `manifest.json` – PWA metadata
- `service-worker.js` or related precache manifests – offline caching
- `electron.js` – Electron main process script
- Sub‑directories for each app feature (about, debug, flight-order, lifting, meet-setup, registration, results, weigh-ins, etc.) each with their own `index.html`.
- No server‑side code here—only client‑side builds.

a. Main Components
- Static Host / CDN (e.g., GitHub Pages, S3/CloudFront) serving:
- HTML files (`index.html` per release + feature pages)
- Static asset bundles (`static/css`, `static/js`, media)
- Manifests and service worker scripts
- Client Runtime – two flavors:
1. Browser (PWA)
2. Electron App (desktop)
- Service Worker (caching & offline)
- Browser Storage (IndexedDB/localStorage) for offline data (if used)
- (Optional) External API Endpoint – if the PWA fetches data (not in this build output but likely present in source)

b. Relationships & Data Flows
- User’s browser/Electron starts by requesting `index.html` from Static Host.
- `index.html` loads JS bundles from `/static/js/*.js`.
- On first visit, Service Worker installs and caches assets; subsequent loads come from cache.
- Electron’s main process (`electron.js`) spawns a `BrowserWindow` pointed at the local `index.html` URL.
- In both runtimes, the SPA code renders feature pages and (optionally) calls out to external services (e.g. OpenPowerlifting API).
- Local data (user entries, registrations, results) persists in the browser’s IndexedDB or localStorage.

c. Architectural Patterns & Principles
- Static Pre‑Rendering + Client‑Side Routing (a “static SPA” architecture)
- Progressive Enhancement via Service Worker (PWA caching, offline capability)
- Desktop Wrapping via Electron (separation of main process vs renderer process)
- Reusable Build Pipeline – every release shares the same build artifacts pattern, just with different branding/config.

d. Key Technologies
- React (implied by `chunk.js` naming conventions) or other webpack‑based bundler
- Service Worker / Workbox (for precache manifests)
- Web App Manifest (`manifest.json`)
- Electron (for `electron.js`)
- Static hosting (GitHub Pages, S3, Netlify, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hosting Layer
    StaticHost["Static Host / CDN"]:::host
    click StaticHost "https://github.com/openpowerlifting/openlifter-custom/blob/master/index.html"

    %% Custom Client Bundle Group
    subgraph "Custom OpenLifter Client (per release)"
        direction TB
        ReleaseBundles["Release Bundles Directory"]:::host
        click ReleaseBundles "https://github.com/openpowerlifting/openlifter-custom/tree/master/releases/"

        %% PWA Runtime
        PWA["Browser (PWA)"]:::client
        click PWA "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/index.html"

        Manifest["Web App Manifest"]:::client
        click Manifest "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/manifest.json"

        AssetManifest["Asset Manifest"]:::client
        click AssetManifest "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/asset-manifest.json"

        ServiceWorker["Service Worker"]:::cache
        click ServiceWorker "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/blue-collar-barbell/service-worker.js"

        Precache["Precache Manifest"]:::cache
        click Precache "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/burley-strength/precache-manifest.ff64f2908070e78d3648aa429aad5b33.js"

        StaticJS["Static JS Bundles"]:::client
        click StaticJS "https://github.com/openpowerlifting/openlifter-custom/tree/master/releases/advanced-training-center/static/js/"

        StaticCSS["Static CSS Bundles"]:::client
        click StaticCSS "https://github.com/openpowerlifting/openlifter-custom/tree/master/releases/advanced-training-center/static/css/"

        %% SPA Routes
        subgraph "SPA Feature Routes"
            direction TB
            About["About Page"]:::client
            click About "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/about/index.html"

            Debug["Debug Page"]:::client
            click Debug "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/debug/index.html"

            FlightOrder["Flight Order Page"]:::client
            click FlightOrder "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/flight-order/index.html"

            Lifting["Lifting Page"]:::client
            click Lifting "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/lifting/index.html"

            MeetSetup["Meet Setup Page"]:::client
            click MeetSetup "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/meet-setup/index.html"

            Registration["Registration Page"]:::client
            click Registration "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/registration/index.html"

            Results["Results Page"]:::client
            click Results "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/results/index.html"

            WeighIns["Weigh‑Ins Page"]:::client
            click WeighIns "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/weigh-ins/index.html"
        end

        %% Browser Storage
        Storage["Browser Storage (IndexedDB/localStorage)"]:::cache

        %% Electron Runtime
        ElectronMain["Electron Main Process"]:::client
        click ElectronMain "https://github.com/openpowerlifting/openlifter-custom/blob/master/releases/advanced-training-center/electron.js"

        ElectronRenderer["Electron Renderer (BrowserWindow)"]:::client
    end

    %% External API (optional)
    ExternalAPI["External Data API"]:::external

    %% Connections
    StaticHost --> ReleaseBundles
    ReleaseBundles --> PWA
    ReleaseBundles --> ElectronMain

    PWA -->|"loads manifest"| Manifest
    PWA -->|"loads asset manifest"| AssetManifest
    PWA -->|"registers"| ServiceWorker
    ServiceWorker -->|"installs/caches assets"| StaticJS
    ServiceWorker -->|"installs/caches assets"| StaticCSS
    PWA -->|"fetches bundles"| StaticJS
    PWA -->|"fetches bundles"| StaticCSS
    PWA -->|"routes to feature pages"| About
    PWA -->|"routes to feature pages"| Debug
    PWA -->|"routes to feature pages"| FlightOrder
    PWA -->|"routes to feature pages"| Lifting
    PWA -->|"routes to feature pages"| MeetSetup
    PWA -->|"routes to feature pages"| Registration
    PWA -->|"routes to feature pages"| Results
    PWA -->|"routes to feature pages"| WeighIns
    PWA -->|"read/write data"| Storage
    PWA -->|". . . optional"| ExternalAPI

    ElectronMain -->|"spawns"| ElectronRenderer
    ElectronRenderer -->|"loads same assets"| StaticJS
    ElectronRenderer -->|"loads same assets"| StaticCSS
    ElectronRenderer -->|"registers"| ServiceWorker
    ElectronRenderer -->|"loads manifest"| Manifest
    ElectronRenderer -->|"loads asset manifest"| AssetManifest
    ElectronRenderer -->|"read/write data"| Storage
    ElectronRenderer -->|". . . optional"| ExternalAPI

    %% Documentation
    RootDocs["README.md / LICENSE / CNAME"]:::host

    StaticHost --> RootDocs

    %% Styles
    classDef host fill:#cce5ff,stroke:#66b0ff;
    classDef client fill:#d4edda,stroke:#28a745;
    classDef cache fill:#fff3cd,stroke:#ffecb5;
    classDef external fill:#e2e3e5,stroke:#d6d8db;
```
