# dotnetcore/bootstrapblazor architecture

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

## Overview

##### Project type and purpose
- This is an enterprise‑grade UI component library for Blazor based on Bootstrap (“BootstrapBlazor”).
- It consists of two main deliverables:
a. The **core component library** (`src/BootstrapBlazor`), packaged as a NuGet and static assets (CSS/JS).
b. A **demo site / server app** (`src/BootstrapBlazor.Server`) that hosts live examples, serves static files, and exposes APIs for demos.

##### File structure
- Top‑level:
- `src/BootstrapBlazor` – Razor components, C# classes, JS interop modules, SCSS, localization, options, services, testing assets.
- `src/BootstrapBlazor.Server` – A Blazor Server application with `Program.cs`, controllers (API), services, data models, `wwwroot` (static assets), Dockerfile.
- `test` – Extensive unit tests organized by area (Components, Services, Extensions, etc.).
- `scripts` and `.github/workflows` – Build, test, Docker‐deploy, and publish CI/CD.
- `docs` – Repro steps, localization dictionaries.

##### README for additional insights
- Describes installation, main layouts, CSS/JS bundles, adding services in `Program.cs`.
- Points to the online example site, `.NET Foundation` affiliation, and contribution workflow.

a. **Main components**
- **Client Browser**: Runs Blazor WebAssembly or Blazor Server UI, loads CSS & JS bundles.
- **Demo Server App** (`BootstrapBlazor.Server`):
- **Controllers**: REST endpoints for code snippets, Gitee integration, dispatch, login, waterfall chart.
- **Services**: Business/data logic for weather, menu, code snippets, mock data, localization.
- **Static File Host**: Serves `wwwroot` (CSS, JS modules, models, samples).
- **Core Library Package** (`BootstrapBlazor`):
- **Components**: `.razor` + `.cs` code-behind, SCSS, JS interop modules.
- **Services & Utilities**: DI registrations, converters, dynamic, extensions, options, validators.
- **Localization**: JSON and resx-based.
- **CI/CD & Packaging**:
- **GitHub Actions**: Build, test, pack, publish to NuGet.
- **Scripts**: Docker build & deploy, Linux service unit files, Nginx config.
- **Unit Tests** (`test/*`): Validate components, services, converters, extensions, performance.

b. **Relationships and interactions**
- **Browser → Demo Server App**:
- On first load, server generates and streams the Blazor host page.
- Static assets (CSS/JS) loaded from `_content/BootstrapBlazor`.
- API requests routed to controllers → services → data models.
- **Demo Server App → Core Library**:
- The server app references the core library NuGet or project directly.
- Components used in Razor pages under `Components/Pages` and `Components/Samples`.
- **CI/CD → Packaging**:
- On push, workflows build solution, run tests, generate NuGet packages (`BootstrapBlazor.dll` + static assets).
- Publish to NuGet.org and optionally deploy Docker container.

c. **Architectural patterns & design principles**
- **Component-Based**: Reusable UI building blocks with code‐behind + SCSS + JS interop.
- **Dependency Injection**: All services registered via `builder.Services.AddBootstrapBlazor()`.
- **MVC‑style Controllers**: For RESTful demo APIs.
- **Modular Packaging**: Static assets under `_content` folder for library consumption.
- **Separation of Concerns**:
– `BootstrapBlazor` (UI library) vs. `BootstrapBlazor.Server` (demo host & API).
– Tests separate from production code.

d. **Key technologies**
- .NET 6+ / ASP.NET Core Blazor Server & WebAssembly
- Bootstrap CSS, SCSS
- Razor Components
- JavaScript Interop modules
- GitHub Actions, Docker, Nginx
- NuGet packaging

