# thuanthichlaptrinh/websitenongsan_mvc architecture

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

- Interactive diagram: https://gitdiagram.com/thuanthichlaptrinh/websitenongsan_mvc
- Repository: https://github.com/thuanthichlaptrinh/websitenongsan_mvc

## Overview

##### Project type and purpose
- This is a full-stack, monolithic ASP.NET MVC e-commerce website for buying and selling agricultural products (“WebsiteNongSan”).
- It targets two user personas: public shoppers (user area) and administrators (Admin area).

##### File structure
- Top-level solution and project files:
- WebsiteNongSan.sln, WebsiteNongSan.csproj
- Global.asax, RouteConfig.cs – ASP.NET MVC entry point and routing
- packages.config – NuGet dependencies (Entity Framework, jQuery, etc.)
- MVC directories:
- Controllers (NguoiDungController, SanPhamController, DatHangController, etc.)
- Views (Areas/Admin/Views for admin UI; Views/Shared and Views/{Feature} for user UI)
- Models (Entity Framework EDMX model in Model1.edmx, entity classes, context)
- Static assets:
- Content/Assets (CSS, JS, images) + Bootstrap5 folder
- Scripts (jQuery, validation)
- plugin/ckeditor and plugin/ckfinder – WYSIWYG editor and file manager
- Admin Area: Uses Areas/Admin to separate admin controllers, views, and static assets.

##### Confirm technical stack and architecture from README
- ASP.NET MVC on .NET Framework
- Entity Framework (Database-first using .edmx)
- SQL Server backend
- Frontend libraries: Bootstrap 5, jQuery, CKEditor, CKFinder

a. Main components to represent
- Client browser (User UI vs Admin UI)
- Web Server – ASP.NET MVC Application
- MVC Layers:
­– Controllers (route incoming HTTP to actions)
­– Views (Razor .cshtml templates for HTML)
­– Models / Data Access (EF DbContext and entity classes)
- SQL Server Database
- File storage for uploads (served via CKFinder)
- Third-party libraries (CKEditor plugin, CKFinder connector)
- Static asset server (serving CSS, JS, images)

b. Relationships and interactions
- User/Admin browser issues HTTP requests → Web Server
- Routing engine (Global.asax/RouteConfig) → appropriate Controller/Area
- Controller calls EF DbContext → fetch/update data in SQL Server
- Controller returns a View (.cshtml) populated with Model data
- Client loads static assets (CSS, JS) and editor plugins (CKEditor)
- For file uploads, CKEditor calls CKFinder connector → writes to server file system
- Admin controllers under Areas/Admin namespace handle management workflows

c. Architectural patterns and design principles
- MVC pattern to separate concerns
- Area segregation for Admin vs User modules
- Database-first Entity Framework for data layer
- Layered architecture: Presentation (Views + static assets), Application (Controllers + routing), Data (EF + SQL Server)

d. Key technologies and libraries
- .NET Framework / ASP.NET MVC
- Entity Framework (EDMX + DbContext)
- SQL Server
- Bootstrap 5, jQuery
- CKEditor, CKFinder (with ASPX connector)

