# annguyenbinh03/fufleamarket architecture

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

- Interactive diagram: https://gitdiagram.com/annguyenbinh03/fufleamarket
- Repository: https://github.com/annguyenbinh03/fufleamarket

## Overview

Based on our analysis, this project is a full‐stack application with multiple front‐end clients (a mobile app built with React Native/Expo found under the “mobile” directory and a web app in the “react” directory) and a robust backend built in .NET (see the “TestFUFM” folder with its layered structure including Business Objects, DTOs, Repositories, Services, and a WebAPI). There is also a set of static HTML/CSS pages that seem to serve a legacy or administrative front end.

##### Client Applications
a. Web Client
- Located under “react”
- Uses React and related libraries for UI and API integration
b. Mobile Client
- Located under “mobile”
- Built on React Native / Expo
- Uses APIs to connect with backend services
c. Static HTML/CSS pages
- Found in “HTML CSS”
- Likely serve static views or legacy admin pages

##### Backend API (WebAPI)
- Found under “TestFUFM/WebAPI” – handles HTTP requests
- Controllers such as CategoryController, OrderController, ProductController, etc.
- Exposes REST endpoints for the clients
- Contains integration code, e.g., VNPay for payment processing

##### Business/Application Logic Layers
a. Business Objects
- Contains domain models and context (e.g., FufleaMarketContext)
- Located in “TestFUFM/BusinessObjects”
b. Data Transfer Objects (DTOs)
- Acts as contracts between backend layers; located in “TestFUFM/DTO”
c. Repository Layer
- Abstracts database access; located in “TestFUFM/Repository”
- Contains interfaces and concrete repository classes
d. Service Layer
- Contains business rules and workflow logic
- Includes background services (e.g., PromotionPackagesService, StatusOrderService) and various domain-specific services
- Found in “TestFUFM/Service” with several functional areas (order totals, product totals, etc.)

##### Data Persistence
- While not explicitly a “database” folder, the presence of contexts (e.g., FufleaMarketContext) and SQL scripts in the “document” folder (FUFM.sql, DeleteAllTableAzure.sql) indicate a relational database (likely MS SQL) that stores data model entities.

##### External Integrations & Utilities
- VNPay integration found in “TestFUFM/BusinessObjects/VNPay” and in the WebAPI controllers
- Configuration files (e.g., appsettings.json) governing environment-specific settings

##### Architectural Patterns and Design Principles
- Layered architecture separating concerns (Controllers → Business Logic/Services → Repositories → Database)
- The use of DTOs and Mappers to decouple internal models from external representations
- Modular separation permitting individual testing and maintenance of mobile, web, and backend components

– Group the “Web Client (React)” and “Mobile Client (React Native/Expo)” with a note that they are separate front-end interfaces communicating via HTTP/HTTPS.
– Optionally, include the “Static HTML/CSS” component as a legacy/admin interface if applicable.

– Represent the WebAPI as the primary entry point for client requests.

- In the center or next to the WebAPI, show the Application Layers:

- A database component:
– Represent the relational database (MS SQL or similar) and indicate that it stores models represented in BusinessObjects (e.g., Product, Order, User).

- External services:
– Optionally, note any other external APIs if mentioned in documentation or inferred (e.g., authentication through Google SignIn as seen in the DTO and controller names).

- For design clarity, use:
– Clear labels for each component with concise descriptions

- Tailoring to the Project’s Purpose:
– Given the project might be an “OnDemandTuroring” platform (as per the README) but seems to have evolved with market-like functionalities (products, orders, promotions), clearly label components that support user interactions (ordering, chatting, product listings) along with admin functions.
– Highlight the micro-level detail in the backend (e.g., separate controllers for Contacts, Orders, Trading Orders, etc.) to indicate a modular design where each domain function is isolated.

- Final Touches:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Applications"
        WebClient["Web Client (React)"]:::client
        MobileClient["Mobile Client (React Native/Expo)"]:::client
        StaticHTML["Static HTML/CSS Pages"]:::client
    end

    %% Backend API
    subgraph "Backend API"
        APIControllers["API Controllers (.NET)"]:::backend
        APIProgram["Program.cs & Startup"]:::backend
    end

    %% Business/Application Logic Layers
    subgraph "Business/Application Logic"
        BusinessObjects["Business Objects (Domain Models)"]:::business
        DTOs["Data Transfer Objects (DTOs)"]:::business
        Repository["Repository Layer"]:::business
        ServiceLayer["Service Layer"]:::business
    end

    %% External Integrations & Utilities
    subgraph "External Integrations & Utilities"
        VNPay["VNPay Integration"]:::external
        Config["Configuration Files"]:::external
    end

    %% Data Persistence
    Database[(MS SQL Database)]:::db

    %% Relationships between components
    WebClient -->|"HTTP/HTTPS"| APIControllers
    MobileClient -->|"HTTP/HTTPS"| APIControllers
    StaticHTML -->|"HTTP/HTTPS"| APIControllers

    APIProgram -->|"initializes"| APIControllers
    APIControllers -->|"calls"| ServiceLayer
    APIControllers -->|"integrates"| VNPay
    APIControllers -->|"reads"| Config

    ServiceLayer -->|"invokes"| Repository
    ServiceLayer -->|"mapsData"| DTOs
    ServiceLayer -->|"uses"| VNPay

    Repository -->|"accesses"| Database
    Repository -->|"uses"| BusinessObjects

    %% Click Events
    click WebClient "https://github.com/annguyenbinh03/fufleamarket/tree/main/react/src"
    click MobileClient "https://github.com/annguyenbinh03/fufleamarket/tree/main/mobile/app"
    click StaticHTML "https://github.com/annguyenbinh03/fufleamarket/blob/main/HTML CSS/index.html"
    click APIControllers "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/WebAPI/Controllers"
    click APIProgram "https://github.com/annguyenbinh03/fufleamarket/blob/main/TestFUFM/WebAPI/Program.cs"
    click BusinessObjects "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/BusinessObjects"
    click DTOs "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/DTO"
    click Repository "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/Repository"
    click ServiceLayer "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/Service"
    click VNPay "https://github.com/annguyenbinh03/fufleamarket/tree/main/TestFUFM/BusinessObjects/VNPay"
    click Config "https://github.com/annguyenbinh03/fufleamarket/blob/main/TestFUFM/WebAPI/appsettings.json"
    click Database "https://github.com/annguyenbinh03/fufleamarket/blob/main/document/FUFM.sql"

    %% Styling
    classDef client fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef business fill:#fffacd,stroke:#000,stroke-width:2px;
    classDef db fill:#ffa07a,stroke:#000,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#ffb6c1,stroke:#000,stroke-width:2px;
```
