Skip to content

Latest commit

 

History

History
 
 

README.md

RecipeSharing - A Blazor Web Application

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.

Project Structure

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

Architecture

Vertical Slice Architecture

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.

Key Design Decisions

  1. Entity Design: The Recipe entity uses required properties for essential fields (Title, Ingredients, Instructions) to ensure data integrity.
  2. Service Pattern: RecipeService in Application layer provides a simple in-memory implementation for MVP.
  3. Repository Pattern: IRecipeRepository in Infrastructure provides an abstraction for data persistence, enabling future database integration.
  4. Dependency Injection: Services are registered in Program.cs and available throughout the application.
  5. Nullable Reference Types: Enabled for type safety with proper null handling.
  6. Server-side Rendering: Using Blazor Web App with server-side Razor components for server-side rendering.

Getting Started

Prerequisites

  • .NET 8.0 SDK or later
  • Visual Studio 2022, VS Code, or any .NET-compatible IDE

Building the Project

# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run tests
dotnet test

# Run the web app (from src/RecipeSharing.Web directory)
dotnet run

Future Enhancements

  1. Database Integration: Replace InMemoryRecipeRepository with Entity Framework Core and a real database.
  2. API Layer: Add a REST API layer for backend integration.
  3. Authentication: Implement user authentication and authorization.
  4. Search & Filtering: Add recipe search and filtering capabilities.
  5. User Reviews & Ratings: Allow users to rate and review recipes.
  6. Image Upload: Support recipe images and thumbnails.
  7. Mobile-Friendly UI: Enhance responsive design for mobile devices.

Testing Strategy

  • Unit tests focus on domain entities and business logic.
  • Tests use xUnit framework and follow AAA (Arrange-Act-Assert) pattern.
  • Run dotnet test to execute all tests.

Technology Stack

  • .NET 8.0: Target framework
  • Blazor Web App: UI framework (server-side Razor components)
  • xUnit: Testing framework
  • C# 14: Language version with latest features

Contributing

When making changes:

  1. Ensure all tests pass: dotnet test
  2. Follow C# naming conventions and null-safety practices
  3. Keep layers loosely coupled and focused on single responsibility
  4. Add tests for new domain logic