# huynh156/fashionhub architecture

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

- Interactive diagram: https://gitdiagram.com/huynh156/fashionhub
- Repository: https://github.com/huynh156/fashionhub

## Overview

##### Project Type & Purpose
- FashionHub is an ASP.NET MVC-based web application targeting the e-commerce domain.
- Its core purpose is to enable online shopping with functionalities including product browsing, user account management, shopping carts, orders, and payment integrations.
- The README indicates that it meets standard SEO and admin/customer requirements, so the overall architecture must clearly separate presentation, business logic, and data layers.

##### Analyzing the File Structure
- Top-Level Directories:
- Controllers: Contains MVC controllers (e.g., BrandsController, CartController, CustomerController, etc.) that manage HTTP requests.
- Data: Includes entity classes (models) such as Product, Order, User, and the FashionHubContext, which likely represents the Entity Framework database context.
- Helper: Contains utility classes like AutoMapperProfile for object mapping, payment helpers (PaypalClient, VnPayLibrary), and session management tools.
- Models and ViewModels: Separate directories for domain models and specific view models for data presentation.
- Services: Contains interfaces and implementations (e.g., for VnPay payment services) which encapsulate business logic related to external integrations.
- Views: Organized into feature-based folders (e.g., Brands, Cart, Customer, Home, etc.), and also includes Shared components and partial views.
- wwwroot: Contains static assets like CSS, JavaScript, images, and even some PHP for form processing.
- Supporting Files:
- The solution file (FashionHub.sln) ties everything together.
- appsettings.json and appsettings.Development.json for configuration.
- The presence of a SQL file (FashionHub.sql) suggests a relational database backend.

##### Core Architectural Components (to include
a. Presentation Layer:
- MVC Views: The HTML/CSHTML files under the Views folder.
- View Components: For reusable UI sections (e.g., BrandsViewComponent, CategoriesViewComponent, FeatureProductViewComponent).
- Static Content: Managed by wwwroot folder (CSS, JS, Images, etc.).
b. Application/Business Logic Layer:
- Controllers: Request handling and coordination between the views and the underlying data/business logic.
- Services: For encapsulating business rules or integration logic such as VnPay/Paypal interactions.
- Helpers: For common utilities like data encryption, session management, and mappings (using AutoMapper).
- ViewModels: For shaping data specific to any view.
c. Data/Domain Layer:
- Data Models: Represents the domain entities (e.g., Product, Order, Category, User).
- Database Interaction: FashionHubContext acting as the data access layer typically through Entity Framework.
- SQL Database: FashionHub.sql indicates the use of a relational database.
d. External/Infrastructure Components:
- Payment Services: External gateways integrated via helper classes and corresponding services (VnPay, Paypal).
- Deployment/CI Tools: .github/workflows files indicate the use of GitHub Actions for CI/CD.

##### Relationships & Interactions
- The Controllers receive HTTP requests and use the Services and Data layer to process business logic and retrieve or update data.
- Data models interact with the database through the FashionHubContext, enforcing ORM-based data access.
- Helpers and Utilities facilitate cross-cutting concerns (like encryption and payment processing) accessible from controllers or services.
- ViewModels mediate between the controllers and the Views to format data for display.
- The static assets served from wwwroot support the frontend styling and interactivity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Request
    Client["User HTTP Request"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        CONTROLLERS["MVC Controllers<br/>(Handles HTTP requests)"]:::presentation
        VIEWS["Views (UI/CSHTML)"]:::presentation
        VIEWCOMPS["View Components<br/>(Reusable UI Elements)"]:::presentation
        WWWROOT["Static Assets<br/>(CSS/JS/Images)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Application/Business Logic Layer"
        SERVICES["Services<br/>(Business Logic & Integrations)"]:::business
        HELPERS["Helpers/Utilities<br/>(Mapping, Payments, Sessions)"]:::business
        VIEWMODELS["ViewModels<br/>(Data Shaping for Views)"]:::business
    end

    %% Data/Domain Layer
    subgraph "Data/Domain Layer"
        DATA["Data Models & EF Context"]:::data
        SQLDB["SQL Database<br/>(FashionHub.sql)"]:::data
    end

    %% External/Infrastructure
    subgraph "External/Infrastructure"
        PAYMENT["Payment Services<br/>(Paypal & VnPay)"]:::external
        CICD["CI/CD Pipelines<br/>(GitHub Actions)"]:::external
    end

    %% Flow Connections
    Client -->|"HTTP Request"| CONTROLLERS
    CONTROLLERS -->|"Invokes"| SERVICES
    CONTROLLERS -->|"Utilizes"| HELPERS
    SERVICES -->|"Processes Data"| DATA
    DATA -->|"Interacts with"| SQLDB
    SERVICES -->|"Formats Data"| VIEWMODELS
    CONTROLLERS -->|"Renders"| VIEWS
    VIEWS -->|"Loads"| WWWROOT
    VIEWCOMPS -->|"Supplies UI Components to"| VIEWS
    SERVICES -->|"Integrates"| PAYMENT
    CICD -->|"Deploys Updates to"| CONTROLLERS

    %% Architectural Note
    note1["Note: Employs MVC Pattern and Layered Architecture"]:::note

    %% Click Events
    click VIEWS "https://github.com/huynh156/fashionhub/tree/master/FashionHub/Views"
    click CONTROLLERS "https://github.com/huynh156/fashionhub/tree/master/FashionHub/Controllers"
    click VIEWCOMPS "https://github.com/huynh156/fashionhub/tree/master/FashionHub/ViewComponents"
    click WWWROOT "https://github.com/huynh156/fashionhub/tree/master/FashionHub/wwwroot"
    click SERVICES "https://github.com/huynh156/fashionhub/tree/master/FashionHub/Services"
    click HELPERS "https://github.com/huynh156/fashionhub/tree/master/FashionHub/Helper"
    click VIEWMODELS "https://github.com/huynh156/fashionhub/tree/master/FashionHub/ViewModels"
    click DATA "https://github.com/huynh156/fashionhub/tree/master/FashionHub/Data"
    click CICD "https://github.com/huynh156/fashionhub/tree/master/.github/workflows"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef business fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef external2 fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef note fill:#FCF3CF,stroke:#B7950B,stroke-width:1px, font-style:italic;
```