##### Detail
- Both user and admin features as separate modules.
- EF EDMX model as part of the data access layer.
- Don’t shy away from labeling every major folder or service – more granularity helps stakeholders understand responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    BrowserUser["Public Browser"]:::client
    BrowserAdmin["Admin Browser"]:::client

    %% Routing
    RouteConfig["RouteConfig (Global.asax/App_Start)"]:::server

    %% Web Server
    subgraph "Web Server (ASP.NET MVC)"
      direction TB

      ControllersGroup["Controllers"]:::server
      subgraph Controllers
        direction TB
        NguoiDungController["NguoiDungController"]:::server
        SanPhamController["SanPhamController"]:::server
        DatHangController["DatHangController"]:::server
        subgraph "Admin Controllers"
          direction TB
          QuanLySanPhamController["QuanLySanPhamController"]:::server
          QuanLyDonhangController["QuanLyDonhangController"]:::server
          QuanLyNguoiDungController["QuanLyNguoiDungController"]:::server
          QuanLyLoaiSanPhamController["QuanLyLoaiSanPhamController"]:::server
          QuanLyNhaCungCapController["QuanLyNhaCungCapController"]:::server
          QuanLyKhuyenMaiController["QuanLyKhuyenMaiController"]:::server
          QuanLySanPhamKhuyenMaiController["QuanLySanPhamKhuyenMaiController"]:::server
          ThongBaoController["ThongBaoController"]:::server
          ThongKeController["ThongKeController"]:::server
        end
      end

      subgraph "Views"
        direction TB
        PublicViews["Views (.cshtml)"]:::server
        AdminViews["Areas/Admin/Views"]:::server
      end

      subgraph "Data Access"
        direction TB
        EFModel["Model1.edmx & DbContext"]:::server
      end

      StaticAssets["Static Assets (CSS/JS/Images)"]:::assets
      CKEditor["CKEditor Plugin"]:::plugin
      CKFinder["CKFinder Connector"]:::plugin
    end

    %% Database and Storage
    SQLServer["SQL Server"]:::database
    FileStorage["File Storage"]:::database

    %% Flows
    BrowserUser -->|HTTP Request| RouteConfig
    BrowserAdmin -->|HTTP Request| RouteConfig
    RouteConfig --> Controllers
    Controllers --> EFModel
    EFModel -->|SQL Queries| SQLServer
    Controllers --> Views
    Views -->|HTML Response| BrowserUser
    Views -->|HTML Response| BrowserAdmin
    BrowserUser -->|Load Assets| StaticAssets
    BrowserAdmin -->|Load Assets| StaticAssets
    BrowserAdmin -->|Use Editor| CKEditor
    CKEditor -->|"Connector Request"| CKFinder
    CKFinder -->|Write Files| FileStorage

    %% Click Events
    click RouteConfig "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/App_Start/RouteConfig.cs"
    click NguoiDungController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Controllers/NguoiDungController.cs"
    click SanPhamController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Controllers/SanPhamController.cs"
    click DatHangController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Controllers/DatHangController.cs"
    click QuanLySanPhamController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLySanPhamController.cs"
    click QuanLyDonhangController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLyDonhangController.cs"
    click QuanLyNguoiDungController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLyNguoiDungController.cs"
    click QuanLyLoaiSanPhamController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLyLoaiSanPhamController.cs"
    click QuanLyNhaCungCapController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLyNhaCungCapController.cs"
    click QuanLyKhuyenMaiController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLyKhuyenMaiController.cs"
    click QuanLySanPhamKhuyenMaiController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/QuanLySanPhamKhuyenMaiController.cs"
    click ThongBaoController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/ThongBaoController.cs"
    click ThongKeController "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Areas/Admin/Controllers/ThongKeController.cs"
    click PublicViews "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Views"
    click AdminViews "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Areas/Admin/Views"
    click EFModel "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/blob/master/WebsiteNongSan/Models/Model1.edmx"
    click StaticAssets "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Content/Assets"
    click CKEditor "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Content/plugin/ckeditor"
    click CKFinder "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Content/plugin/ckfinder"
    click FileStorage "https://github.com/thuanthichlaptrinh/websitenongsan_mvc/tree/master/WebsiteNongSan/Content/plugin/ckfinder/userfiles"

    %% Styles
    classDef server fill:#cce5ff,stroke:#006bb3,color:#000
    classDef database fill:#d4edda,stroke:#155724,color:#000
    classDef plugin fill:#f8d7da,stroke:#721c24,color:#000
    classDef client fill:#fff3cd,stroke:#856404,color:#000
    classDef assets fill:#ffeeba,stroke:#856404,color:#000
```
