# lnlonggg/doan1_2025 architecture

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

- Interactive diagram: https://gitdiagram.com/lnlonggg/doan1_2025
- Repository: https://github.com/lnlonggg/doan1_2025

## Overview

##### Project type and purpose
- This is an ASP.NET Core MVC full-stack web application named QL_CuaHangDienThoai (Phone Store Management).
- Purpose: provide an online storefront for browsing products, managing carts and orders, handling user accounts, and integrating with an external payment gateway (VnPay).

##### File structure
- Controllers folder: MVC controllers (Account, Home, Shop, Cart, Checkout, Admin, etc.).
- Views folder: Razor views under feature subfolders (Account, Shop, Cart, Checkout, etc.) plus Shared layout.
- Models folder: domain and EF Core entity definitions (DatabaseModels.cs) and ViewModels for data transfer.
- Data folder: ApplicationDbContext (Entity Framework Core context).
- Migrations folder: EF Core migrations for database schema.
- Services folder: business logic and external-service wrappers (VnPayService, VnPayLibrary).
- Helpers folder: utility classes (e.g. ImageHelper).
- wwwroot: static assets (CSS, JS, images, client-side libs).
- Program.cs & appsettings.json: application entry point and configuration.

##### README
- Very minimal (“# DoAn1-master”). No additional architectural notes; we infer MVC + EF Core + external payment integration.

a. Main components
- Client (Browser/Mobile)
- ASP.NET Core Web Server (Kestrel + HTTP Pipeline)
- MVC Layers:
– Controllers (AccountController, ShopController, etc.)
– Services/Helpers (VnPayService, ImageHelper)
– Data Access (ApplicationDbContext, EF Core)
- Database (SQL Server or any configured RDBMS)
- External Payment Gateway (VnPay)
- Static Asset Server (wwwroot)

b. Relationships and interactions
- Client ↔ Web Server: HTTP/HTTPS requests and responses
- Controllers invoke Services and Data Access layers
- Services wrap business logic and call external VnPay APIs
- ApplicationDbContext interacts with the relational database via EF Core
- Migrations update database schema
- Static assets served directly from wwwroot

c. Architectural patterns and design principles
- MVC (Model-View-Controller) for clear separation of concerns
- Repository pattern implied via DbContext
- Dependency Injection for Services and DbContext
- Layered architecture: Presentation → Business Logic → Data Access
- External integration encapsulated in Service classes

d. Key technologies, frameworks, libraries
- ASP.NET Core MVC
- Entity Framework Core with Migrations
- Razor Views (server-side rendering)
- VnPayLibrary for payment integration
- Bootstrap, jQuery in wwwroot for UI styling and validation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    Browser["Browser/Client"]:::client

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Controllers["Controllers"]:::server
        subgraph "Controllers"
            direction TB
            AccountController["AccountController"]:::server
            ShopController["ShopController"]:::server
            CartController["CartController"]:::server
            CheckoutController["CheckoutController"]:::server
            HomeController["HomeController"]:::server
            AdminController["AdminController"]:::server
            AccountManagementController["AccountManagementController"]:::server
            DonHangController["DonHangController"]:::server
            DienThoaiController["DienThoaiController"]:::server
        end
        Views["Razor Views"]:::server
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        Services["Services"]:::server
        subgraph "Services & Helpers"
            direction TB
            VnPayService["VnPayService"]:::server
            VnPayLibrary["VnPayLibrary"]:::server
            ImageHelper["ImageHelper"]:::server
        end
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        ApplicationDbContext["ApplicationDbContext (EF Core)"]:::server
        subgraph "Migrations"
            direction TB
            Migrations["EF Core Migrations"]:::server
        end
        Models["Domain Models"]:::server
        ViewModels["ViewModels"]:::server
    end

    %% Configuration & Entry
    subgraph "Configuration & Entry"
        direction TB
        ProgramCs["Program.cs"]:::config
        AppSettings["appsettings.json"]:::config
    end

    %% Static Assets
    StaticAssets["Static Assets (wwwroot)"]:::server

    %% Database
    Database[/"SQL Database"/]:::database

    %% External Service
    VnPayGateway["VnPay Gateway"]:::external

    %% Connections
    Browser -->|"GET/POST"| Controllers
    Controllers -->|"inject"| Services
    Controllers -->|"inject"| ApplicationDbContext
    Controllers -->|"returns Razor View"| Browser
    Browser -->|"requests CSS/JS"| StaticAssets
    Services -->|"API calls"| VnPayGateway
    ApplicationDbContext -->|"SQL Queries"| Database
    Migrations -->|"update schema"| Database

    %% Click Events
    click AccountController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/AccountController.cs"
    click ShopController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/ShopController.cs"
    click CartController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/CartController.cs"
    click CheckoutController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/CheckoutController.cs"
    click HomeController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/HomeController.cs"
    click AdminController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/AdminController.cs"
    click AccountManagementController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/AccountManagementController.cs"
    click DonHangController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/DonHangController.cs"
    click DienThoaiController "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Controllers/DienThoaiController.cs"
    click Views "https://github.com/lnlonggg/doan1_2025/tree/master/QL_CuaHangDienThoai/Views"
    click VnPayService "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Services/VnPayService.cs"
    click VnPayLibrary "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Services/VnPayLibrary.cs"
    click ImageHelper "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Helpers/ImageHelper.cs"
    click ApplicationDbContext "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Data/ApplicationDbContext.cs"
    click Migrations "https://github.com/lnlonggg/doan1_2025/tree/master/QL_CuaHangDienThoai/Migrations"
    click Models "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Models/DatabaseModels.cs"
    click ViewModels "https://github.com/lnlonggg/doan1_2025/tree/master/QL_CuaHangDienThoai/ViewModels"
    click StaticAssets "https://github.com/lnlonggg/doan1_2025/tree/master/QL_CuaHangDienThoai/wwwroot"
    click ProgramCs "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/Program.cs"
    click AppSettings "https://github.com/lnlonggg/doan1_2025/blob/master/QL_CuaHangDienThoai/appsettings.json"

    %% Styles
    classDef client fill:#b2f2bb,stroke:#333,stroke-width:1px
    classDef server fill:#cfe2ff,stroke:#333,stroke-width:1px
    classDef external fill:#ffd8a8,stroke:#333,stroke-width:1px
    classDef database fill:#e9ecef,stroke:#333,stroke-width:1px
    classDef config fill:#fff3bf,stroke:#333,stroke-width:1px
```
