webplatform

One .NET platform behind several client sites.

What it is

A platform that gives a small business a proper website with content editing, news, contact forms and billing, without hiring an agency. Each client site has its own host name, and one codebase serves all of them.

How it works

The backend is about thirty modules. Each one owns its Postgres schema and talks to the others only through contracts and a transactional outbox, and architecture tests check those boundaries. A site starts from a reviewed seed of JSON and images. Content is data, so changing a sentence needs no rebuild.

Keeping tenants apart

Each request works out its site once, from the signed token or the host name, and only a platform administrator may act on another site. Every table that belongs to a site has a database query filter, so a query that forgets the site still gets only that site's rows. Architecture tests fail the build when a site table has no filter, when code bypasses the filter outside a reviewed list where every entry gives a reason, or when an endpoint does not say whether it needs sign-in. A separate test suite signs in as one tenant and tries to read another tenant's data, module by module.

Sign-in

Staff and customers are separate identities with separate tokens. Staff sign in to the admin with a password, an OAuth provider or a passkey, and can add a TOTP second factor. Customers get single-use sign-in links. Access tokens last 15 minutes. Refresh tokens last up to 30 days and are replaced on every use. On the web both live in httpOnly cookies, never in browser storage. Sign-in endpoints are rate-limited per IP address. Ten wrong passwords for an account from one address lock out only that address for 15 minutes, so an attacker cannot lock the real user out. The whole account locks only when failures pile up from many addresses. Permissions are cached, and the cache is dropped as soon as they change.

Secrets and dependencies

Production values live in Infisical. At deploy time a machine identity on the server renders them, and that identity never touches GitHub. If Infisical cannot be reached, the deploy fails and the running config stays as it was. In production the API refuses to start with a placeholder signing key, and the same check covers Stripe and GoPay: it will not boot with stub payment clients whose webhooks cannot be verified. Every image is scanned with Trivy before it is pushed. A weekly job rescans what is actually deployed, so a vulnerability published after a release still turns up. I take a new dependency version only once it is at least a week old.

Staging

A separate staging server holds test data only. Any branch can be built and tried there without spending CI minutes. It has its own secrets project, cannot reach the production servers and is deliberately not backed up. A change goes from its branch to staging, and reaches production only in a release I approve.

What I decided

When I audit the platform, I fix what I find. In the October security sweep all eight critical, high and medium findings were fixed test-first: the new test had to fail before the fix and pass after it. Gitleaks found no leaked secret anywhere in the git history.

What comes next

Planned, not built yet. Production deploys move onto the private network, as the homelab's already have, so the platform server no longer needs public SSH. A live probe will try cross-tenant reads against the running system, and a scanner will run against a production-mode stack. Support gets account impersonation with a full audit trail. Custom domains get verified automatically instead of by hand. Each client will choose whether customers, payments and vouchers are shared across their sites or kept per site. The AI assistant gets red-teamed before it is switched on.

Architecture

  1. Caddyper-tenant hosts
  2. Web, admin and mobile apps
  3. About 30 modules.NET 10my code
  4. Transactional outbox
  5. Postgresschema per module
Status
Private
Built with
.NET 10C#Vertical SlicePostgresNext.jsReactStripeDocker
Numbers
~30modules
3apps
2payment providers
History
  1. The first client site is on its own domain, behind a launch page until its launch day.
  2. The first tenants in production, with content-driven page sections.