# letrungviet2005/vietnamjourney-fe architecture

> Architecture diagram of the GitHub repository letrungviet2005/vietnamjourney-fe, 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/letrungviet2005/vietnamjourney-fe
- Repository: https://github.com/letrungviet2005/vietnamjourney-fe

## Overview

##### Main Components
- Frontend Client:
- Built using React (the Create React App framework is used, as seen in “src” and “public”).
- Contains multiple pages (e.g., “ChienDich” for campaigns, “CongDong” for community posts, “Messenger” for chat, “TrangChu” for the home page, etc.), images, videos, and other static assets.
- Likely uses React Router for navigation among pages.
- Backend Server:
- Implemented in PHP, organized under the “Server” directory.
- Submodules include “ChienDich” (managing campaigns), “CongDong” (community posts), “TaiKhoan” (account related actions), and “User” (user interactions like comments, likes, and posting).
- Includes endpoints for CRUD operations on campaigns, posts, and user accounts.
- Contains common utility files such as “db_connect.php” suggesting a database integration.
- Database (Assumed):
- Although not explicitly shown in the file tree, the existence of “db_connect.php” implies there is a relational database (likely MySQL) on the backend to store and retrieve data supporting the functionalities.

##### Relationships and Interactions
- The Client (React front-end) communicates with the PHP backend by making HTTP/REST API calls to the various PHP endpoints.
- Each module in the “Server” (i.e., ChienDich, CongDong, TaiKhoan, User) provides specific functionalities. For example:
- Campaign-related pages in the frontend will send requests to PHP files like “CreateCampaign.php”, “UpdateCampaign.php”, “GetCampaign.php”, etc.
- User-related actions (comments, likes, following) on the client will interact with the corresponding PHP endpoint handlers.
- The backend interactions include data fetching, processing, and returning JSON responses (as seen from “text.json” and the PHP scripts’ naming patterns) that the frontend uses to update the UI.
- The database layer (though not shown in detail) sits behind the PHP modules and handles persistent storage for campaigns, users, comments, and other data.

##### Architectural Patterns and Design Principles
- Modularity & Separation of Concerns:
- The backend is organized by business domains (campaigns, community posts, user accounts), which makes it easier to manage and scale individual functionalities.
- The frontend is component-based (organized in “src/component”, “src/pages”) letting you apply separation between views, navigation (Navbar, Footer), and utilities (Cookies, ScrollToTop).
- API-driven Communication:
- Asset Management:
- The “public” folder holds static files (HTML, manifest, robots.txt, sample JSON for units, etc.) that are served by the client application.

##### Design Elements
- React <--> PHP endpoints (HTTP requests/responses)
- PHP endpoints <--> Database (data read/write operations)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Client (React)
    subgraph "Frontend Client (React)"
        direction TB
        FE_PCC["Pages & Components (src)"]:::frontend
        FE_ASSETS["Static Assets (public)"]:::frontend
        FE_CAM["Campaign Pages (src/pages/ChienDich)"]:::frontend
        FE_COM["Community Page (src/pages/CongDong)"]:::frontend
        FE_ACC["Account Pages (src/pages/TaiKhoan)"]:::frontend
        FE_ACC2["Account Test (src/pages/TaiKhoanTest)"]:::frontend
        FE_USR["User Interaction Pages (src/pages/User)"]:::frontend
    end

    %% Backend Server (PHP)
    subgraph "Backend Server (PHP)"
        direction TB
        BE_CAM["Campaign Module (ChienDich)"]:::backend
        BE_COM["Community Module (CongDong)"]:::backend
        BE_ACC["Account Management (TaiKhoan)"]:::backend
        BE_USR["User Interactions Module (User)"]:::backend
        BE_DB["DB Connection (db_connect.php)"]:::backend
        BE_UTIL["Image Upload Utility (insert_anh.php)"]:::backend
    end

    %% Database Layer
    Database["Database"]:::database

    %% Frontend to Backend HTTP interactions
    FE_CAM -->|"HTTP"| BE_CAM
    FE_COM -->|"HTTP"| BE_COM
    FE_ACC -->|"HTTP"| BE_ACC
    FE_ACC2 -->|"HTTP"| BE_ACC
    FE_USR -->|"HTTP"| BE_USR

    %% Backend modules interacting with Database
    BE_CAM -->|"CRUD"| Database
    BE_COM -->|"CRUD"| Database
    BE_ACC -->|"CRUD"| Database
    BE_USR -->|"CRUD"| Database
    BE_DB -->|"connects"| Database

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;

    %% Click Events
    click FE_PCC "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src"
    click FE_ASSETS "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/public"
    click FE_CAM "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src/pages/ChienDich"
    click FE_COM "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src/pages/CongDong"
    click FE_ACC "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src/pages/TaiKhoan"
    click FE_ACC2 "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src/pages/TaiKhoanTest"
    click FE_USR "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/src/pages/User"
    click BE_CAM "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/Server/ChienDich"
    click BE_COM "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/Server/CongDong"
    click BE_ACC "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/Server/TaiKhoan"
    click BE_USR "https://github.com/letrungviet2005/vietnamjourney-fe/tree/main/Server/User"
    click BE_DB "https://github.com/letrungviet2005/vietnamjourney-fe/blob/main/Server/db_connect.php"
    click BE_UTIL "https://github.com/letrungviet2005/vietnamjourney-fe/blob/main/Server/insert_anh.php"
```
