# kayamuhammet/pastryshop architecture

> Architecture diagram of the GitHub repository kayamuhammet/pastryshop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kayamuhammet/pastryshop
- Repository: https://github.com/kayamuhammet/pastryshop

## Overview

##### Main Components
a. Clients
- Web Browser (Customer UI)
- Web Browser (Admin UI)
b. ASP.NET Core MVC Application
- Frontend Controllers & Views (HomeController, Areas/Admin)
- ViewComponents & ViewModels
- Models & FluentValidation
- AppDbContext (Entity Framework Core)
- Authentication/Authorization (AccountController, ApplicationUser)
c. Database
- SQL Server (DefaultConnection)
d. Static Asset Server
- wwwroot (CSS/JS/images for frontend & admin templates)
e. External Libraries/Services
- Chart.js (Dashboard)
- DataTables (Tables)
- SweetAlert2 (Notifications)
- jQuery, Bootstrap

##### Relationships & Data Flow
- Web browser sends HTTP(S) requests → ASP.NET Core Routing →
- If path starts with /Admin → Admin Area Controllers
- Else → Public Controllers (HomeController, Order, Menu, etc.)
- Controller invokes business logic / ViewModels and uses AppDbContext to query/update database
- AppDbContext uses EF Core to translate LINQ to SQL → SQL Server
- Controller returns a View (Razor .cshtml) or ViewComponent
- Razor view is populated with ViewModels and embedded JS/CSS libraries
- Static files (js/css/images) are served directly from wwwroot

##### Architectural Patterns & Principles
- MVC Pattern (Separation of Concerns: Models, Views, Controllers)
- Area Pattern (Admin area is logically partitioned)
- Repository / Unit of Work implicitly via EF Core’s DbContext
- Validation layer using FluentValidation in Models/Validators

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Clients"
        BrowserPublic["Web Browser (Public Site)"]:::client
        BrowserAdmin["Web Browser (Admin UI)"]:::client
    end

    subgraph "Web Application" 
        subgraph "Public Site"
            ControllersPublic["Controllers"]:::webapp
            ViewsPublic["Views (.cshtml)"]:::webapp
        end
        subgraph "Admin Area"
            ControllersAdmin["Areas/Admin/Controllers"]:::webapp
            ViewsAdmin["Areas/Admin/Views"]:::webapp
        end
        VC["ViewComponents"]:::webapp
        VM["ViewModels"]:::webapp
        DomainModels["Domain Models"]:::webapp
        Validators["Validation (FluentValidation)"]:::webapp
        Auth["Authentication/Authorization"]:::webapp
        DbCtx["AppDbContext"]:::data
    end

    Static["Static Assets & External Libs"]:::static
    SQL["SQL Server (DefaultConnection)"]:::db

    BrowserPublic -->|"HTTP/HTTPS"| ControllersPublic
    BrowserAdmin -->|"HTTP/HTTPS /Admin"| ControllersAdmin

    ControllersPublic -->|"invokes"| VM
    ControllersPublic -->|"uses"| DomainModels
    ControllersPublic -->|"validates via"| Validators
    ControllersPublic -->|"queries"| DbCtx
    ControllersPublic -->|"returns"| ViewsPublic

    ControllersAdmin -->|"invokes"| VM
    ControllersAdmin -->|"uses"| DomainModels
    ControllersAdmin -->|"validates via"| Validators
    ControllersAdmin -->|"queries"| DbCtx
    ControllersAdmin -->|"returns"| ViewsAdmin

    ControllersPublic -->|"invokes"| VC
    ControllersAdmin -->|"invokes"| VC
    VC -->|"renders component"| ViewsPublic

    DbCtx -->|"LINQ-to-SQL"| SQL

    Static -->|"serves CSS/JS/Images"| BrowserPublic
    Static -->|"serves CSS/JS/Images"| BrowserAdmin

    classDef client fill:#f9f,stroke:#333,stroke-width:1px;
    classDef webapp fill:#bbdefb,stroke:#333,stroke-width:1px;
    classDef data fill:#c8e6c9,stroke:#333,stroke-width:1px;
    classDef db fill:#ffe0b2,stroke:#333,stroke-width:1px;
    classDef static fill:#e0e0e0,stroke:#333,stroke-width:1px;

    click ControllersPublic "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Controllers/HomeController.cs"
    click ViewsPublic "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Views/Home/*.cshtml"
    click ViewsPublic "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Views/Shared/_Layout.cshtml"
    click ViewsPublic "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Views/Shared/_Navbar.cshtml"
    click ControllersAdmin "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Areas/Admin/Controllers/*.cs"
    click ViewsAdmin "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/Areas/Admin/Views/**"
    click DbCtx "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Data/AppDbContext.cs"
    click DomainModels "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Models/*.cs"
    click Validators "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Models/Validators/LoginViewModelValidator.cs"
    click Validators "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Models/Validators/RegisterViewModelValidator.cs"
    click VM "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Models/ViewModels/*.cs"
    click VC "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/ViewComponents/FooterViewComponent.cs"
    click VC "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/Views/Shared/Components/Footer/Default.cshtml"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/frontend-template/**"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/admin-template/**"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/lib/bootstrap/**"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/lib/jquery/**"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/lib/jquery-validation/**"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/lib/jquery-validation-unobtrusive/**"
    click Static "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/wwwroot/admin-template/js/init/chartjs-init.js"
    click Static "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/wwwroot/admin-template/js/init/datatables-init.js"
    click Static "https://github.com/kayamuhammet/pastryshop/tree/main/PastryShop/wwwroot/admin-template/js/lib/data-table/**"
    click Static "https://github.com/kayamuhammet/pastryshop/blob/main/PastryShop/wwwroot/js/sweetalert.js"
```