##### Elements
- **Labels**:
- “Browser”
- “BootstrapBlazor.Component Library”
- “Demo Server App”
- “Controllers”, “Services”, “Static Host”
- “CI/CD / GitHub Actions” → “NuGet / Docker”
- “Unit Tests”
- Browser → Static Host (load CSS/JS)
- Browser → Demo App (HTTP, SignalR)
- Demo App → Core Library (project dependency)
- CI/CD → Build/Test → NuGet + Docker
- Orange for static assets & JS modules
- Purple for CI/CD & packaging

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::browser

    subgraph "Core Component Library"
        CoreComponents["Razor Components"]:::runtime
        JSModules["JS Interop Modules"]:::static
        StaticAssets["Static Assets (CSS/JS)"]:::static
        subgraph "Localization"
            LocalJSON["Locales (JSON)"]:::ext
            LocalResx["Localization (resx)"]:::ext
        end
        subgraph "Services & Utilities"
            ServicesCore["Services & Utilities"]:::service
            Converters["Converters & Validators"]:::service
        end
    end

    subgraph "Demo Server App"
        DApp["BootstrapBlazor.Server"]:::runtime
        Program["Program.cs"]:::service
        subgraph "Controllers"
            Controllers["Controllers"]:::service
            APIControllers["API Controllers"]:::service
        end
        subgraph "Services"
            DServices["Services"]:::service
        end
        subgraph "Data Models"
            Models["Data Models"]:::service
        end
        subgraph "Razor UI"
            Pages["Razor Pages"]:::runtime
            Layout["Layouts"]:::runtime
            Samples["Sample Components"]:::runtime
        end
        StaticHost["Static File Host"]:::static
    end

    CI["CI/CD GitHub Actions"]:::ci
    Scripts["Packaging & Deploy Scripts"]:::ci
    BuildTest["Build & Test"]:::ci
    Pack["NuGet Package"]:::ci
    DockerNode["Docker Container"]:::ci

    Tests["Unit Tests"]:::test

    %% Relationships
    Browser -->|HTTP/SignalR| DApp
    Browser -->|Load CSS/JS| StaticHost
    DApp -->|serves assets| StaticHost
    DApp -->|references| CoreComponents
    DApp -->|references| StaticAssets
    DApp -->|uses| ServicesCore
    DApp -->|uses| JSModules

    CI --> BuildTest
    BuildTest --> Tests
    BuildTest --> Pack
    BuildTest --> DockerNode
    Pack -->|publishes| NuGet[NuGet.org]:::ci
    DockerNode -->|deploys| ContainerRegistry[Container Registry]:::ci

    %% Click Events
    click CoreComponents "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Components"
    click JSModules "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/wwwroot/modules"
    click StaticAssets "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/wwwroot"
    click LocalJSON "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Locales"
    click LocalResx "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Localization"
    click ServicesCore "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Services"
    click ServicesCore "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Utils"
    click Converters "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Converter"
    click Converters "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor/Validators"
    click DApp "https://github.com/dotnetcore/bootstrapblazor/blob/main/src/BootstrapBlazor.Server"
    click Program "https://github.com/dotnetcore/bootstrapblazor/blob/main/src/BootstrapBlazor.Server/Program.cs"
    click Controllers "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Controllers"
    click APIControllers "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Controllers/Api"
    click DServices "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Services"
    click Models "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Data"
    click Pages "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Components/Pages"
    click Layout "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Components/Layout"
    click Samples "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/Components/Samples"
    click StaticHost "https://github.com/dotnetcore/bootstrapblazor/tree/main/src/BootstrapBlazor.Server/wwwroot"
    click CI "https://github.com/dotnetcore/bootstrapblazor/tree/main/.github/workflows"
    click Scripts "https://github.com/dotnetcore/bootstrapblazor/tree/main/scripts"
    click Tests "https://github.com/dotnetcore/bootstrapblazor/tree/main/test/UnitTest"
    click Tests "https://github.com/dotnetcore/bootstrapblazor/blob/main/test/UnitTest.Localization"

    %% Styles
    classDef runtime fill:#E3F2FD,stroke:#2196F3,stroke-width:1.5px
    classDef service fill:#E8F5E9,stroke:#4CAF50,stroke-width:1.5px
    classDef static fill:#FFF3E0,stroke:#FB8C00,stroke-width:1.5px
    classDef ext fill:#F3E5F5,stroke:#9C27B0,stroke-width:1.5px
    classDef ci fill:#EDE7F6,stroke:#673AB7,stroke-width:1.5px
    classDef test fill:#FCE4EC,stroke:#E91E63,stroke-width:1.5px
    class browser fill:#BBDEFB,stroke:#1976D2,stroke-width:1.5px
```
