How tebrizetayi/cakeshop works
Project Type and Purpose
• This is a full‑stack ASP.NET Core MVC web application (“CakeShop”) that sells pies online.
• It uses a layered architecture:
• Presentation layer (ASP.NET Core Web)
• Business logic layer (BS Interface + Implementation)
• Data access layer (Entity Framework Core with Unit of Work & Repository)
• Domain models (DM), DTOs, ViewModels and a DataTransformation component
• Utility library and automated tests
File Structure
• Top‑level solution (“CakeShop.sln”) contains multiple class‑library and web‑app projects:
• CakeShop.Net.Web.AspCore (frontend)
• CakeShop.Net.BS.Interface + CakeShop.Net.BS.Implementation (business services)
• CakeShop.Net.Model.DM (Entity Framework Core domain models & migrations)
• CakeShop.Net.Model.DTO (data transfer objects)
• CakeShop.Net.Model.DataTransformation (maps between DM, DTO, VM)
• CakeShop.Net.Model.VM (view models)
• CakeShop.Net.Utility (cross‑cutting helpers)
• CakeShop.Net.Test (unit tests with Moq)
• Infrastructure/config files: appsettings.json, Startup.cs, Program.cs, bower.json (for Bootstrap/jQuery), migrations folder, test settings.
Read README Insights
• Architectural patterns: Unit of Work, Repository.
• Key technologies: ASP.NET Core MVC, EF Core (code‑first), Automapper, Bootstrap, jQuery, MS SQL, Moq, MSTest.
Main Components
a. Presentation Layer
• Browser (HTML/CSS/JS) ←→ ASP.NET Core MVC Web App
• Controllers (HomeController, PieController, etc.)
• Views + Razor TagHelpers + ViewComponents
• Static assets: Bootstrap, jQuery
b. Business Logic Layer
• Interfaces (IOrderBs, IPieBs, IUserManagementBs, IUnitOfWork)
• Implementations (OrderBs, PieBs, UnitOfWork, UserManagementBs)
• Automapper configuration for DTO↔VM
c. Data Access Layer
• Entity Framework Core DbContext (AppDbContext)
• Domain entities (Pie, Order, OrderDetail, ShoppingCartItem, User)
• Migrations
d. Database
• MS SQL Server
e. Utilities
• Utility functions (CakeShop.Net.Utility) used across layers
f. Data Transformation
• Transformation.cs (maps DM objects to DTO and VM)
g. Testing
• Unit tests project that mocks BS interfaces (Moq)
Relationships and Data Flow
• HTTP Request → Web App (Controllers) → Business Services (BS Implementation) → UnitOfWork → DbContext → SQL Database
• Business Services use Utility library and DataTransformation to map models
• Automapper invoked in Business Services or Controller to convert between DM, DTO, VM
• Browser interacts via HTML forms, AJAX calls (jQuery) to MVC controllers and API Controllers (PieApiController)
• Unit tests call BS Interface methods, mock underlying dependencies
Architectural Patterns & Principles
• Layered (N‑Tier) architecture
• Separation of concerns: Presentation / Business / Data
• Dependency Injection (builtin ASP.NET Core DI container)
• Unit of Work + Repository for transactional consistency
• Code‑First EF Core migrations
• Testability via interfaces and Moq