Skip to content

Architecture

A .NET 10 Blazor Server application with one database per organisation, split into a small set of hosts that share one Clean Architecture core.

The Hosts

Host Project Role
Web Web/BlazorBlueprint.Web Blazor Server UI, Identity, tenant resolution, webhooks, the host’s own controllers
Application Service Services/BlazorBlueprint.InternalApi JWT-authenticated REST API on the internal network — see API Reference
Background worker Services/BlazorBlueprint.BackgroundWorker Consumes the job streams and runs the recurring sweeps
DbMigrator Services/BlazorBlueprint.DbMigrator One-shot deploy-time job: applies EF migrations to the platform database and every tenant, and reconciles MongoDB indexes. Schema only, no data
AppHost Dev/BlazorBlueprint.AppHost .NET Aspire orchestration for local development only

These run in one of two topologies. Full runs every host plus Redis. Lite is the Web host and a database: jobs and sweeps run inside the web process, with no Redis, Application Service or worker. The same build serves both; see Deployment.

Solution Structure

  • 📁 Core/
    • 📁 BlazorBlueprint.Domain/ — entities, enums, constants, attributes, and the IRepository<T> / IPlatformRepository<T> interfaces
    • 📁 BlazorBlueprint.Application/ — services, interfaces, business logic, background sweeps
    • 📁 BlazorBlueprint.ServiceDefaults/ — shared host setup: health checks, telemetry, Data Protection
    • 📁 BlazorBlueprint.Rendering.Abstractions/ — rendering contracts (IPdfRenderer) shared by the hosts and plugins
  • 📁 Infrastructure/
    • 📁 BlazorBlueprint.Infrastructure.Persistence/ — backend-neutral persistence (Identity stores, database options)
    • 📁 BlazorBlueprint.Infrastructure.Persistence.MongoDB/ — the MongoDB implementation (default)
    • 📁 BlazorBlueprint.Infrastructure.Persistence.EntityFrameworkCore/ — the shared EF Core implementation for both relational backends
    • 📁 BlazorBlueprint.Infrastructure.Persistence.Postgres/ — PostgreSQL provider
    • 📁 BlazorBlueprint.Infrastructure.Persistence.Sqlserver/ — SQL Server provider
    • 📁 BlazorBlueprint.Infrastructure.Integrations/ — email, SMS, payments, push, PDF, DNS, caching, Redis, messaging, scheduling and webhooks
    • 📁 BlazorBlueprint.Infrastructure.Extensions/ — service registration and health checks
  • 📁 Web/
    • 📁 BlazorBlueprint.Web/ — the Blazor Server app
    • 📁 BlazorBlueprint.Web.Shared/ — Razor components and web types plugins can use too
  • 📁 Services/
    • 📁 BlazorBlueprint.Api.Shared/ — the API contract: scoped base controllers, scope attributes, the JWT client and handler
    • 📁 BlazorBlueprint.InternalApi/ — the Application Service
    • 📁 BlazorBlueprint.BackgroundWorker/ — the worker
    • 📁 BlazorBlueprint.DbMigrator/ — the deploy-time schema runner
  • 📁 Plugins/ — plugin projects, referenced by every host through Plugins/Plugins.props. (Not the runtime drop-in Plugins/ folder beside each host’s assembly, which takes built DLLs.)
    • 📁 ExamplePlugin/ — the one bundled plugin, with its own tests. An example, not a feature: one small working use of each host extension point, plus a diagnostics page and a contract smoke test that catch host changes that would break plugins (see “Removing the example plugin” on the Plugins page)
  • 📁 Tests/ — run the solution, not a single project
    • 📁 BlazorBlueprint.Tests/ — the main suite
    • 📁 BlazorBlueprint.Tests.Integration/ — real database containers, plus boot-path and convention guards. Container tests skip themselves without Docker, so check the skip count before trusting a green local run
    • 📁 BlazorBlueprint.Tests.Shared/ — shared fakes and fixtures
    • 📁 BlazorBlueprint.Tests.FixturePlugin/ — a test-only plugin; never shipped
  • 📁 Dev/ — the Aspire AppHost
  • 📁 .github/workflows/ and .azure/devops/ — CI/CD pipelines and compose files

Layer rules

  • Domain has no infrastructure dependencies. Entities are plain property bags mapped by both the MongoDB driver and EF Core, so an invariant spanning several fields is enforced in the Application service that owns the write.
  • Application depends on abstractions — never a database driver, never ASP.NET Core host types such as WebApplication (those live in Web.Shared).
  • Infrastructure implements the Application interfaces; each host wires it up at startup.

Tenancy Model

Platform database and tenant databases

  • The platform database holds routing and identity: organisations, users, roles, memberships, customer hostnames (SiteDomain) and preview links, the shared AI integrations, subscription billing, and the deployment settings. Code reaches it through IPlatformRepository<T>.
  • One tenant database per organisation (bb-org-{name} by default) holds everything that organisation owns: site settings, navigation, installed plugins, plugin data and audit logs. Code reaches it through IRepository<T>, which writes to whichever tenant ITenantContext names. The platform organisation has one like any other.

Application code depends only on those two interfaces, so call sites are identical on every backend.

Database backends

Database:DatabaseType selects one backend per deployment:

  • MongoDB (default) — the native driver.
  • PostgreSQL — EF Core; each tenant is a schema in one database.
  • SQL Server — EF Core; each tenant is a database.

The relational backends share one EF Core implementation, with the few real differences (JSON column type, identifier quoting, array indexes) behind a per-provider adapter. Schemas are created from the model in Development; outside Development a relational host refuses to start without Database:UseMigrations, because the model-driven path cannot evolve a live schema. See Configuration → Database and Relational Migrations.

[Encrypted] fields and uploaded files are encrypted at rest on every backend (unless a file is served directly from storage, or encryption is switched off) — see Security.

