# elastisys/welkin architecture

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

- Interactive diagram: https://gitdiagram.com/elastisys/welkin
- Repository: https://github.com/elastisys/welkin

## Overview

##### Project type and purpose
- This repository is **not** an application backend or frontend in the traditional sense, but a **static documentation site** for the “Welkin” project.
- It also contains two **user‑demo** microprojects (Node.js and .NET) illustrating how to deploy sample services on Welkin.

##### File structure
- **Root**: configuration files (`mkdocs.yml`, `package.json`, `requirements.txt`), CI workflows (`.github/workflows/*.yml`), styling (`extra_sass/`).
- **docs/**: all Markdown source; subfolders for ADRs, architecture, user‑guide, operator‑manual, ciso‑guide, release notes, images, styles.
- **overrides/**: Jinja templates to override mkdocs-material theme.
- **mkdocs-ciso-controls/**: Python package providing custom mkdocs plugin to render CISO controls.
- **scripts/**: helper scripts to generate tables or run Graphviz (`scripts/jsonschema2md.sh`, etc.).
- **user-demo/** & **user-demo-dotnet/**: two demo apps, each with Dockerfile, Helm charts under `deploy/`, and helper scripts.

##### Read README insights
- The **tech stack**: Python 3, mkdocs, mkdocs-material, Graphviz, mike (versioned deploy), SASS, npm.
- **CI/CD**: GitHub Actions run link checks, linting, then deploy `main` branch via mike to GitHub Pages.

##### Main components
a. **Developer Workstation**
- Python virtualenv (mkdocs + plugins)
- Node/npm (for SASS compilation)
- Git CLI
b. **Version Control & CI/CD**
- GitHub (repo) → pushes trigger GitHub Actions:
- link checker
- lint (pre‑commit + eslint)
- build & deploy (mike + mkdocs build)
c. **Build Pipeline**
- mkdocs build step reading:
- `mkdocs.yml` (site config)
- `docs/` (Markdown + images)
- `overrides/` (theme customizations)
- `extra_sass/style.css.scss` → CSS via sass
- `docs/img/*.dot` → PNG via Graphviz
- `mkdocs-ciso-controls` plugin
d. **Hosting & Delivery**
- GitHub Pages (static site)
- CDN (GitHub’s pages CDN for CSS, JS, images)
- End‑users (browsers) fetch HTML/CSS/JS
- Node.js demo: `user-demo/`
- .NET demo: `user-demo-dotnet/`
- Both build Docker images, deploy via Helm to a Kubernetes cluster (Welkin)

##### Relationships & Interactions
- Developer → GitHub (push)
- GitHub → GitHub Actions → Build Server
- Build Server → mkdocs pipeline (inc. SASS, Graphviz, plugin)
- mkdocs pipeline → Generated site artifacts
- Mike → GitHub Pages
- End‑user → GitHub Pages (HTTP)
- (Optionally) Demo apps → Docker Registry → Kubernetes cluster

##### Architectural patterns & principles
- **Static‑site generator pattern**: Clear separation between source (Markdown, theme overrides) and output (static HTML).
- **Plugin extension**: mkdocs plugin for CISO controls shows extensibility.
- **CI/CD as code**: workflows under `.github/workflows`.
- **Infrastructure as code**: Helm charts and Kubernetes manifests in `user-demo/*/deploy/`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workstation
    subgraph "Developer Workstation"
        Python["Python venv\n(mkdocs + plugins)"]:::dev
        NodeNPM["Node/NPM\n(SASS compilation)"]:::dev
        Graphviz["Graphviz & Make\n(diagram generation)"]:::dev
        GitCLI["Git CLI"]:::dev
    end

    %% Version Control & CI/CD
    subgraph "Version Control & CI/CD"
        GitHub["GitHub Repo"]:::ci
        Actions["GitHub Actions"]:::ci
        CheckLinks["Link Checker"]:::ci
        Lint["Lint (pre-commit + eslint)"]:::ci
        DeployFlow["Deploy (mike + mkdocs build)"]:::ci
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        MkConfig["MkDocs Config\n(mkdocs.yml)"]:::build
        DocsSrc["Documentation Sources\ndocs/"]:::build
        Overrides["Theme Overrides\noverrides/"]:::build
        Sass["SASS → CSS\n(extra_sass/style.css.scss)"]:::build
        DotInput["Graphviz Inputs & Makefile\ndocs/img/*.dot\nMakefile"]:::build
        Plugin["Custom MkDocs Plugin\n(mkdocs-ciso-controls/)"]:::build
        Scripts["Helper Scripts\n(scripts/)"]:::build
        Mkdocs["MkDocs Build Engine"]:::build
    end

    %% Hosting & Delivery
    subgraph "Hosting & Delivery"
        Pages["GitHub Pages"]:::host
        CDN["CDN"]:::host
        Browser["End-user Browser"]:::host
    end

    %% User Demo Apps
    subgraph "User Demo Apps"
        NodeDemo["Node.js Demo\n(user-demo/)"]:::demo
        DotnetDemo[".NET Demo\n(user-demo-dotnet/)"]:::demo
    end

    %% Arrows - Developer to VCS
    GitCLI -->|"git push"| GitHub
    %% Local workflow to Build Pipeline
    Python -->|"mkdocs serve"| Mkdocs
    NodeNPM -->|"sass build"| Sass
    Graphviz -->|"make diagrams"| DotInput
    Scripts -->|"run scripts"| Scripts
    %% CI/CD triggers
    GitHub --> Actions
    Actions --> CheckLinks
    Actions --> Lint
    Actions --> DeployFlow
    DeployFlow --> Mkdocs
    %% Build pipeline inputs
    MkConfig --> Mkdocs
    DocsSrc --> Mkdocs
    Overrides --> Mkdocs
    Sass --> Mkdocs
    DotInput --> Mkdocs
    Plugin --> Mkdocs
    Scripts --> Mkdocs
    %% Hosting flow
    Mkdocs -->|"site artifacts"| Pages
    Pages --> CDN
    Browser -->|"HTTP GET"| CDN
    %% Demo apps pipeline
    NodeDemo -->|"build Docker"| NodeDemo
    NodeDemo -->|"helm deploy"| NodeDemo
    DotnetDemo -->|"build Docker"| DotnetDemo
    DotnetDemo -->|"helm deploy"| DotnetDemo

    %% Click Events
    click MkConfig "https://github.com/elastisys/welkin/blob/main/mkdocs.yml"
    click DocsSrc "https://github.com/elastisys/welkin/tree/main/docs/"
    click DotInput "https://github.com/elastisys/welkin/tree/main/docs/img/Makefile"
    click Overrides "https://github.com/elastisys/welkin/tree/main/overrides/"
    click Sass "https://github.com/elastisys/welkin/blob/main/extra_sass/style.css.scss"
    click Plugin "https://github.com/elastisys/welkin/tree/main/mkdocs-ciso-controls/"
    click Scripts "https://github.com/elastisys/welkin/tree/main/scripts/"
    click GitCLI "https://github.com/elastisys/welkin/blob/main/package.json"
    click CheckLinks "https://github.com/elastisys/welkin/blob/main/.github/workflows/checklinks.yml"
    click Lint "https://github.com/elastisys/welkin/blob/main/.github/workflows/lint.yml"
    click DeployFlow "https://github.com/elastisys/welkin/blob/main/.github/workflows/deploy.yml"
    click NodeDemo "https://github.com/elastisys/welkin/tree/main/user-demo/"
    click DotnetDemo "https://github.com/elastisys/welkin/tree/main/user-demo-dotnet/"

    %% Styles
    classDef dev fill:#cce5ff,stroke:#004085,color:#004085;
    classDef ci fill:#ffe5b4,stroke:#985f0d,color:#985f0d;
    classDef build fill:#d4edda,stroke:#155724,color:#155724;
    classDef host fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef demo fill:#f0f0f0,stroke:#999999,color:#333333;
```
