# ionic-team/docs-demo architecture

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

- Interactive diagram: https://gitdiagram.com/ionic-team/docs-demo
- Repository: https://github.com/ionic-team/docs-demo

## Overview

##### Project Type and Purpose
- This is a front-end “kitchen sink” demo application built with Stencil (used by Ionic) showcasing a library of Web Components.
- There is no backend or database—everything is compiled to static assets and served as a static site.

##### Key Architectural Components
a. Developer Environment
- Source code in GitHub repo (includes package.json, stencil.config.ts, CI workflow).
- Local dev server (`npm start`) powered by Stencil’s watcher and build pipeline.
b. Continuous Integration & Build
- GitHub Actions (/.github/workflows/CI.yml) runs lint, tests, and `npm run build`.
- Build artifacts produced by Stencil (configured in stencil.config.ts).
c. Deployment
- Static host (e.g., Netlify, Surge, Firebase; static.json hints at hosting config).
- Deployed bundle includes index.html, compiled JS/CSS assets, manifest.json, service worker if any.
d. Runtime (Browser)
- index.html bootstraps the Stencil loader script.
- Components registry initializes—each UI component (in src/components/*) loads on demand.
- Demo pages (app-root, app-home) mount and render various component examples.

##### Relationships & Data Flow
- Developer pushes code → CI builds & tests → Artifacts deployed to Static Host → Browser fetches index.html & assets → Stencil loader registers Web Components → User interacts with components → events and property bindings drive UI demos.
- Within the browser:
→ index.html
→ Stencil runtime
→ component registry
→ individual components (each with .tsx and .css)
→ global utils (src/utils/component-utils.ts) support shared logic.
→ assets served from /src/assets.

##### Architectural Patterns & Principles
- Component-based architecture: encapsulated UI elements (`accordion`, `button`, `modal`, etc.).
- Build-time code generation and lazy loading via Stencil compiler.
- Separation of concerns:
- src/components for UI
- src/global for common styles and bootstrap code (app.ts)
- src/utils for shared helper functions
- scripts/mkcomponent.sh to scaffold new components.

a. Nodes into layers:
1. Source & CI layer (GitHub repo, CI workflow)
2. Build layer (Node.js/NPM → Stencil compiler → bundle artifacts)
3. Deployment layer (Static hosting service with static.json config)
4. Runtime layer (Browser with Stencil loader and Web Components)
- Code push → CI trigger
- CI → build artifacts
- Artifacts → deployment
- Browser requests → host → serves assets
- Loader → component registry → individual components
c. Technologies:
- GitHub Actions, Node.js, npm, Stencil.js, Hosting service (e.g., Netlify/Firebase), Web Components API
d. Patterns:
- Lazy loading of components
- Component encapsulation (shadow DOM)
- Build-time optimizations (tree shaking)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    subgraph "Developer Environment"
        Repo["GitHub Repo"]:::dev
        Package["package.json"]:::dev
        StencilCFG["stencil.config.ts"]:::dev
        CIConfig[".github/workflows/CI.yml"]:::dev
        Scaffold["scripts/mkcomponent.sh"]:::dev
    end

    %% CI & Build Layer
    subgraph "CI & Build"
        GHActions["GitHub Actions CI"]:::build
        NodeNpm["Node.js & npm"]:::build
        Compiler["Stencil Compiler"]:::build
        Artifacts["Build Artifacts"]:::build
    end

    %% Deployment Layer
    subgraph "Deployment"
        Host["Static Host"]:::deploy
        StaticJSON["static.json"]:::deploy
        IndexHTML["src/index.html"]:::deploy
        Manifest["src/manifest.json"]:::deploy
    end

    %% Runtime (Browser)
    subgraph "Runtime (Browser)"
        Loader["Stencil Loader"]:::runtime
        Registry["Web Component Registry"]:::runtime
        Styles["Global Styles (app.css)"]:::runtime
        Bootstrap["Global Bootstrap (app.ts)"]:::runtime
        Utils["Shared Utilities"]:::runtime
        subgraph "Components"
            RootComp["app-root Component"]:::runtime
            HomeComp["app-home Component"]:::runtime
        end
    end

    %% Flow Connections
    Repo -->|pushes code| CIConfig
    CIConfig -->|triggers| GHActions
    GHActions -->|runs lint/tests/build| NodeNpm
    NodeNpm -->|invokes| Compiler
    Compiler -->|generates bundle| Artifacts
    Artifacts -->|deploys artifacts| Host
    StaticJSON -->|configures| Host
    Host -->|serves assets| IndexHTML
    Host -->|serves manifest| Manifest
    IndexHTML -->|bootstraps| Loader
    Loader -->|registers| Registry
    Registry -->|lazy loads| RootComp
    Registry -->|lazy loads| HomeComp
    Registry -->|uses| Styles
    Registry -->|uses| Bootstrap
    Registry -->|uses| Utils

    %% Click Events
    click Package "https://github.com/ionic-team/docs-demo/blob/main/package.json"
    click StencilCFG "https://github.com/ionic-team/docs-demo/blob/main/stencil.config.ts"
    click CIConfig "https://github.com/ionic-team/docs-demo/blob/main/.github/workflows/CI.yml"
    click Scaffold "https://github.com/ionic-team/docs-demo/blob/main/scripts/mkcomponent.sh"
    click GHActions "https://github.com/ionic-team/docs-demo/blob/main/.github/workflows/CI.yml"
    click Compiler "https://github.com/ionic-team/docs-demo/blob/main/stencil.config.ts"
    click StaticJSON "https://github.com/ionic-team/docs-demo/blob/main/static.json"
    click IndexHTML "https://github.com/ionic-team/docs-demo/blob/main/src/index.html"
    click Manifest "https://github.com/ionic-team/docs-demo/blob/main/src/manifest.json"
    click Styles "https://github.com/ionic-team/docs-demo/blob/main/src/global/app.css"
    click Bootstrap "https://github.com/ionic-team/docs-demo/blob/main/src/global/app.ts"
    click Registry "https://github.com/ionic-team/docs-demo/tree/main/src/components/"
    click Utils "https://github.com/ionic-team/docs-demo/blob/main/src/utils/component-utils.ts"
    click HomeComp "https://github.com/ionic-team/docs-demo/blob/main/src/components/app-home/app-home.tsx"
    click RootComp "https://github.com/ionic-team/docs-demo/blob/main/src/components/app-root/app-root.tsx"

    %% Styles
    classDef dev fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef build fill:#D5F5E3,stroke:#186A3B,color:#145A32
    classDef deploy fill:#FAD7A0,stroke:#B9770E,color:#7E5109
    classDef runtime fill:#E8DAEF,stroke:#6C3483,color:#4A235A
```
