Starbender.RecipeApp
Overview
This application is a simple code sample to demonstrate my personal coding style and experience with .NET/Blazor. THe code repositiry is publicly available and can be found on GitHub.
Requirements
Create a new recipe application using Blazor (Web Assembly or Server). Application should use SQL Server. Ideally this should be under ~3 hours of work (but polish is appreciated).
- Allow users to create a recipe
- Title
- Description
- Image
- Ingredients (multiple)
- Instructions
- Recipes should be persisted to the database
- List of recipes
- Viewing the list of recipes should be done with ASP.NET Core via Blazor components. Scaffolding should not be used.
- The recipes list should be filterable.
- Individual Recipe
- Viewing an individual recipe should be done via a Razor Page.
- Site should use Bootstrap or some other type of front-end framework.
- Queries should use Entity Framework
Database migration
There is a script in src/migrate-database.cmd that will correctly run the database update. It will use the values in appsettings.json for the Default connection string.
Solution Layout
The solution is split into focused projects under src/:
Starbender.RecipeApp: ASP.NET Core host application (startup, Identity, Razor components endpoint mapping).Starbender.RecipeApp.Blazor: UI components (MudBlazor-based recipe editor/table dialogs and reusable UI pieces).Starbender.RecipeApp.Services.Contracts: application service interfaces and DTO contracts shared across layers.Starbender.RecipeApp.Services: application service implementations (CRUD orchestration and business workflow).Starbender.RecipeApp.EntityFrameworkCore: EF CoreDbContext, migrations, and repository implementations.Starbender.RecipeApp.Domain: domain module composition.Starbender.RecipeApp.Doamin.Shared: shared domain entities (Recipe,Ingredient,Unit,RecipeIngredient).Starbender.RecipeApp.Core: app-specific module wiring and cross-cutting registrations.Starbender.Core: generic abstractions and infrastructure primitives (IRepository, DTO/entity interfaces, module base).Starbender.BlobStorage: blob/file storage abstractions and implementations used for recipe images.
Application Architecture
The application uses a layered architecture with dependency inversion and module-based registration:
- UI Layer (
Starbender.RecipeApp.Blazor)
- Razor/MudBlazor components handle interaction, validation, and dialogs.
- Components call application services via interfaces from
Services.Contracts.
- Application Layer (
Starbender.RecipeApp.Services)
- Implements use cases such as creating/updating recipes and managing images.
- Maps entities <-> DTOs with AutoMapper.
- Coordinates persistence through
IRepository<T>abstractions.
- Data Layer (
Starbender.RecipeApp.EntityFrameworkCore)
ApplicationDbContextdefines EF Core model and relationships.- Repositories execute data access (including eager-loading for recipe ingredient graphs).
- SQL Server persistence is configured in the host (
Program.cs).
- Domain/Shared Model (
Starbender.RecipeApp.Doamin.Shared,Starbender.RecipeApp.Domain)
- Holds core entity definitions and domain module dependencies.
- Cross-cutting Modules (
Starbender.Core,Starbender.RecipeApp.Core,Starbender.BlobStorage)
- Provide module bootstrapping, common abstractions, and image/blob storage infrastructure.
Runtime request flow is:
Blazor Component -> App Service -> Repository -> EF Core DbContext -> SQL Server
and for image operations:
App Service -> Blob Container abstraction -> configured blob store.