How dotnetcore/bootstrapblazor works
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