# andyninety9/skincareproductssalessystem architecture

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

- Interactive diagram: https://gitdiagram.com/andyninety9/skincareproductssalessystem
- Repository: https://github.com/andyninety9/skincareproductssalessystem

## Overview

##### Project Type & Purpose
- This is a full-stack microservices-based web application for selling and managing skincare products.
- The system supports multiple roles (customers, staff, and administrators) with features ranging from product exploration and skin type diagnostics (via quizzes) to comprehensive order management, payment processing, and analytics.
- The README confirms use of a React-based frontend (built with Vite) and a .NET Core Web API backend, along with key integrations (e.g., PostgreSQL, Redis, AWS S3, Google OAuth, VNPay, and GHN for delivery).

##### Analyzing the File Structure
- The top-level directories include assets, database documents, and a substantial src folder.
- Under src, “backend” contains two core components:
– "ApiGateway": This component (with its own solution and Dockerfile) is likely implemented as an API gateway service that routes and manages client requests.
– "WebService": Contains multiple layers (Application, Domain, Infrastructure, WebApi, and extensive testing) that implement business logic, data access via repositories, service integrations (e.g., for AWS, Google Auth, Redis, Payment, Delivery), and provide RESTful controllers.
- The “frontend” directory holds source code, components, layouts, Redux stores, routes, and configuration files for a React/Vite SPA.
- Presence of Docker files, docker-compose configuration, and environment files for both front and backend further suggests containerized deployment across services.

##### Key Components
a. Frontend (React SPA):
– Represent the client-side interface which includes pages for product listing, order history, FAQs, quiz for skin type, etc.
– Tag the integration with the backend Web API over HTTP.

b. Backend Services:
- API Gateway:
– Acts as the primary entry point for client requests.
– Routes and load-balances to backend WebServices.
- Web Service (Microservice):
– Contains Business Logic, Application Services, Domain Entities, and Repositories.
– Implements service features such as product management, order processing, quiz services, and user management.
– Integrates with external services (e.g., AWS S3 for image storage; Google OAuth for authentication; VNPay for payment processing; GHN API for delivery support; Redis for caching).

c. Database:
– The project uses a PostgreSQL database, as shown in configuration files.
– In addition, several SQL scripts and an ERD are present in the database folder.

d. Caching and Storage:
- Redis for session management and caching.
- AWS S3 for storing product images and possibly other assets.

e. External Integrations:
– Google OAuth service for authentication.
– VNPay service for payment gateway integrations.
– GHN API for managing delivery/logistic workflows.

##### Relationships and Interactions
- The API Gateway forwards requests to the Web Service.
- Back-end services interact with the PostgreSQL database for persistent storage.
- The Web Service utilizes Redis as a caching layer.
- The Web Service also interacts with external services: AWS S3 for file storage; Google OAuth for secure auth; VNPay for payment processing; and GHN for logistic/delivery services.

##### Architectural Patterns and Design Principles
- Microservices: Different backend components like the API Gateway and the Web Service are loosely coupled, allowing independent scaling and maintenance.
- Layered Architecture: In the Web Service, separate layers (Application, Domain, Infrastructure) demonstrate the clean separation of concerns.
- Use of Middleware (e.g., visitor tracking, exception handling) suggests the use of cross-cutting concerns in request processing.
- Containerization is supported by Docker and Docker Compose instructions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    Frontend["Frontend (React/Vite SPA)"]:::frontend
    APIGateway["API Gateway (.NET Core)"]:::backend
    WebService["Web Service (Business Logic & Domain)"]:::backend
    Database["PostgreSQL Database"]:::database

    %% Main Flow
    Frontend -->|"HTTP"| APIGateway
    APIGateway -->|"Routes"| WebService
    WebService -->|"Reads/Writes"| Database

    %% Caching
    Redis["Redis Cache"]:::cache
    WebService -->|"Cache"| Redis

    %% External Integrations Subgraph
    subgraph "External Integrations"
        AWS_S3_Abs["AWS S3 (Abstraction)"]:::ext
        AWS_S3_Inf["AWS S3 (Infrastructure)"]:::ext

        GoogleOAuth_Abs["Google OAuth (Abstraction)"]:::ext
        GoogleOAuth_Inf["Google OAuth (Infrastructure)"]:::ext

        VNPay_Abs["VNPay Payment Gateway (Abstraction)"]:::ext
        VNPay_Inf["VNPay Payment Gateway (Infrastructure)"]:::ext

        GHN_Abs["GHN Delivery API (Abstraction)"]:::ext
        GHN_Inf["GHN Delivery API (Infrastructure)"]:::ext
    end

    %% Connections to External Integrations
    WebService -->|"Cloud"| AWS_S3_Abs
    WebService -->|"Cloud"| AWS_S3_Inf

    WebService -->|"Auth"| GoogleOAuth_Abs
    WebService -->|"Auth"| GoogleOAuth_Inf

    WebService -->|"Payment"| VNPay_Abs
    WebService -->|"Payment"| VNPay_Inf

    WebService -->|"Delivery"| GHN_Abs
    WebService -->|"Delivery"| GHN_Inf

    %% Click Events
    click Frontend "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/frontend"
    click APIGateway "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/ApiGateway"
    click WebService "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService"
    click Database "https://github.com/andyninety9/skincareproductssalessystem/tree/main/database"
    click Redis "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Infrastructure/Redis"
    click AWS_S3_Abs "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Application/Abstractions/Cloud"
    click AWS_S3_Inf "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Infrastructure/Cloud"
    click GoogleOAuth_Abs "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Application/Abstractions/Google"
    click GoogleOAuth_Inf "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Infrastructure/Google"
    click VNPay_Abs "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Application/Abstractions/Payment"
    click VNPay_Inf "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Infrastructure/VNPay"
    click GHN_Abs "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Application/Abstractions/Delivery"
    click GHN_Inf "https://github.com/andyninety9/skincareproductssalessystem/tree/main/src/backend/WebService/src/Infrastructure/Delivery"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef cache fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef ext fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