Conflict-safe saves

Two people editing the same record, or a person and a background job, never silently overwrite each other. IRepository<T> offers two writes that behave the same on all three backends:

  • A save writes only what you changed. Each record remembers how it was read, and UpdateAsync writes only the fields that differ. Someone else’s concurrent changes are merged; if you both changed the same field, the save throws ConcurrencyException and the user is asked to reload. A save that depends on a field it does not write can ask to be refused on any change (UpdateConflictMode.Strict).
  • A patch changes fields without reading first. PatchAsync sets fields or increments a counter in one atomic write guarded by a condition (only if this order is still Pending). Background work uses it to claim work and record outcomes, so two workers never both act on one item.

Rows a worker holds for a while (an outgoing email, say) carry a time-limited claim (IClaimable), so a crashed worker holds them only until it lapses. Rules for your own entities: Plugins → Entities and repositories.

Tenant resolution

Two kinds of host, and they never overlap.

  • Application hosts — the platform host (the platform address, set at Platform → Platform Settings) and each organisation’s subdomain beneath it. Sign-in, administration, /apps and every plugin’s application pages live here only. They are members-only: an anonymous visitor reaches the account pages, the legal pages and routes a plugin has declared public, and is sent to sign-in for everything else, the home page included.
  • Customer hostnames — a domain an organisation owns (www.acme.com) connected to one of its sites, a target a plugin publishes public pages for. It serves that site to anonymous visitors and nothing else; nobody signs in there, and application paths are sent to the platform. See Custom domains and sites.

WebTenantResolutionMiddleware decides which organisation a browser request belongs to and adopts it through ITenantContextSetter (which IRepository<T> reads). Each later step acts only when earlier ones left the request on the platform organisation or unresolved, so nothing a client sends can move a request off an organisation’s subdomain or a customer hostname.

The host is normalised first: lower-cased, port and trailing dot removed. A leading www. is kept (www.acme.com and acme.com may be different customer hostnames), but ignored when comparing against the platform host.

Step 1 — the hostname. First match wins:

  1. Customer hostname — only with CustomDomains on, for a host that is not the platform host, beneath it, or loopback. A verified SiteDomain row names the organisation and site; the request adopts the organisation and carries a SiteRoute in HttpContext.Items. Only pending claims → pages go to /domain-not-verified. A demoted hostname is restored only when its TXT record re-verifies (checked at most every 10 minutes), never on the Host header. An inactive organisation’s hostname serves /site-not-found.
  2. The platform host resolves to the platform organisation.
  3. An organisation subdomain — {label}.{platform address}, one label deep — resolves to the active organisation of that Name; an unknown label to nothing. This runs whatever SubdomainOrganisations says; that switch controls where selection sends people.
  4. Localhost (localhost, 127.0.0.1, [::1]) over a loopback connection resolves to the platform organisation (or the only organisation). From any other connection — a browser reaching a container through a published port is not loopback — it resolves to the platform organisation once a platform address is set, and to nothing before. So the operator can still sign in at http://localhost:8080 on the server when the platform address stops resolving (DNS down, domain lapsed). This grants nothing the platform address does not: anyone who can reach the port can send that address as the Host instead. Passkeys and Google, Microsoft or Facebook sign-in are tied to the platform address and will not work there; a password, with its authenticator code, does.
  5. Anything else resolves to nothing — never to the platform organisation. With no platform address, every non-local request lands here and the host logs a warning (at most every five minutes) pointing at /Platform/Settings.

Step 1b — a preview share link. On an application host, /preview/{token}/… is a share link: a live token adopts the organisation and site, the prefix becomes the site’s PathBase, and the response carries X-Robots-Tag: noindex, nofollow and Cache-Control: no-store. A dead token, or a preview path to /_blazor or a hub, is a bare 404. A subdomain serves only its own organisation’s links. Failed lookups are limited to 300 a minute per client address.

Step 2 — the /org/{name} prefix, only on the platform host (or localhost where step 1 resolved it); an unknown host never adopts one. On the platform host an organisation’s public links carry it in the path (/org/acme/portal/abc); the middleware adopts the organisation and strips the prefix before routing (the original is in HttpContext.Items["OrgPrefixedPath"]). In front of /_blazor or a hub it is a bare 404; on a subdomain it is ignored. Build these links with IOrganisationPublicUrlResolver. OrganisationNameRules reserves select, requestaccess and around two hundred names that would read as the deployment’s own (www, api, admin, platform, legal, billing, wpad, postmaster…); add your own before launch.

/api/files/public/{id} on the platform host can also take its organisation from the Referer — a plugin-declared public /org/{name}/… page, or a live preview link (counted against the same guessing budget) — so logos and icons on those pages load. It serves only public files.

