# kasmtech/workspaces_registry_template architecture

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

## Overview

##### Main Components
- Data Layer (File System)
– workspaces/ directory: per‐workspace folders containing workspace.json and image assets
– site/public/list.json: generated registry index used by the front end
- Processing Layer (Node.js Scripts)
– processing/processjson.js: aggregates workspace JSON into list.json and computes channels
– processing/add_next_version.js & get_image_sizes.js: automation for version bumps and size metadata
– processing/update_1_0_to_1_1.js: migration between schema versions
- Front-End Layer (Next.js Site)
– site/pages & site/components: React pages (index, new workspace) and UI components (header, footer, Bubbles, Workspace)
– site/next.config.js + Tailwind CSS (postcss.config.js / tailwind.config.js)
- CI/CD Pipeline
– .github/workflows/build-and-deploy.yml: GitHub Actions to run build_all_branches.sh on push/PR
– build_all_branches.sh: orchestrates checks out of each branch, runs processing scripts, builds Next.js, and deploys to gh-pages
- Deployment & Hosting
– GitHub Pages (gh-pages branch): serves the static Next.js output
- External Client
– Kasm Workspaces instances: fetch registry JSON at runtime to present available workspaces

##### Relationships & Data Flows
1. Developer pushes changes → GitHub Actions workflow triggers
2. build_all_branches.sh runs:
a. Invokes processing scripts to read workspaces/* JSON, update schema or versions, write site/public/list.json
b. Builds Next.js static site (SSG) using the generated list.json and React components
3. Workflow deploys built artifacts to gh-pages branch → GitHub Pages publishes the site
4. End users/Kasm Workspaces instances fetch registry URL (env.listUrl) to list & instantiate workspaces

##### Architectural Patterns & Principles
- Static Site Generation (SSG) with dynamic content driven by file‐based CMS (workspaces JSON)
- Monorepo structure separating data (workspaces/), processing (“backend” scripts), and front end (site/)
- CI/CD pipeline as the glue – automates data processing, build, and deploy across multiple schema branches
- Environment‐driven configuration (next.config.js env vars for name, description, basePath, etc.)

##### Incorporate Relevant Technologies & Frameworks
– Node.js & npm (processing scripts, build tools)
– Next.js (React framework for pages, static exports)
– Tailwind CSS (utility‐first styling)
– GitHub Actions (CI/CD)
– GitHub Pages (static hosting)
– JSON schema for workspace definitions and version compatibility

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer
    Dev["Developer"]:::external
    Dev -->|trigger build| GHActions

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GHActions["GitHub Actions\n.build-and-deploy.yml"]:::cicd
        BuildScript["build_all_branches.sh"]:::cicd
    end
    click GHActions "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/.github/workflows/build-and-deploy.yml"
    click BuildScript "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/build_all_branches.sh"
    GHActions -->|run build script| BuildScript

    %% Processing Layer
    subgraph "Processing Layer"
        direction TB
        ProcessJSON["processjson.js\n(Aggregate JSON)"]:::compute
        AddNext["add_next_version.js\n(Version Bump)"]:::compute
        GetSizes["get_image_sizes.js\n(Size Metadata)"]:::compute
        UpdateSchema["update_1_0_to_1_1.js\n(Schema Migration)"]:::compute
    end
    click ProcessJSON "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/processing/processjson.js"
    click AddNext "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/processing/add_next_version.js"
    click GetSizes "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/processing/get_image_sizes.js"
    click UpdateSchema "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/processing/update_1_0_to_1_1.js"

    BuildScript -->|invoke processing| ProcessJSON
    BuildScript --> AddNext
    BuildScript --> GetSizes
    BuildScript --> UpdateSchema

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Workspaces["workspaces/ (JSON & Assets)"]:::data
        ListJSON["site/public/list.json"]:::data
    end
    click Workspaces "https://github.com/kasmtech/workspaces_registry_template/tree/1.1/workspaces/"
    click ListJSON "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/site/public/list.json"

    ProcessJSON -->|read/write| Workspaces
    AddNext -->|update| Workspaces
    GetSizes -->|analyze| Workspaces
    UpdateSchema -->|migrate| Workspaces
    ProcessJSON -->|generate registry| ListJSON

    %% Front-End Layer
    subgraph "Front-End Layer"
        direction TB
        Pages["site/pages/ (Next.js Pages)"]:::frontend
        Components["site/components/ (React UI)"]:::frontend
        NextConfig["site/next.config.js"]:::frontend
        TailwindCfg["Tailwind CSS Config\npostcss.config.js\n tailwind.config.js"]:::frontend
        NextBuild["Next.js Build Engine"]:::frontend
        StaticSite["Static Site (SSG)"]:::frontend
    end
    click Pages "https://github.com/kasmtech/workspaces_registry_template/tree/1.1/site/pages/"
    click Components "https://github.com/kasmtech/workspaces_registry_template/tree/1.1/site/components/"
    click NextConfig "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/site/next.config.js"
    click TailwindCfg "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/site/tailwind.config.js"
    click TailwindCfg "https://github.com/kasmtech/workspaces_registry_template/blob/1.1/site/postcss.config.js"

    BuildScript -->|static export| NextBuild
    NextBuild --> Pages
    NextBuild --> Components
    NextBuild --> NextConfig
    NextBuild --> TailwindCfg
    NextBuild --> StaticSite

    %% Deployment & Hosting
    subgraph "Deployment & Hosting"
        direction TB
        GHPages["GitHub Pages\n(gh-pages branch)"]:::hosting
    end
    StaticSite -->|deploy| GHPages

    %% External Clients
    KasmClient["Kasm Workspaces\nInstances"]:::external
    KasmClient -->|fetch registry| GHPages

    %% Styles
    classDef data fill:#cce5ff,stroke:#3399ff,stroke-width:1px
    classDef compute fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef frontend fill:#d1ecf1,stroke:#17a2b8,stroke-width:1px
    classDef cicd fill:#ffeeba,stroke:#fd7e14,stroke-width:1px
    classDef hosting fill:#e2e3e5,stroke:#6f42c1,stroke-width:1px
    classDef external fill:#f8f9fa,stroke:#6c757d,stroke-width:1px
```
