# phuongvt24/webbrilifresh architecture

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

- Interactive diagram: https://gitdiagram.com/phuongvt24/webbrilifresh
- Repository: https://github.com/phuongvt24/webbrilifresh

## Overview

- Presentation Layer – This includes all the view files (.cshtml), static assets (CSS, JavaScript, images in the wwwroot folders for HomeAssets, BuyAndPayAssets, OverviewProductAssets, MyAccountAssets, etc.) and the client’s web browser.
- Controller Layer – Represent the various controllers that orchestrate the request–response cycle. Note that there are separate areas (for example, the “Areas/Admin” folder for administrative controllers and views, and regular controllers under “Controllers” that support user-facing functionality).
- Business Logic and Service Layer – Illustrate common classes (like AdminLogin, CustomerLogin, CustomerSession, and Pager) as well as repository patterns (abstract repositories in Repositories/Abstract with implementations in Repositories/Implementation, such as UserAuthenticationService and DAO classes for Products and Users). Also include helper classes such as SessionExtensions.
- Data Access Layer – Capture the use of Entity Framework, as evidenced by the presence of Models (domain classes, DTOs, and Data Access Objects) along with the DbContext (BriliFreshDbContext), Migrations, and SQL scripts (in the ScriptSqlBrili folder).
- External Services/Integrations – Indicate components like the EmailSender, Stripe-related settings (StripeSettings), and any other external dependencies (such as payment gateways, libraries from the “vendors” folder for third‑party JS/CSS frameworks and jQuery). This layer could also include the repository utilities for sending emails.

##### Relationships and data flow
- From the Business Layer, indicate how data flows to and from the Data Access Layer (EF DbContext, migrations, etc.) to interact with the underlying database.
- Separate flows for the administrative section (from the “Areas/Admin” controllers and views) versus the public site’s controllers and views.

##### Architectural patterns and design principles
- Usage of the Model-View-Controller (MVC) pattern, with a clear separation of concerns between presentation (Views), control flow (Controllers), and business/data (Models, Repositories).
- That the repository pattern is employed—abstract interfaces are defined for user authentication and likely others—separately implemented in the Implementation directory.
- Demonstrate how common configurations (like appsettings.json for deployment settings) and initialization (Program.cs) tie together the startup of the application.

##### Details on relevant technologies and frameworks
- ASP.NET MVC (as indicated by the .sln, .cs files, and cshtml view files).
- Entity Framework for data management and migrations.
- Client-side libraries including jQuery, Bootstrap, and various vendors for UI enhancements (chart libraries, date pickers, etc.).
- Integration with external services like Stripe (for payments) and email systems, as suggested by StripeSettings and EmailSender.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% External Entity
    Browser["Customer Browser"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        UserViews["User-Facing Views (.cshtml)"]:::presentation
        AdminViews["Admin Views (.cshtml)"]:::presentation
        StaticAssets["Static Assets (CSS,JS,Images)"]:::presentation
    end

    %% Controller Layer
    subgraph "Controller Layer"
        UserControllers["User Controllers (MVC)"]:::controller
        AdminControllers["Admin Controllers (MVC)"]:::controller
    end

    %% Business Logic and Service Layer
    subgraph "Business Logic & Service Layer"
        CommonBL["Common Business Logic (AdminLogin,CustomerLogin,CustomerSession,Pager)"]:::business
        RepoInterface["Repository Interfaces"]:::business
        RepoImpl["Repository Implementations"]:::business
        Helpers["Helper Classes (SessionExtensions)"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        EFDbContext["Entity Framework DbContext"]:::data
        DomainModels["Domain Models/DTOs/ViewModels"]:::data
        MigrationsSQL["Migrations & SQL Scripts"]:::data
    end

    %% External Services/Integrations
    subgraph "External Services & Integrations"
        EmailPayment["EmailSender & StripeSettings"]:::externalService
        ThirdPartyLibs["Client-Side Third Party Libraries"]:::externalService
    end

    %% Data Flow Connections
    Browser -->|"HTTPRequest"| UserViews
    Browser -->|"HTTPRequest"| AdminViews

    UserViews -->|"calls"| UserControllers
    AdminViews -->|"calls"| AdminControllers

    UserControllers -->|"invokes"| CommonBL
    AdminControllers -->|"invokes"| CommonBL

    CommonBL -->|"uses"| RepoInterface
    RepoInterface -->|"implementedBy"| RepoImpl
    CommonBL -->|"uses"| Helpers

    RepoImpl -->|"accesses"| DomainModels
    DomainModels -->|"managedBy"| EFDbContext
    EFDbContext -->|"applies"| MigrationsSQL

    CommonBL -->|"integratesWith"| EmailPayment
    RepoImpl -->|"integratesWith"| ThirdPartyLibs
    StaticAssets -->|"delivers"| Browser

    %% Click Events
    click UserViews "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Views"
    click AdminViews "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Areas/Admin/Views"
    click StaticAssets "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/wwwroot"
    click UserControllers "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Controllers"
    click AdminControllers "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Areas/Admin/Controllers"
    click CommonBL "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Common"
    click RepoInterface "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Repositories/Abstract"
    click RepoImpl "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Repositories/Implementation"
    click Helpers "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Helpers"
    click EFDbContext "https://github.com/phuongvt24/webbrilifresh/blob/master/WebBriliFresh/WebBriliFresh/Models/BriliFreshDbContext.cs"
    click DomainModels "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Models"
    click MigrationsSQL "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Migrations"
    click EmailPayment "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/Repositories/Utils"
    click ThirdPartyLibs "https://github.com/phuongvt24/webbrilifresh/tree/master/WebBriliFresh/WebBriliFresh/wwwroot/Adminassets/vendors"

    %% Styles
    classDef external fill:#ffd1dc,stroke:#d6336c,stroke-width:2px;
    classDef presentation fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef controller fill:#cff4fc,stroke:#055160,stroke-width:2px;
    classDef business fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#664d03,stroke-width:2px;
    classDef externalService fill:#f8d7da,stroke:#842029,stroke-width:2px;
```
