# guennhatking/shoppe architecture

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

- Interactive diagram: https://gitdiagram.com/guennhatking/shoppe
- Repository: https://github.com/guennhatking/shoppe

## Overview

##### Main Components
- Frontend (User Interface): Represented by the Views folder (with sub-folders like Home, Login, AllProducts, SellerLogin, etc.) and the static assets in the wwwroot (e.g., CSS, JavaScript, Images). This is where the user interacts with the application.
- Backend (Business Logic and Controllers): The Controllers folder contains multiple controllers (e.g., HomeController, LoginController, RegisterController, etc.) that manage request routing, data input/output, and business logic.
- Data Access Layer: The Data folder (with the ShoppeWebAppContext, the Entity Framework context) along with the Migrations folders that record the evolution of the database schema.
- Domain Models: Located in the Models folder, these hold the application’s business entities (e.g., SanPham, DonHang, GioHang, etc.) and models specific to user authentication and login scenarios.
- Authentication/Authorization Components: Notice subdirectories and models like Login, which manage login view models and account related functionalities. This helps to manage both regular user and seller login flows.

##### Relationships and Interactions
- The User Interface (Views) sends requests to the Controllers.
- Controllers interact with the Domain Models for business logic, validation, and data processing.
- The Data Access layer (via ShoppeWebAppContext in Data and the Migration files) manages interactions with the underlying database.
- Static contents (site.css, site.js, images, etc.) are delivered via the wwwroot folder to the client.
- In case of authentication and login, the interaction spans specialized Controllers, specialized Models (within Login), and possibly a separate context (ApplicationDb) for that authentication data.

##### Important Architectural Patterns and Design Principles
- MVC (Model-View-Controller) Pattern: Clearly isolated responsibilities among the UI (Views), request-handling (Controllers), and data/business logic (Models + Data/Entity Framework).
- Separation of Concerns: File structure demonstrates separation between UI, business logic, and data persistence layers.
- Entity Framework Code-First Migrations: Shown by migration files for database versioning—this ties the domain models to the database schema layering.

##### Relevant Technologies and Frameworks
- ASP.NET MVC (the project solution and csproj file indicate usage of ASP.NET MVC framework).
- Entity Framework for ORM and migrations (evident in the Migrations and Data folders).
- Standard web technologies (HTML, CSS, JavaScript) for frontend presentation.
- .NET language (C#) for coding controllers, models, and other server-side logic.

- “UI Layer (Views & Static Assets)” for the Views and wwwroot.
- “Application Layer (Controllers)” for the business logic.
- “Domain Layer (Models)” for the business entities and view models.
- “Data Access Layer (Entity Framework Context & Migrations)” for the ShoppeWebAppContext and migration files.
- For example, use a blue rectangle for UI components, green for controllers, yellow for models, and red for data persistence elements.
- Annotations or notes highlighting that the repository uses Entity Framework code-first migrations to evolve database design over time.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    UI["UI Layer (Views & Static Assets)"]:::ui

    %% Application Layer (Controllers)
    CTRL["Application Layer (Controllers)"]:::controllers
    GEN_CTRL["General Controllers"]:::controllers
    LC["Login Controller"]:::auth
    SLC["Seller Login Controller"]:::auth

    %% Domain Layer (Models)
    MODELS["Domain Layer (Models)"]:::models
    GENERAL_MODELS["Business Models"]:::models
    AUTH_MODELS["Login Models"]:::auth

    %% Data Access Layer
    DATA["Data Access Layer (EF Context & Migrations)"]:::data

    %% Connections between layers
    UI -->|"HTTP_requests"| CTRL
    CTRL -->|"Processes"| MODELS
    CTRL -->|"DB_interactions"| DATA
    MODELS -->|"EF_code-first"| DATA

    %% Authentication-specific connections within Controllers and Models
    CTRL --> LC
    CTRL --> SLC
    LC -->|"Handles_login"| AUTH_MODELS
    SLC -->|"Handles_seller_login"| AUTH_MODELS

    %% Click Events
    click UI "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/Views"
    click UI "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/wwwroot"
    click CTRL "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/Controllers"
    click LC "https://github.com/guennhatking/shoppe/blob/main/ShoppeWebApp/Controllers/LoginController.cs"
    click SLC "https://github.com/guennhatking/shoppe/blob/main/ShoppeWebApp/Controllers/SellerLoginController.cs"
    click MODELS "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/Models"
    click AUTH_MODELS "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/Models/Login"
    click DATA "https://github.com/guennhatking/shoppe/blob/main/ShoppeWebApp/Data/ShoppeWebAppContext.cs"
    click DATA "https://github.com/guennhatking/shoppe/tree/main/ShoppeWebApp/Migrations"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controllers fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef models fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef auth fill:#d1c4e9,stroke:#4527a0,stroke-width:2px;
```
