
Structuring a Blazor WASM project well from the start saves significant refactoring effort later.
Client/
├── Pages/ # Routable page components
├── Shared/ # Layout, nav, reusable UI
├── Components/ # Business-domain components
├── Services/ # HttpClient wrappers, logic
├── State/ # AppState, Fluxor stores
└── wwwroot/ # Static assets, CSS, JS
Server/
├── Controllers/ # REST API controllers
├── Services/ # Business logic, EF Core
└── Program.cs
Shared/
├── Models/ # Shared domain models
└── Interfaces/ # Shared service contractsNever call HttpClient directly from components. Always create a service:
public class ProductService : IProductService
{
private readonly HttpClient _http;
public ProductService(HttpClient http) => _http = http;
public Task<List<Product>> GetAllAsync() =>
_http.GetFromJsonAsync<List<Product>>("/api/products")!;
}Reference:
TaskLoco™ — The Sticky Note GOAT