A modern recipe sharing application built with .NET 8 and Blazor Web App with server-side Razor components, featuring a clean architecture with separation of concerns.
RecipeSharing/
├── src/
│ ├── RecipeSharing.Domain/ # Core business entities
│ │ └── Entities/
│ │ └── Recipe.cs # Recipe entity with properties
│ │
│ ├── RecipeSharing.Application/ # Business logic and use cases
│ │ └── Services/
│ │ └── RecipeService.cs # Recipe service with CRUD operations
│ │
│ ├── RecipeSharing.Infrastructure/ # Data access and external services
│ │ └── Persistence/
│ │ └── RecipeRepository.cs # In-memory recipe repository
│ │
│ └── RecipeSharing.Web/ # Blazor Web App with server-side Razor components
│ ├── Components/
│ │ ├── Layout/
│ │ │ ├── MainLayout.razor # Main layout wrapper
│ │ │ └── NavMenu.razor # Navigation component
│ │ ├── Pages/
│ │ │ ├── Home.razor # Landing page
│ │ │ ├── Recipes.razor # Recipe listing page
│ │ │ └── RecipeDetail.razor # Recipe detail page
│ │ ├── App.razor # Root component
│ │ └── Routes.razor # Route definitions
│ ├── wwwroot/
│ │ ├── index.html # HTML entry point
│ │ └── css/
│ │ └── app.css # Application styles
│ └── Program.cs # DI configuration
│
└── tests/
└── RecipeSharing.Tests/ # xUnit test projects
└── Domain/
└── RecipeTests.cs # Domain entity tests
The project follows a clean architecture pattern with clear separation of concerns:
- Domain Layer (
RecipeSharing.Domain): Contains core business entities (Recipe) with no dependencies on other layers. - Application Layer (
RecipeSharing.Application): Implements business logic and services. Depends on Domain only. - Infrastructure Layer (
RecipeSharing.Infrastructure): Handles data persistence and external integrations. Depends on Domain only. - Presentation Layer (
RecipeSharing.Web): Blazor Web App with server-side Razor components. Depends on Application, Domain, and Infrastructure.
- Entity Design: The Recipe entity uses
requiredproperties for essential fields (Title, Ingredients, Instructions) to ensure data integrity. - Service Pattern: RecipeService in Application layer provides a simple in-memory implementation for MVP.
- Repository Pattern: IRecipeRepository in Infrastructure provides an abstraction for data persistence, enabling future database integration.
- Dependency Injection: Services are registered in Program.cs and available throughout the application.
- Nullable Reference Types: Enabled for type safety with proper null handling.
- Server-side Rendering: Using Blazor Web App with server-side Razor components for server-side rendering.
- .NET 8.0 SDK or later
- Visual Studio 2022, VS Code, or any .NET-compatible IDE
# Restore dependencies
dotnet restore
# Build the solution
dotnet build
# Run tests
dotnet test
# Run the web app (from src/RecipeSharing.Web directory)
dotnet run- Database Integration: Replace InMemoryRecipeRepository with Entity Framework Core and a real database.
- API Layer: Add a REST API layer for backend integration.
- Authentication: Implement user authentication and authorization.
- Search & Filtering: Add recipe search and filtering capabilities.
- User Reviews & Ratings: Allow users to rate and review recipes.
- Image Upload: Support recipe images and thumbnails.
- Mobile-Friendly UI: Enhance responsive design for mobile devices.
- Unit tests focus on domain entities and business logic.
- Tests use xUnit framework and follow AAA (Arrange-Act-Assert) pattern.
- Run
dotnet testto execute all tests.
- .NET 8.0: Target framework
- Blazor Web App: UI framework (server-side Razor components)
- xUnit: Testing framework
- C# 14: Language version with latest features
When making changes:
- Ensure all tests pass:
dotnet test - Follow C# naming conventions and null-safety practices
- Keep layers loosely coupled and focused on single responsibility
- Add tests for new domain logic