Tutorials Blazor Architecture & Enterprise Patterns
Project Structure: Proper layout for large-scale systems
On this page
Structuring for Scale
A messy project structure will kill your productivity. For enterprise Blazor, we follow a strict **Clean Architecture** approach.
1. The "Shared" Library Pattern
Always create a separate MyProject.Shared class library. This is where your DTOs, Enums, and FluentValidation rules live. Both your **Client (WASM)** and your **Server (API)** should reference this project. This ensures 100% type safety across the network boundary.
2. Feature-Based Folders
Instead of /Components, /Pages, /Models, use **Feature Folders**:
/Features/Billing/BillingList.razor
/Features/Billing/BillingDetail.razor
/Features/Billing/BillingService.cs
This makes it much easier to find everything related to a single business requirement.
3. Architect Insight
Q: "Where should the API client logic go?"
Architect Answer: "Create an IClientApiService in the Client project. Implement it using HttpClient. This allows you to Unit Test your components by mocking the API service instead of trying to mock the complex Http stack. It also keeps your UI code clean of 'Fetch' and 'Json' boilerplate."