Step 3 — the BB_SelectedOrg cookie, only when MultiOrganisation is on and the request is still on the platform organisation. If it names an active organisation, that is adopted — for pages, /api/*, the circuit and hub handshakes, but not static assets, /robots.txt, /sitemap.xml, /favicon.ico or /manifest.json.

  • With SubdomainOrganisations on, the cookie is ignored and deleted on the platform host itself (it is still honoured on localhost). With no platform address it is ignored everywhere but localhost.
  • The cookie selects; it does not authorise. /api/org/switch checks membership (or platform-admin impersonation) before setting it, and the membership wall checks every request; a refused user has the cookie cleared and is sent to /Org/Select.

Step 4 — nothing resolved. A page request on an unknown host redirects to /site-not-found (an unverified customer hostname to /domain-not-verified). API, hub, circuit, health-probe and asset requests continue with no tenant, so any tenant-scoped read fails. Before initial setup an unknown host is left to SetupRedirectMiddleware.

Caching. Host, customer-hostname and organisation lookups are cached per process (TenantResolutionCache) for five minutes, misses included, at most 10,000 entries each. A change to an organisation or hostname evicts its entries on every instance through ICacheInvalidator (Redis pub/sub under Full). Changing a site’s primary evicts all its hostnames; creating or renaming an organisation clears the whole cache.

What runs around it

The Web host’s middleware order (WebApplicationExtensions.UseCustomMiddleware):

  1. Forwarded headers, security headers, compression, exception handling, HTTPS redirection, CORS.
  2. Tenant resolution for /org/{name}/… paths, so the prefix is stripped before routing.
  3. Tenant resolution plus SiteDomainGateMiddleware for possible customer hostnames and /preview/… paths, also before routing, because the gate may rewrite the path.
  4. UseRouting(), SiteDomainEndpointGateMiddleware, the rate limiter.
  5. Tenant resolution for every other request (under Lite, skipping bearer-token /api/plugin/* calls, which the API resolver handles).
  6. The tenant schema gate (relational only: a tenant whose schema is behind gets 503), the first-run setup redirect, SubdomainAuthRedirectMiddleware.
  7. The platform’s stored external sign-in credentials and the organisation’s OIDC scheme applied, so callbacks have a handler.
  8. Authentication and authorisation.
  9. Under Lite only: ApiTenantResolutionMiddleware for plugin API calls.
  10. The access walls: anonymous → platform-only routes (/platform/* is not-found on any other organisation) → membership → premium-plugin entitlement → consent → two-factor enrolment. A request carrying a SiteRoute passes the anonymous and membership walls; the site gate has already confined it.
  11. Output caching, SignalR hubs, static assets and the Razor components.

SiteDomainGateMiddleware — the website-only rule for a customer hostname or preview:

  • An alias (a verified hostname that is not the site’s primary) redirects 301 (308 for non-GET/HEAD) to the primary, path and query intact.
  • An application path (/Account, /Admin, /Platform, /apps, /plugin/…, /Org, /notifications) redirects to the organisation’s subdomain (or the platform host) with ?bbOrg={organisation id}.
  • /_blazor, /api/files/public/*, static assets, the well-known site files, the status pages and any path in the provider’s SiteRoutePrefixes are served. Any other /api/* or /hubs/* is a bare 404.
  • A path whose first segment is a page route of the host or a plugin (/legal) gets the not-found page with 404. Everything else is a slug of the site, rendered through IPublicUrlRegistry, or 404.

The gate runs before routing, so it judges paths by shape. SiteDomainEndpointGateMiddleware re-decides a verified customer hostname from the endpoint routing chose: only static assets, the circuit, well-known files, the public file route, SiteRoutePrefixes paths and the site’s own Razor pages (catch-all, home, status pages) are served. Every other controller or minimal API, any IWebPluginConfigurator endpoint, /health, /alive and the /signin-* / /signout-* callbacks are 404 there.

A preview is not a customer hostname. Resolution sets WebTenantResolutionMiddleware.CustomerHostnameKey only for a verified SiteDomain. A preview carries a site route but not that flag, so it keeps the application CSP, never renders the site’s pasted head or body code, shows no site cookie banner and cannot change the visitor’s application consent (the page is consent-read-only), and is never output-cached. A signed-in circuit never adopts a preview’s organisation.

SubdomainAuthRedirectMiddleware sends /Account/* on an organisation subdomain to the platform host, where OAuth redirect URIs are registered and the auth cookie is scoped — while SubdomainOrganisations is on and the platform address can carry a shared cookie. It appends ?bbOrg={organisation id} so sign-in returns the user to that organisation through /api/org/switch. /Account/Manage/*, /Account/Logout and /Account/DeletionStatus stay on the subdomain, except linking an external login and managing passkeys.

Blazor circuits. TenantCircuitHandler keeps the tenant (and any site route) resolved for the connecting request; an /org/{name} organisation from the Referer applies only while a plugin-declared public /org/{name}/… page is rendered. A site circuit is public but may instantiate only the site’s own pages; every other circuit is members-only. The checks run on every component a circuit creates, plugin pages also passing the plugin gate (loaded, available, installed, entitled, schema); any refusal ends the circuit. Every circuit is re-checked on Authentication:SecurityStampValidationIntervalMinutes, and ended (the browser reloads) once its organisation is deactivated or deleted.

The Application Service has its own resolver, ApiTenantResolutionMiddleware (Services/BlazorBlueprint.Api.Shared/Middleware/), driven by the controller’s scope attribute. A declared scope requires a valid service token (401 without one), read from the bearer scheme so a cookie never counts:

  • [EndpointScope(EndpointScope.Organisation)]: requires an X-Organisation-Id header (400 without one) equal to the token’s org_id claim (403 if not), naming an active organisation (400).
  • [EndpointScope(EndpointScope.Platform)]: runs with no tenant and refuses an organisation-bound token (403). Only here does [AllowAnonymous] waive the token, which is how the token endpoint is reached.
  • An [Authorize] endpoint declaring neither is refused with 500, so a missing attribute fails closed.

Under Full it runs in the Application Service; under Lite the Web host runs it for plugin API calls. On either topology the Web host also runs it for any endpoint declaring a scope, so a scoped controller there cannot be reached without a token. See API Reference.

Routing modes

Choosing an organisation goes through /api/org/switch?orgId=…, which checks membership and then:

  • Single-org (MultiOrganisation off): returns to the page; the cookie is never read. The membership wall still applies; a signed-in non-member is sent to /Account/AccessDenied.
  • Subdomain (SubdomainOrganisations on): redirects to {organisationName}.{platform address}. Needs wildcard DNS and a wildcard certificate; the sign-in cookie is then scoped to .{platform address}. Outside Development it cannot be turned on — and is treated as off — unless the platform address is a domain (not localhost, an IP address or a single-label name).
  • Cookie-based (otherwise): sets BB_SelectedOrg and stays on the current host.

Selecting an organisation never sends anyone to a customer hostname.

The platform address is entered at initial setup and edited at Platform → Platform Settings (/Platform/Settings); it is not configuration. It is a bare hostname (app.example.com), or for a run on your own machine the local address with its port (http://localhost:5034). It is stored in the platform database, validated as a DNS hostname and canonicalised (lower-case, no scheme, port, path or leading www., except a localhost address, which keeps scheme and port).

  • Every link is built on it, never on the request — https://{address} or https://{organisation}.{address}, or the saved local address — so a page and a background job produce the same link.
  • Each host holds it in memory: loaded before serving, re-read every Caching:Policies:PlatformSettingsRefreshSeconds (120), replaced at once on the saving replica. A change drops every cached tenant route on every replica.
  • Changing it is guarded against typos: the new address must be the one you are browsing at or a parent of it (loopback exempt), must not overlap a verified customer hostname, and moving a saved address needs confirmation. Initial setup skips the browsing check, so the address can precede its DNS.
  • There is no fallback: before setup it is unset and only loopback requests are served. With SubdomainOrganisations or CustomDomains on and no address, /health reports Degraded (still 200), as it does when subdomains are on but the address cannot carry a shared cookie.

Organisations have no domain of their own.

CustomDomains controls routing, not just the Domains page. Turning it off takes every customer hostname offline at once while the application hosts keep working, so you won’t notice from your own site. Nothing is lost — rows and verification state are kept, and turning it back on restores every route without re-verification. To retire one hostname, remove it at /Admin/Domains or /Platform/CustomerDomains.

Custom domains and sites

A site is anything a plugin publishes public pages for, identified by the plugin’s provider key and a target key. The host asks the plugin’s IPublicPageProvider (see Plugins → Public pages on customer hostnames). An organisation may own many sites, each with many hostnames.

Connecting a domain — at Admin → Domains (/Admin/Domains) or inside the owning plugin, through the shared DomainConnectPanel:

  1. An organisation admin enters a hostname and picks a site published by the organisation’s installed (and entitled) plugins; any other target is refused. The claim starts pending and routes nothing.
  2. The page shows the DNS records to publish: the ownership TXT record ({DomainVerification:TxtRecordPrefix}{token}) at _bb-verify.{hostname} (its own name, since a CNAME cannot share one), the traffic CNAME at the hostname, and any Cloudflare for SaaS certificate-validation records — as last stored; Refresh status asks Cloudflare at once. Any registrar works.
  3. When the TXT record appears (on Verify or the next check) the claim becomes verified and starts routing, and only then is it registered with Cloudflare for SaaS (if enabled at /Platform/CustomDomains). A site’s first verified hostname is its primary; later ones are aliases that redirect to it. A site has exactly one primary; if two ever become primary at once, the earliest-verified keeps it.

Ownership is proven, never claimed. Several organisations may hold pending claims on one hostname, each with its own token, so typing a domain blocks nobody; the first to publish its token wins and the others close. An unproven claim is released after 7 days. A verified hostname whose record disappears is demoted after about nine hours of failed checks — it stops routing and hands the primary role on — and is released (and deregistered from Cloudflare) if the record has not returned within 30 days. Both periods are fixed. Cloudflare registration waits for proof because a custom hostname is unique per Cloudflare zone.

Limits. The platform host and everything beneath it are refused, on adding and again on verifying (a name beneath it would receive the session cookie). A hostname of an inactive or deleted organisation is never verified or restored. A hostname is at most 242 characters (so _bb-verify. fits DNS’s 253); internationalised TLDs are accepted in xn-- form; an organisation may add 20 an hour and hold 100.

Operator controls. At Platform → Customer Domains (/Platform/CustomerDomains), Remove releases a hostname (it can be re-added); Remove and block also blocklists it (BlockedHostname), refusing it and everything beneath it to every organisation until unblocked, and releases any already connected. Every domain change is in the platform audit log, and a member’s also in the organisation’s /Admin/Audit. A plugin deleting a site calls ISiteDomainService.RemoveForTargetAsync and ISitePreviewLinkService.RevokeForTargetAsync. A hostname is released only once its Cloudflare registration is deleted; until then it stays listed, routing nothing, and the background check retries.

Deactivating an organisation. A platform admin deactivates or reactivates one at Platform → Organisations; an organisation also deactivates itself when its last active member leaves or their account is deleted (see Orphan organisations below). While deactivated, its subdomain and hostnames serve nothing, its open circuits end, its jobs and inbound mail are refused, work-generating sweeps (the email outbox included) skip it, and its subscription is not charged — see Subscription Billing. Retention sweeps still run.

Deleting an organisation can be refused. Platform → Organisations first asks every IOrganisationDeletionGuard — a plugin’s way of objecting while the organisation still owns something that cannot be tidied up afterwards, such as a live purchase or an order in flight. A guard that fails counts as an objection. The page lists each reason; a platform admin may override exactly the objections shown (a new one refuses again), and the platform audit log records the override.

What deletion does, in order:

  1. Settles, expires or records any charge in flight on the operator’s account, under the subscription’s change lock — if another subscription change is still running after a short wait, deletion stops having changed nothing, and can be retried.
  2. Runs each installed plugin’s teardown (tenant data still readable), and removes the app-registered Stripe or PayPal webhooks for the organisation’s payment accounts (best effort).
  3. Deactivates the organisation, then archives its database. If the archive fails, deletion stops: the organisation is restored to its previous active state with its row, database and hostnames intact (plugin teardown, webhook removal and charge resolution are not undone — Repair on each payment account restores its webhook), and the stop is audited.
  4. Deletes the organisation row, releases its hostnames (and their Cloudflare registrations) and preview links, removes the host’s platform rows for it (memberships, subscription) and those plugins clean up, and erases its files from Azure Blob Storage or S3 (GridFS and relational blob tables go with the database). Payment records are kept.

Apex domains

Make www.example.com the primary; connect the apex as an alias only where the customer’s DNS supports CNAME flattening or ALIAS records, or simply forward the apex to www at their registrar (Cloudflare for SaaS apex proxying is Enterprise-only). Each hostname is a separate Cloudflare custom hostname, billed beyond the plan’s allowance.

What a customer hostname serves. The site’s pages, to anonymous visitors, with the document head — title, description, icons, language, analytics id, cookie banner, pasted head and body code — from the site (SiteDocumentHead). No PWA (/manifest.json is 404). /robots.txt and /sitemap.xml are the site’s (disallow-all while it is not indexable). It gets the customer-site CSP — see Configuration → Security headers.

Preview links. A site with no domain yet can be shared from Admin → Public Pages (/Admin/Pages) or inside the plugin (SitePreviewLinksPanel): https://{organisation's app host}/preview/{token}/, built from the server’s settings, never the browser’s address. The token is shown once and stored hashed. A link expires after 7 days by default (at most 30), can be revoked, and a site holds at most 20; changes are in the organisation’s audit log, and dead links are deleted after 30 days. A preview is never indexed, sends no analytics, has no canonical, and shows a preview banner with a “Report abuse” link to DefaultOrganisationSettings:SiteEmail (SITE_EMAIL) when set; see also A preview is not a customer hostname above.

Platform vs Organisation Settings

/Platform/* (platform admins) manages the deployment; /Admin/* (organisation admins) manages the current organisation, the platform organisation’s included. The deciding question for a setting: does the answer depend on which organisation you are in? If not, it is a deployment setting.

  • Deployment settings — legal policies, cookie consent, PWA, email sender, external authentication, SMS, inbound email, application analytics and the VAPID push keys. The application runs on hosts you own, so each has one value, the operator’s, in the platform database, edited at /Platform/*, with no per-organisation override. (/Admin/InboundEmail holds only the organisation’s own choices: which app receives its mail, and its sender check.)
  • Organisation settings — site identity (display name, logo, theme, contact details, language, time zone), member landing page and app launcher, in the organisation’s own tenant database, with no fallback.
  • A site’s settings — name, icon, analytics, cookie banner, legal pages, indexing — belong to the plugin serving it.

All mail goes out as the platform. Every email uses the deployment’s sender. Links carrying a token (confirmation, password reset, invitation) are always built on the saved platform address, never on the request — not even a loopback one; other links go to the organisation’s subdomain or the platform host. A plugin needing to send from an organisation’s own mail or SMS account keeps those credentials and its job in its own settings.

Quick reference: behaviour by host

With the default switches (MultiOrganisation, SubdomainOrganisations and CustomDomains on):

Host Serves Legal / cookies / email / PWA / SMS / inbound email / sign-in apps Analytics
app.yourdomain.com
(platform host)
The application, members only — the platform organisation, and any organisation selected by cookie The deployment’s The deployment’s property (/Platform/Settings)
acme.app.yourdomain.com
(organisation subdomain)
The application, members only — one organisation. Sign-in routes through the platform host The deployment’s The deployment’s property
www.acme.com
(customer hostname)
One site’s public pages, anonymous only. Application paths redirect to the subdomain The site’s own banner and legal pages; no PWA; nobody signs in The site’s own property

What lives where

Area /Platform/* /Admin/*
Organisations, users and roles, platform audit log, infrastructure, orphaned organisations, API usage (/Platform/ApiUsage) ✅ —
Push notification (VAPID) keys ✅ —
Legal policies, cookie consent, PWA, email, SMS, inbound email, external authentication ✅ The one value, used by every organisation —
Platform address and application analytics (/Platform/Settings) ✅ —
Cloudflare for SaaS (/Platform/CustomDomains) and every organisation’s hostnames (/Platform/CustomerDomains) ✅ —
Display name, web address, logo, theme, contact details (/Admin/OrganisationSettings) Via the organisations list ✅ Own organisation. Seeded once at creation from /Platform/OrganisationDefaults
Hostnames (/Admin/Domains) and public pages, preview links and member landing (/Admin/Pages) — ✅
Per-organisation SSO (OIDC), navigation, plugin install, roles, organisation audit log — ✅

Pages the table only names:

  • Orphan organisations (/Platform/OrphanOrganisations) — organisations left with no Owner (Ownerless, left running) or no active member (Abandoned, deactivated). Promote a remaining member to Owner, claim it as its Owner yourself (either reactivates an organisation that deactivated itself, never one a platform admin deactivated — reactivate that at Platform → Organisations), or dismiss the flag; each is in the platform audit log.
  • Retry setup (🔄 on Platform → Organisations) — re-runs an organisation’s default setup (site settings, navigation, auto-installed apps). Safe to repeat; use it when creating an organisation reported unfinished steps.
  • AI models (/Platform/AiModels) — the deployment’s shared catalogue of AI models, each linked to an integration at /Platform/ApiIntegrations.
  • Notifications (/notifications) — a user’s notifications in the current organisation, with mark-all-read and a button to enable browser push. /Account/Manage/NotificationSettings lists the user’s push subscriptions by browser and device, to reactivate, remove or send a test.
  • Navigation (/Admin/Navigation) — the organisation’s own links in the main navigation and profile menu, with order, icon and an optional required role. App links are not edited here.
  • Roles (/Admin/Roles) — custom roles, assigned at Admin → Members. A holder gets the role as a claim in that organisation only, so navigation items and your own checks can require it. System and app roles are read-only and reserved names are refused; changes are in the organisation’s audit log.
  • Members (/Admin/Members) — invite by email, change membership level (only an Owner changes an Owner), assign custom roles, remove. An invitation link expires after 7 days; Resend issues a fresh one, Copy invite link hands it over without email, and an invitation can be cancelled. Invitees accept from the email and can decline at /Org/Select, where members can also leave (the last Owner cannot).
  • Incoming webhooks (/Admin/Webhooks/Incoming, /Platform/Webhooks/Incoming) — read-only: every endpoint that calls the organisation (or the platform) and the page it is set on (see Incoming webhooks under Built-in Host Services).

The web address is the organisation’s Name — its subdomain and /org/{name} prefix. Changing it asks for confirmation, because old links break. The database keeps its original name, so while the renamed organisation exists nobody else can take the old name. The display name is free text.

/Platform/OrganisationDefaults is a template, not an inherited value. It is copied once into each new organisation — theme, language, time zone, currency, landing page, launcher — so later edits affect only organisations created afterwards. It holds no file references, because copying a file id does not copy the file.

Don’t rely on the walls to protect a controller or a hub. The anonymous wall lets every /api/* request through, and the membership wall never sees anonymous callers and, on the platform organisation, gates only /admin, /apps, /plugin and /notifications. Give a controller serving tenant data its own attribute, such as [AuthorizeOrganisationMember] (an active member of the resolved organisation, or a platform admin). A hub invocation never passes middleware after the handshake, so a plugin hub declares [EndpointScope(EndpointScope.Organisation)] or [EndpointScope(EndpointScope.Platform)], and a plugin API controller declares its scope — see API Reference.

Feature Flags

Feature switches turn whole parts of the product on or off for every organisation. They are not in appsettings.json: they are saved in the platform database, written with the defaults below at initial setup, and changed by a platform admin at Platform → Platform Settings (/Platform/Settings) → Features. Every host reads the same saved value; a change applies without a restart (other servers within Caching:Policies:PlatformSettingsRefreshSeconds, two minutes) and is written to the platform audit log.

A Features:<Name> key in configuration overrides the saved value (environment variable, overlay file or command line), and the settings page shows that switch locked. Use it for tests or emergencies, on every host; no shipped file sets one, so Lite and Full have the same features.

Two switches refuse to turn on without their prerequisite: SubdomainOrganisations needs a platform address that is a domain (outside Development), and RequireEmailConfirmation needs outbound email configured.

Flag Default What it does
MultiOrganisation true Multiple organisations, with switching and membership. Off = single-organisation mode: no organisation picker or request-access page, but a subdomain or /org/{name} still decides the organisation and the membership wall still applies (a non-member is sent to /Account/AccessDenied). Registration and external sign-up add each new account to the site’s organisation as a Member, and are refused once it is at its plan’s member limit.
SubdomainOrganisations true Selecting an organisation redirects to <orgName>.<platform address>, and the sign-in cookie is scoped to .{platform address}. Needs a platform address that is a domain (not localhost, an IP address or a single-label name), wildcard DNS and a wildcard certificate. Saved off at setup unless the address entered is such a domain, and outside Development held off whenever it is not, whatever is saved; setting a domain lifts it.
CustomDomains true Organisations can connect hostnames they own to a site a plugin publishes (see Custom domains and sites). Off: no hostname lookup, the Domains page says the switch is off, the verification sweep pauses — every customer hostname goes offline. With this on and no platform address, /health reports Degraded. Cloudflare for SaaS automation is a separate switch at /Platform/CustomDomains.
RequireEmailConfirmation false New users must confirm their email before signing in. Can only be turned on once outbound email is configured.
RequirePhoneNumber false A required phone-number field on Register, external-login sign-up, initial setup and /Account/Manage, enforced server-side. Off hides the field (existing numbers are kept).
AppLauncher true The /apps tile launcher: members land there after sign-in, org selection and org creation. Off: the user menu lists plugins individually, / shows a welcome page and /apps redirects to /. Each organisation can also turn it off for itself.
OrganisationSso true Per-organisation OIDC single sign-on: the per-organisation schemes, the SSO sign-in endpoint and /Admin/Sso. Off refuses every SSO sign-in (the endpoint answers 404); the page stays in the nav, marked “Off”.
PlatformSubscriptionBilling true Platform subscription billing — you charging organisations. Off hides the plan picker on /Admin/Billing; the Subscriptions tab of /Platform/Billing and Platform → Plans stay, marked Off, showing only an “off” notice. On a live deployment, off also freezes billing: the lifecycle sweep does nothing, premium apps become free and seat limits stop. Nothing is charged until the separate runtime switch is on too — see Subscription Billing.
SiteFooter true The site-wide footer, whose content (copyright line, text, link columns, social profiles, legal links) is edited at /Platform/Footer for every organisation. Off removes it; the cookie banner then shows its own “Cookie settings” control so consent can still be withdrawn.
RequireTwoFactorForPlatformAdmins false A platform admin with neither an authenticator app nor a passkey is sent to set one up on sign-in and can reach nothing but that page, sign-out, the legal pages and their own data until they do — pages redirect, API calls and plugin hub connections are refused. Applies to every sign-in method, organisation SSO included.
RequireTwoFactor false The same for every user. A passkey counts, but then the passkey IS the sign-in: an account covered by either switch whose only second factor is a passkey is refused password and external-provider sign-in. A forgotten-password reset keeps that passkey, so someone who has lost it asks a platform admin to Reset two-factor at Platform → Users.
PromptPasskeySetup true After sign-in or sign-up, a user with no passkey is offered one at /Account/PasskeyPrompt: add it, be asked again in 30 days, or never. Not shown after a passkey sign-in, nor while a two-factor switch covers someone with no authenticator app.

Background Work & Messaging

Two entry points move work off the request thread:

  • IOutboundApiDispatcher.SendAsync(job) submits an outbound provider call (AI, SMS, email, payments, outgoing webhooks, Cloudflare, the settings pages’ Test buttons) and returns its result, wherever it ran.
  • IInboundWebhookDispatcher takes a signature-verified incoming webhook off the request thread, so the provider gets its 2xx quickly.

Messaging:Transport decides where work runs: Redis (Full) publishes to Redis streams consumed by the worker and returns the answer to the waiting web instance; InProcess (Lite) runs the same handlers in the web process. Each job runs in a fresh scope, its tenant resolved from the platform database by organisation id — never from what the message claims — and always produces a final result, including unknown (a timed-out payment call may have succeeded, so never treat it as failed).

  • A job for a deleted or deactivated organisation does not run and is answered as a failure, except provider clean-up that must outlive the organisation (handlers marked ITenantIndependentJobHandler, run with no tenant).
  • A job or incoming webhook for a plugin that is disabled or switched off at Platform → Apps is refused, as is a tenant-scoped webhook for an organisation that has not installed or is not entitled to the plugin.
  • Under Full, a job left unfinished by a stopped worker is reclaimed after Messaging:ClaimIdleMs (five minutes). One already past its maximum age is discarded and reported as unknown, since the first attempt may have reached the provider. A throwing webhook handler is retried the same way and dead-lettered after Messaging:MaxDeliveryAttempts (five). Under Lite it is not retried.

Under Full the Web host makes almost no third-party calls itself: only external sign-in (Google, Facebook, Microsoft, organisation SSO), domain-verification DNS lookups and file storage (Azure Blob / S3 transfers and the Platform → Storage connection test). Everything else runs wherever the transport sends it.

Recurring sweeps — email outbox, data retention, domain verification, appointment reminders, webhook retries, stranded SMS sends, payment reconciliation, subscription lifecycle and plugin sweeps — run in the worker under Full and in the web process under Lite (BackgroundServices:RunInProcess). Every replica runs every sweep, so each must be safe to run twice at once.

Configuration and Redis requirements: Configuration → Background Messaging.

Observability and Audit

Every host logs one console line per event, scoped with the organisation, job, circuit or sweep, and with OTEL_EXPORTER_OTLP_ENDPOINT set sends logs, metrics and traces over OpenTelemetry. A job is one trace from request to worker. The application’s meters use the BlazorBlueprint. prefix; only API usage is tagged by organisation. An optional bundled Grafana (compose profile observability) has dashboards and alerts. See Deployment → Observability.

The three audit trails — each organisation’s, the platform’s, and each user’s security activity — are stored in the database and also copied, ids only, to the BlazorBlueprint.Audit log category and a blazorblueprint.audit.events counter. Each trail’s storage can be switched off in configuration (Security:Audit:*), deliberately not at Platform Settings. Details: Security → Audit trail.

Plugins

Features are added as plugins implementing IPlugin — a manifest plus a service-registration method — and optionally further interfaces for pages, seed data, sweeps and web wiring. A plugin assembly identifies itself with [assembly: PluginAssembly("slug")].

  • Plugins are discovered once, at startup, by the Web host, the Application Service and the worker: add the project to Plugins/Plugins.props, or drop built DLLs into a subfolder of the Plugins/ folder beside each host’s assembly (in Development the Web host also reads Web/BlazorBlueprint.Web/Plugins/).
  • Availability is layered: configuration (Plugins:{id}:Disabled) → platform policy (Platform → Apps) → per-organisation install (Admin → Apps) → premium entitlement.
  • Plugins are fully trusted, in-process code with full DI access; those layers control availability, not security.

The full contract is in the Plugin Development Guide.

Built-in Host Services

Primitives the host ships for your code and plugins, injected through DI, with no database-driver types at the call site.

Service What it does Providers
Payments
IPaymentService
Hosted checkout, refunds, and webhook events dispatched to per-plugin IPaymentEventHandlers. Each organisation charges into its own provider account (one per provider) at /Admin/PaymentProviders; which providers are allowed is set at /Platform/PaymentAccounts. Every payment received through any app is listed, with CSV and refunds, at /Admin/Payments; refunds are audited. A provider event reaches handlers and the payment.* outgoing webhooks only when it matches a known payment and its status rules (a late payment.failed for a paid row is dropped). Amounts are in micros (millionths of a unit). Stripe Checkout, PayPal Orders v2
File storage
IFileService
Per-organisation uploads with a size cap, content sniffing and tenant-scoped StoredFile rows. Visibility: Public (anonymous, cacheable) or Member — any active member (or platform admin) holding the id, with no owner or role check, so serve a narrower-audience file through your own authorised endpoint. Switching cloud provider keeps old files; switching database backend does not move bytes (old files answer 410 Gone). Show the uploader only FileUploadValidationException’s message. Bytes are encrypted under the Data Protection key ring unless the file is served directly from storage (Security → Stored files). Serve modes, including the per-upload serveMode: Configuration → File Storage. GridFS, Azure Blob, S3, PostgreSQL bytea, SQL Server varbinary (default follows the database)
PDF rendering
IPdfRenderer
Render QuestPDF documents or stamp values onto an existing PDF. Safe to inject in any host. QuestPDF (Community licence), PdfSharp
SMS
ISmsService
Outbound SMS through the job pipeline from the deployment’s one Twilio sender (/Platform/Sms). Opt-outs are per sender, so a STOP applies to every organisation: a reply that is only STOP, STOPALL, UNSUBSCRIBE, CANCEL, END, QUIT, REVOKE or OPT OUT opts out; START, UNSTOP or YES opts back in; an opt-out word inside other text prompts one “Reply STOP…” reply, after which a further opt-out word or Yes/Y within a day opts out. Delivery receipts reach /api/webhooks/platform/Twilio automatically; set it as the number’s incoming-message webhook for replies. A plugin is told once if its message later fails (ApiRequestTypes.SmsNotDelivered). A send whose attempt is cut off, or never comes back (a stopped or crashed process; after BackgroundServices:SmsStrandedSends:StrandedAfterMinutes, 60), ends OutcomeUnknown and is never sent again; only a later delivery receipt moves it on. Twilio (extensible through ISmsProvider)
Inbound email
IInboundEmailConsumer
The deployment’s one Mailgun catchall (/Platform/InboundEmail) plus an unguessable alias per organisation: each forwards mail to inbound+{alias}@{catchall domain}, shown at Admin → Inbound Email. The organisation is found from the envelope recipient, never the To: header. Mail for a deactivated organisation is dropped; the organisation’s optional sender check discards mail failing both SPF and DKIM; each message goes to ONE app — the consumer chosen on that page, or the only one — with no recipient and a dedupe key the consumer must be idempotent on. A received-mail log (sender and subject, encrypted) is kept 30 days. Mailgun
Incoming webhooks
IInboundWebhookHandler
/api/webhooks/organisation/{organisationId}/{provider} (tenant from the path), /api/webhooks/platform/{provider} (platform organisation) and /api/webhooks/platform/billing/{provider} (the platform payment account); never on customer hostnames. Signature-verified; every authentication failure is 401. Limits: 60/min per sender address × tenant × provider, 3,000/min per sender address × provider (full address, as providers send from pools); 1 MB body unless the handler declares more (inbound mail 25 MB, attachments not queued). Payment webhooks register with the provider automatically on save. Webhooks → Incoming (Admin and Platform) lists each with status, last delivery, counts and last failure. Stripe, PayPal, Twilio, Mailgun; plugins add their own
Outgoing webhooks
IOutboundWebhookEventBus
Subscriptions at /Admin/Webhooks/Outgoing (at most 25 per organisation), HMAC-signed (X-BB-Signature), retried with exponential backoff. Test fires: 30 per subscription, 60 per organisation, per hour. Paused after 20 consecutive failures, with admins notified; set Active to resume. Events over 256 KB are not sent. Host events: payment.succeeded / .failed / .refunded / .charged_back / .dispute_won, organisation.member.invited / .joined / .role_changed / .removed, subscription.activated / .past_due / .cancelled / .expired; add more with IOutboundWebhookEventCatalog. Platform-wide subscriptions (/Platform/Webhooks/Outgoing) get platform.organisation.*, platform.user.registered, platform.subscription.* and platform.payment.*, and are invisible to the platform organisation’s own admins. —
Scheduling
IAppointmentService
Tenant-scoped appointments with RFC 5545 RRULE recurrence and a reminder sweep that won’t double-send. Calendar rules follow the organisation’s time zone across DST; plain intervals step in exact time. At most 1,000 occurrences of one series per query window. Reminder lead up to a year, duration up to ten years (ArgumentException beyond). A reminder goes up to one sweep interval early, never after the start, and is re-armed only if start, lead or recurrence changes. GetRangeAsync omits cancelled appointments and ended series. An appointment is created Scheduled; CancelAsync is its only status change and is final (an edit never changes the status). —
Token hashing
ITokenHasher
Issue and verify high-entropy tokens for links unauthenticated visitors follow; only the hash is stored, verification is constant-time. SHA-256
Sequences
ISequenceService
Atomic per-organisation counters (order numbers, ticket ids). NextAsync never repeats or goes backwards under concurrency; a number taken by a failed write is not reused, so gaps are possible. MongoDB, PostgreSQL, SQL Server
Email templates
IEmailTemplateService
Renders a Markdown body inside a branded HTML email. Branding values are HTML-escaped and raw HTML in the body is stripped. A logo isn’t inherited — pass one in EmailBranding. Markdig

AI integrations (OpenAI, OpenRouter, Ollama, n8n) are shared across the deployment and managed at /Platform/ApiIntegrations; moderation needs a provider with a moderation endpoint.

API usage is metered per organisation unless Security:Audit:StoreApiUsage is false (configuration only, on every host, so a platform admin cannot stop the record of spend in one click). Every third-party call adds to one row per UTC day × type × paying account × organisation × integration × provider × model × plugin in the platform database (ApiUsageDaily): calls, failures, provider-reported tokens (AI only) and total response time — never content.

  • Counted outbound: AI, email, SMS, push (per device), Cloudflare custom-hostname calls, payment-provider calls, outgoing webhook deliveries and every AddApiClient client. Inbound: verified webhooks, and refused ones against no organisation. Only calls that reach the provider count. Not counted: external sign-in, DNS lookups, file storage.
  • Shown at Platform → API Usage (/Platform/ApiUsage) with totals, a daily trend and breakdowns by type, paying account, organisation, provider, model and app. Usage the platform causes itself is recorded against the platform organisation.
  • Counted in memory per process and flushed every BackgroundServices:ApiUsageFlush:IntervalSeconds (300, or at 100,000 distinct rows) as atomic increments; a crash loses at most that interval. Rows are kept two years (BackgroundServices:DataRetention:ApiUsageRetentionInDays) and survive organisation deletion.
  • The same counts always go out as OpenTelemetry metrics (meter BlazorBlueprint.ApiUsage) when a telemetry endpoint is set. No prices ship; multiply the token totals by your own rates.

Technology Stack

  • Runtime: .NET 10, ASP.NET Core, Blazor Server, SignalR, Fluent UI
  • Data: MongoDB, PostgreSQL or SQL Server; Redis for cache, SignalR backplane and job streams (Full only); the Data Protection key ring is in the platform database
  • Identity: ASP.NET Core Identity with custom stores, two-factor, passkeys, external login (Facebook, Google, Microsoft), per-organisation OIDC SSO
  • Email: SendGrid, SMTP, MailerSend, Mailgun
  • Hosting: Docker and Docker Compose, .NET Aspire for local development, GitHub Actions and Azure DevOps pipelines with a gated DbMigrator