# nguyennhat99/computerdeviceshopping architecture

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

- Interactive diagram: https://gitdiagram.com/nguyennhat99/computerdeviceshopping
- Repository: https://github.com/nguyennhat99/computerdeviceshopping

## Overview

##### Project type and purpose
- Full-stack web application: public storefront + admin (private) portal
- Built on ASP.NET Core MVC, EF Core, SQL Server, Razor Views, with payment/email integrations

##### File structure
- Presentation layer:
- Controllers/ (public site controllers)
- Areas/PrivateSite/Controllers/ (admin controllers)
- Views/ and Areas/PrivateSite/Views/ (Razor view files)
- ViewComponents/, DTOs/, ViewModel/
- wwwroot/ (static assets: JS, CSS, images, lib)
- Business-logic & services:
- Services/ShoppingCartService.cs, UserLoggedService.cs, VnPayService.cs
- Common/ (authentication, email sender, helpers, CommentHub.cs for SignalR)
- Data-access layer:
- Models/ComputerDeviceDataContext.cs (DbContext) + entity classes
- Config & startup:
- Program.cs, appsettings*.json, Properties/launchSettings.json

##### README for technical stack & external services
- ASP.NET Core MVC, SignalR, Session & Cookie Auth
- EF Core + SQL Server
- MailKit (EmailSender)
- VNPay Payment Gateway integration via VnPayLibrary.cs

1. Browser → Kestrel web server (HTTP/S requests)
2. Web server → Controller (public or admin)
3. Controller → Services or directly → DbContext
4. Services → DbContext → SQL Server
5. Services → External (SMTP, VNPay API)
6. SignalR: Controller → CommentHub → Browser clients
7. Static requests: Browser → wwwroot (served by web server)

##### Architectural patterns & design principles
- MVC (separate Models, Views, Controllers)
- Layered architecture (Presentation → BLL → DAL → Data/External)
- Dependency Injection for services & DbContext
- Area-based segregation for public vs. admin portals
- DTOs/ViewModels for data transfer to views
- SignalR for real-time updates (hub in Common/CommentHub.cs)

##### Final checklist
- All major folders/files represented as logical components
- Public vs. Admin separation clearly shown
- Data flows (HTTP, DB calls, external API calls, SignalR messages)
- Authentication & authorization modules
- Static content delivery path (wwwroot)
- External integrations (Email, Payment)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["Browser"]:::external
    Browser -->|"HTTP/S Requests"| WebServer["Kestrel / IIS\n(Program.cs)"]:::external
    Browser -->|"Fetch Static Assets"| StaticAssets["wwwroot/"]:::presentation
    click StaticAssets "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/wwwroot/"

    %% Presentation Layer - Public Site
    subgraph "Public Site" 
        direction TB
        PC["Public Controllers"]:::presentation
        PV["Razor Views"]:::presentation
        VC["ViewComponents"]:::presentation
        DTO["DTOs"]:::presentation
        VM["ViewModels"]:::presentation
    end
    click PC "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/Controllers/"
    click PV "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/Views/"
    click VC "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/ViewComponents/"
    click DTO "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/DTOs/"
    click VM "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/ViewModel/"

    %% Presentation Layer - Admin Site
    subgraph "Admin Site"
        direction TB
        AC["Admin Controllers"]:::presentation
        AV["Admin Razor Views"]:::presentation
    end
    click AC "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/Areas/PrivateSite/Controllers/"
    click AV "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/Areas/PrivateSite/Views/"

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        SCS["ShoppingCartService"]:::logic
        ULS["UserLoggedService"]:::logic
        VPS["VnPayService"]:::logic
        CT["CommonTools"]:::logic
        CA["CustomAuthentication"]:::logic
        CJ["CustomAuthorize"]:::logic
        CH["CommentHub (SignalR)"]:::logic
        ES["EmailSender"]:::logic
    end
    click SCS "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Services/ShoppingCartService.cs"
    click ULS "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Services/UserLoggedService.cs"
    click VPS "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Services/VnPayService.cs"
    click CT "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Common/CommonTools.cs"
    click CA "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Common/CustomAuthentication.cs"
    click CJ "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Common/CustomAuthorize.cs"
    click CH "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Common/CommentHub.cs"
    click ES "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Common/EmailSender.cs"

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DBCTX["ComputerDeviceDataContext"]:::data
        EM["Entity Models"]:::data
    end
    click DBCTX "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Models/ComputerDeviceDataContext.cs"
    click EM "https://github.com/nguyennhat99/computerdeviceshopping/tree/main/Models/"

    %% External Services & Database
    SQL["SQL Server"]:::external
    SMTP["SMTP Server\n(via MailKit)"]:::external
    VNPAY["VNPAY Gateway"]:::external
    VNPAYLib["VnPayLibrary"]:::external
    click VNPAYLib "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Payments/VnPayLibrary.cs"

    %% Configuration
    subgraph "Configuration & Startup"
        direction TB
        AppSettings["appsettings.json\nappsettings.Development.json"]:::external
        Launch["launchSettings.json"]:::external
    end
    click AppSettings "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/appsettings.json"
    click AppSettings "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/appsettings.Development.json"
    click Launch "https://github.com/nguyennhat99/computerdeviceshopping/blob/main/Properties/launchSettings.json"

    %% Connections: Presentation to BLL and DAL
    WebServer --> PublicSite{"Public Site"} 
    WebServer --> AdminSite{"Admin Site"}
    PublicSite --> PC
    PublicSite --> PV
    PublicSite --> VC
    PublicSite --> DTO
    PublicSite --> VM

    AdminSite --> AC
    AdminSite --> AV

    PC -->|"invoke"| SCS
    PC -->|"check session"| ULS
    PC -->|"payment call"| VPS
    PC -->|"push comments"| CH
    AC -->|"invoke"| SCS
    AC -->|"auth"| CA
    AC -->|"authorize"| CJ

    SCS --> DBCTX
    ULS --> DBCTX
    VPS --> DBCTX
    ES --> SMTP
    VPS --> VNPAY
    CH -->|"real-time"| Browser

    DBCTX --> SQL
    DBCTX --> EM

    %% Static assets served
    StaticAssets --> WebServer

    %% Config injection
    WebServer --> AppSettings
    WebServer --> Launch

    %% Styles
    classDef presentation fill:#d0e6f8,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef logic fill:#dff0d8,stroke:#3c763d,color:#3c763d,stroke-width:1px;
    classDef data fill:#fcf8e3,stroke:#8a6d3b,color:#8a6d3b,stroke-width:1px;
    classDef external fill:#f2dede,stroke:#a94442,color:#a94442,stroke-width:1px;
```
