SaaS CRM with Multi-Tenancy — Complete Source Code
A production-ready multi-tenant SaaS CRM application to serve multiple organizations from a single deployment. Built with .NET 10, ASP.NET Core, Blazor Web App (interactive server), MudBlazor and Vertical Slice Architecture — V4 adds workspace selection with a signed tenant cookie, multi-branch scoping per tenant, 68 modules across 9 areas and plain CQRS handlers wired to Minimal API endpoints.

The V4 upgrade keeps every business module and adds multi-tenant workspaces with multi-branch operations on a completely rebuilt application architecture.
Sign in, pick a workspace at /TenantSelection, and every query is scoped to it. 60 entity classes carry TenantId; a signed 12-hour tenant cookie (or a JWT tenant_id claim for API clients) drives the guard pipeline.
Each workspace gets its own branch list and a protected Head Office branch seeded during provisioning; branch scoping is tenant-scoped end to end.
7 platform modules — Tenant, Tenant User, System User, Health Check, Serilog, System File and Job Dashboard — exempt from tenant selection and reserved for the SuperAdmin role.
Every operation is a plain handler class with a single HandleAsync(). Blazor pages resolve handlers through HandlerInvoker with a fresh DI scope per call, while Minimal API endpoints inject the same handler directly. No dispatcher, no pipeline magic.
One Minimal API group per feature (/api/{entity}) with list, /export, /{id}/items and /{lookup}-lookup routes — JWT-protected and rate-limited. Access tokens rotate with SHA-256 hashed refresh tokens, Firebase SSO is optional, and Bearer clients select a workspace via POST /api/auth/select-tenant.
InMemory (zero-config), SQL Server and PostgreSQL — switch with a single IsUsed toggle in appsettings.json. Hangfire, Serilog, health checks, OpenTelemetry (OTLP) and four rate-limiting policies round out the ops stack.
SaaS businesses need to serve multiple organizations from one deployment — but building secure tenant isolation, managing separate customer data, and scaling multi-tenant infrastructure is complex and expensive.
Building separate CRM instances for each client is prohibitively expensive in infrastructure and maintenance. Blazor CRM Multi-Tenant allows multiple organizations to share one database and one deployment with complete data isolation via TenantId global query filters. Add new tenants in seconds without provisioning new servers.
Without proper tenant isolation, customer data can leak between organizations — a catastrophic security and compliance failure. EF Core global query filters automatically scope every query to the current tenant. Tenant A's contacts, deals, and activities are completely invisible to Tenant B. Zero data leakage by design.
Each tenant needs their own contacts, companies, and deals — but managing this separation manually is error-prone. Blazor CRM Multi-Tenant centralizes all tenant data with automatic scoping. Every API call, every database query, every UI interaction is tenant-aware.
Each tenant needs their own sales pipeline and reporting — but building per-tenant analytics is complex. Blazor CRM Multi-Tenant provides fully tenant-aware dashboards with KPI cards, pipeline charts, and win/loss rates scoped to each organization.
Complete end-to-end business features with tenant isolation — 68 modules across 9 areas, and every module is a complete vertical slice with Blazor pages, a plain CQRS handler, a FluentValidation validator, a Minimal API endpoint and EF Core queries.
Personal Info, Password, Avatar, Session
CRM Dashboard, Campaign, Budget, Expense, Lead, Lead Contacts, Lead Activities, Sales Team, Sales Representative, Todo, Todo Dashboard
Customer Group, Customer Category, Customer, Customer Contact, Vendor Group, Vendor Category, Vendor, Vendor Contact
Sales Quotation, Sales Order, Delivery Order, Sales Return, Credit Note, Invoice, Payment Receive — lists export to XLSX, Detail pages print to PDF
Purchase Requisition, Purchase Order, Goods Receive, Purchase Return, Debit Note, Bill, Payment Disburse — lists export to XLSX, Detail pages print to PDF
Unit Measure, Product Group, Product, Warehouse, Transfer Out, Transfer In, Positive/Negative Adjustment, Scrapping, Stock Count, Transaction Report, Stock Report, Movement Report
Booking Group, Booking Resource, Booking, Program Manager, Program Resource, Payment Method
Health Check, Serilog logs, System File — plus the Hangfire dashboard at /hangfire
Users, Roles, Tax, Country, Currency, Auto Number, Company, Branch
full inspection mode for appsettings.json
Tenant, Tenant User, System User, Health Check, Serilog, System File, Job Dashboard
ChatGPT / Claude / Gemini / DeepSeek (optional, bring your own API key)
Blazor CRM Multi-Tenant is built on the modern .NET ecosystem with production-grade libraries and tools.
| Layer | Technology |
|---|---|
| Framework | .NET 10 |
| Web Framework | ASP.NET Core 10 |
| UI Rendering | Blazor Web App — Interactive Server render mode (SignalR circuit) |
| UI Component Library | MudBlazor (Material Design components for Blazor) |
| UI Assets | SheetJS (Excel export), jsPDF (PDF print), ECharts (dashboards) |
| Architecture Pattern | Vertical Slice Architecture (VSA) via ASP.NET Core Areas + CQRS plain handlers (no MediatR) |
| Multi-Tenancy | IMultiTenant + EF Core global query filter (60 entities) + tenant selection cookie/JWT claim |
| API Style | Per-feature Minimal API groups (/api/{entity}) with Swagger/OpenAPI |
| Data Access | Entity Framework Core 10 — code-first, auto-create on startup, DataTable paging/search/sort helpers |
| Database | InMemory (zero-config) / SQL Server / PostgreSQL — toggle IsUsed in appsettings.json |
| Branch Scope | IHasBranch + BranchId — tenant-scoped branches, protected Head Office per workspace |
| Validation | FluentValidation |
| Authentication | ASP.NET Core Identity + JWT access/refresh token rotation + Firebase SSO (Google) |
| Authorization | Role-based (11 global roles incl. SuperAdmin + per-area roles) + rate-limited endpoint policies |
| Real-Time | SignalR circuit (Blazor Web App interactive server mode) |
| Background Jobs | Hangfire — dashboard at /hangfire, recurring jobs (daily log cleanup) |
| MailKit — SendGrid / Mailgun / SMTP / Mailjet (switch via appsettings.json) | |
| Logging | Serilog — rolling files, optional database sink and Seq, 3-day auto cleanup |
| Observability | Health checks (/health/live, /health/ready) + Admin Ops metrics dashboard + OpenTelemetry (OTLP) |
| AI Chat | Optional AI assistant — ChatGPT / Claude / Gemini / DeepSeek (provider + API key) |
Blazor CRM Multi-Tenant uses Vertical Slice Architecture (VSA) with plain CQRS handlers wired directly into per-feature Minimal API endpoints, and EF Core global query filters for complete tenant isolation — no MediatR dependency.
Each feature (Tenant, Lead, Sales Order, Product, etc.) lives in its own folder under ASP.NET Core Areas with its Blazor pages, feature components, plain CQRS handlers, validators, and Minimal API endpoint all in one place. Zero coupling between features. Every handler automatically applies tenant filtering.
Folder structure: Areas/SuperAdmin/Tenant/ contains Pages/, Components/, Cqrs/, Endpoints/, and the entity fields definition — everything for that feature with tenant awareness built in.
Tenant isolation is implemented at the EF Core level using global query filters combined with the soft-delete filter. 60 entity classes implement IMultiTenant, and every query is automatically scoped to TenantId == CurrentTenantId. Without a selected tenant the sentinel NO_TENANT_SELECTED makes reads return zero rows; inserts are auto-stamped with the current tenant (and throw without tenant context); changing TenantId on a row throws. Legacy rows are stamped on first update. Zero data leakage by design — no developer can accidentally query across tenants.
Tenant resolution: sign in, then pick a workspace at /TenantSelection. A signed HttpOnly X-Tenant-Token cookie (12 hours) becomes a tenant_id claim via claims transformation; TenantGuardMiddleware guards module areas and redirects to /TenantSelection?reason=no-tenant|invalid-tenant, while SuperAdmin pages are exempt. Bearer clients call POST /api/auth/select-tenant to receive a JWT with tenant_id.
The entire multi-tenant application — Blazor UI, REST API, tenant management, business logic, data access, and authentication — lives in one .NET 10 project. No distributed complexity, no microservice overhead. Single F5 to run. Deploy as one unit to Azure, IIS, or Docker. Perfect for SaaS startups that value velocity.
Indotalent/
├── Areas/
│ ├── Main/ # CRM dashboard, lead management, campaigns
│ │ ├── CrmDashboard/ # KPI dashboard (ECharts)
│ │ ├── Lead/ # Lead + Lead Contact + Lead Activity
│ │ ├── Campaign/ Budget/ Expense/
│ │ ├── SalesTeam/ SalesRepresentative/
│ │ ├── Todo/ TodoDashboard/
│ │ └── TenantSelection/ # workspace picker after sign-in
│ ├── ThirdParty/ # Customer, Vendor + categories, groups, contacts
│ ├── Sales/ # Quotation, Order, Delivery, Return, Credit Note,
│ │ # Invoice, Payment Receive
│ ├── Purchase/ # Requisition, Order, Goods Receive, Return,
│ │ # Debit Note, Bill, Payment Disburse
│ ├── Inventory/ # Product, Warehouse, Transfer, Adjustment,
│ │ # Scrapping, Stock Count, Reports
│ ├── Utilities/ # Booking, Program Manager, Payment Method
│ ├── Admin/ # User, Role, Tax, Country, Currency, Auto Number,
│ │ │ # Company, Branch (tenant-scoped)
│ ├── SuperAdmin/ # Tenant, TenantUser, SystemUser, JobDashboard +
│ │ │ # Health Check, Serilog, System File (global, no tenant)
│ ├── AI/Chat/ # multi-provider AI chat (ChatGPT/Claude/Gemini/DeepSeek)
│ ├── Identity/ # Account pages (Login, Register, Manage)
│ ├── Public/ # Home + built-in Documentation
│ └── Blazor/ # App shell, layouts, HandlerInvoker, TenantGuard
├── Infrastructures/ # Auth, tenancy, database, email, jobs, logging, OTel
├── Data/ # Entities (IMultiTenant), enums, seeders, migrations
├── Shared/ # ApiResponse, DataTable helpers, pagination
└── Program.cs # Single entry point with full configuration
Areas/Main/Lead/ # Feature folder convention (VSA)
├── Pages/ # Index / Create / Edit / Detail (.razor)
├── Components/ # feature-local dialogs and forms
├── Cqrs/ # GetList/GetById/Create/Update/Delete handlers + validators
├── Endpoints/ # LeadEndpoint.cs -> /api/lead
└── LeadFields.cs # entity field definitions
Security is baked into the architecture — multi-tenant isolation, Identity, JWT, RBAC, and audit trail.
Blazor CRM Multi-Tenant ships with tenant-aware authentication and authorization. ASP.NET Core Identity manages users with secure password hashing; roles are global constants and tenancy is a TenantUser mapping (tenant + user with IsActive) — newly registered users receive Guest and Member, and SuperAdmins are mapped to every tenant automatically. JWT access tokens with SHA-256 hashed refresh tokens and rotation protect the REST API, the signed X-Tenant-Token selection cookie drives the Blazor UI, and Firebase SSO (Google) is optional.
Role-based access control uses 11 global roles — Guest, Member, Admin, AI, Main, Sales, Purchase, Inventory, ThirdParty, Utilities and SuperAdmin — with every API group behind rate-limiting policies (global, authenticated, write, admin). EF Core global query filters combine TenantId == CurrentTenantId with the soft-delete filter so Tenant A's data never leaks to Tenant B; without a selected tenant the sentinel NO_TENANT_SELECTED makes reads return zero rows.
With Blazor Web App (interactive server mode), source code, database credentials, and tenant resolution logic never leave the server. All data access happens server-side via SignalR.
Blazor CRM Multi-Tenant exposes a complete tenant-aware REST Web API built on per-feature Minimal API groups — ready for mobile apps, third-party integrations, and external systems.
Every feature registers one Minimal API endpoint group. All endpoints are JWT-protected, role-authorized, rate-limited, tenant-scoped and return an ApiResponse<T> envelope.
The same tenant-aware pattern applies to every entity — vendor, lead, campaign, sales order, invoice, product, branch and more — with /export, /{id}/items and /{lookup}-lookup routes.
/swagger/export endpoints feed client-side .xlsx download via SheetJS; Detail pages print to PDF via jsPDFThree database providers, auto-provisioned workspaces, and flexible deployment options — ready to run in under 60 seconds.
Explore the Blazor CRM Multi-Tenant interface — tenant management, dashboards, contact management, sales pipeline, and more.
Test every feature — including multi-tenant isolation — before you buy. No registration required.
/TenantSelection. A signed HttpOnly X-Tenant-Token cookie (12 hours) becomes a tenant_id claim, and EF Core global query filters combine TenantId == CurrentTenantId with the soft-delete filter across 60 IMultiTenant entity classes. Without a selected tenant the sentinel NO_TENANT_SELECTED makes reads return zero rows; inserts are auto-stamped (and throw without tenant context); changing TenantId on a row throws. API clients use POST /api/auth/select-tenant. Zero data leakage between tenants.IsUsed toggle in appsettings.json — the database is auto-created and seeded on startup, including 4 demo tenants.HandleAsync() and returning ApiResponse<T>, a FluentValidation validator and a Minimal API endpoint group. Blazor pages call handlers through HandlerInvoker, while Minimal API endpoints inject them directly. Tenant isolation is enforced by EF Core global query filters.Complete, unrestricted C# source code with full multi-tenant SaaS architecture. Single .NET 10 project.
or
Secure checkout via PayPal or LemonSqueezy. No subscription.
MVC EDevKit Basic is the MVC implementation of Vertical Slice Architecture — every feature lives in one self-contained folder with Controllers, CQRS handlers, per-feature Endpoints, and Razor Views.
