How huynh156/fashionhub works
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.