# leminhtriet3105206-dev/haihand-marketplace architecture

> Architecture diagram of the GitHub repository leminhtriet3105206-dev/haihand-marketplace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leminhtriet3105206-dev/haihand-marketplace
- Repository: https://github.com/leminhtriet3105206-dev/haihand-marketplace

## Overview

HaiHand is a second-hand goods marketplace with a React client, a Node backend, and a separate Express admin application. The user journey spans account access, browsing and listing products, buyer–seller communication, orders and payments, and post-transaction reviews; administrators also manage listings, users, and categories. The source index identifies the backend server as substantial, but its routes were not excerpted, so backend internals and several client-to-server links remain intentionally coarse. Admin model and route relationships are shown where the excerpts provide evidence.

Main entry points: [`frontend/src/App.js`](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/App.js) (Route application), [`frontend/src/components/Header.js`](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/components/Header.js) (Navigation and alerts), [`backend/server.js`](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/server.js) (Marketplace API), [`admin/app.js`](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/app.js) (Admin routes and views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Marketplace client"]
  node_app["Route application<br/>[App.js]"]
  node_accounts["Accounts<br/>[LoginPage.js]"]
  node_catalog["Browse catalog<br/>[ProductListPage.js]"]
  node_home["Home discovery<br/>[HomePage.js]"]
  node_listing["Create listings<br/>[CreatePostPage.js]"]
  node_product["Product details"]
  node_profile["Profiles and reviews<br/>[ProfilePage.js]"]
  node_cart["Cart and orders<br/>[CartPage.js]"]
  node_payments["Payments<br/>[HaiPayPage.js]"]
  node_messaging["Buyer-seller chat<br/>[ChatPage.js]"]
  node_social["Favorites and follows<br/>[FavoritesPage.js]"]
  node_header["Navigation and alerts<br/>[Header.js]"]
  node_admin_chat["Admin chat widget"]
end

subgraph group_api["Marketplace backend"]
  node_backend["Marketplace API<br/>[server.js]"]
  node_product_model["Product model<br/>[Product.js]"]
  node_user_model["User model<br/>[User.js]"]
  node_message_model["Message model<br/>[Message.js]"]
end

subgraph group_admin["Admin console"]
  node_admin_app["Admin routes and views<br/>[app.js]"]
end

subgraph group_admin_data["Admin data"]
  node_admin_posts["Admin post model<br/>[Post.js]"]
  node_admin_users["Admin user model<br/>[User.js]"]
  node_admin_categories["Category model<br/>[Category.js]"]
end

node_user(("Marketplace user"))
node_mongo[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_accounts
node_app -->|"routes to"| node_listing
node_app -->|"routes to"| node_product
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_payments
node_app -->|"routes to"| node_messaging
node_app -->|"routes to"| node_social
node_app -->|"renders"| node_admin_chat
node_home -->|"renders"| node_header
node_catalog -->|"renders"| node_header
node_listing -->|"renders"| node_header
node_product -->|"renders"| node_header
node_profile -->|"renders"| node_header
node_cart -->|"renders"| node_header
node_messaging -->|"renders"| node_header
node_header -->|"requests categories"| node_backend
node_messaging -->|"loads conversations"| node_backend
node_profile -->|"loads orders and reviews"| node_backend
node_product -->|"loads product and reviews"| node_backend
node_backend -.-> node_product_model
node_backend -.-> node_user_model
node_backend -.-> node_message_model
node_admin_app -->|"queries and updates"| node_admin_posts
node_admin_app -->|"queries and updates"| node_admin_users
node_admin_app -->|"queries and updates"| node_admin_categories
node_admin_app -->|"connects"| node_mongo
node_admin_app -.->|"renders post administration"| node_admin_posts

click node_app "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/App.js"
click node_accounts "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/LoginPage.js"
click node_catalog "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProductListPage.js"
click node_home "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/HomePage.js"
click node_listing "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/CreatePostPage.js"
click node_product "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProductDetailPage.js"
click node_profile "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProfilePage.js"
click node_cart "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/CartPage.js"
click node_payments "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/HaiPayPage.js"
click node_messaging "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ChatPage.js"
click node_social "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/FavoritesPage.js"
click node_header "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/components/Header.js"
click node_admin_chat "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/components/FloatingAdminChat.js"
click node_backend "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/server.js"
click node_product_model "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/Product.js"
click node_user_model "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/User.js"
click node_message_model "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/Message.js"
click node_admin_app "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/app.js"
click node_admin_posts "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/Post.js"
click node_admin_users "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/User.js"
click node_admin_categories "https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/Category.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_accounts,node_catalog,node_home,node_listing,node_product,node_profile,node_cart,node_payments,node_messaging,node_social,node_header,node_admin_chat,node_user toneBlue
class node_backend,node_product_model,node_user_model,node_message_model,node_mongo toneAmber
class node_admin_app toneMint
class node_admin_posts,node_admin_users,node_admin_categories toneRose
```

## Components

### Marketplace client

- [Route application](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Accounts](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/LoginPage.js): `frontend/src/pages/LoginPage.js`
- [Browse catalog](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProductListPage.js): `frontend/src/pages/ProductListPage.js`
- [Home discovery](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/HomePage.js): `frontend/src/pages/HomePage.js`
- [Create listings](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/CreatePostPage.js): `frontend/src/pages/CreatePostPage.js`
- [Product details](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProductDetailPage.js): `frontend/src/pages/ProductDetailPage.js`
- [Profiles and reviews](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ProfilePage.js): `frontend/src/pages/ProfilePage.js`
- [Cart and orders](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/CartPage.js): `frontend/src/pages/CartPage.js`
- [Payments](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/HaiPayPage.js): `frontend/src/pages/HaiPayPage.js`
- [Buyer-seller chat](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/ChatPage.js): `frontend/src/pages/ChatPage.js`
- [Favorites and follows](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/pages/FavoritesPage.js): `frontend/src/pages/FavoritesPage.js`
- [Navigation and alerts](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/components/Header.js): `frontend/src/components/Header.js`
- [Admin chat widget](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/frontend/src/components/FloatingAdminChat.js): `frontend/src/components/FloatingAdminChat.js`

### Marketplace backend

- [Marketplace API](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/server.js): `backend/server.js`
- [Product model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/Product.js): `backend/models/Product.js`
- [User model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/User.js): `backend/models/User.js`
- [Message model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/backend/models/Message.js): `backend/models/Message.js`

### Admin console

- [Admin routes and views](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/app.js): `admin/app.js`

### Admin data

- [Admin post model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/Post.js): `admin/models/Post.js`
- [Admin user model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/User.js): `admin/models/User.js`
- [Category model](https://github.com/leminhtriet3105206-dev/haihand-marketplace/blob/main/admin/models/Category.js): `admin/models/Category.js`

### Other components

- **Marketplace user**
- **MongoDB**

## Connections

- Marketplace user → Route application: uses (evidence: `frontend/src/App.js`)
- Route application → Home discovery: routes to (evidence: `frontend/src/App.js`)
- Route application → Accounts: routes to (evidence: `frontend/src/App.js`)
- Route application → Create listings: routes to (evidence: `frontend/src/App.js`)
- Route application → Product details: routes to (evidence: `frontend/src/App.js`)
- Route application → Profiles and reviews: routes to (evidence: `frontend/src/App.js`)
- Route application → Cart and orders: routes to (evidence: `frontend/src/App.js`)
- Route application → Payments: routes to (evidence: `frontend/src/App.js`)
- Route application → Buyer-seller chat: routes to (evidence: `frontend/src/App.js`)
- Route application → Favorites and follows: routes to (evidence: `frontend/src/App.js`)
- Route application → Admin chat widget: renders (evidence: `frontend/src/App.js`)
- Home discovery → Navigation and alerts: renders (evidence: `frontend/src/pages/HomePage.js`)
- Browse catalog → Navigation and alerts: renders (evidence: `frontend/src/pages/ProductListPage.js`)
- Create listings → Navigation and alerts: renders (evidence: `frontend/src/pages/CreatePostPage.js`)
- Product details → Navigation and alerts: renders (evidence: `frontend/src/pages/ProductDetailPage.js`)
- Profiles and reviews → Navigation and alerts: renders (evidence: `frontend/src/pages/ProfilePage.js`)
- Cart and orders → Navigation and alerts: renders (evidence: `frontend/src/pages/CartPage.js`)
- Buyer-seller chat → Navigation and alerts: renders (evidence: `frontend/src/pages/ChatPage.js`)
- Navigation and alerts → Marketplace API: requests categories (evidence: `frontend/src/components/Header.js`)
- Buyer-seller chat → Marketplace API: loads conversations (evidence: `frontend/src/pages/ChatPage.js`)
- Profiles and reviews → Marketplace API: loads orders and reviews (evidence: `frontend/src/pages/ProfilePage.js`)
- Product details → Marketplace API: loads product and reviews (evidence: `frontend/src/pages/ProductDetailPage.js`)
- Marketplace API → Product model
- Marketplace API → User model
- Marketplace API → Message model
- Admin routes and views → Admin post model: queries and updates (evidence: `admin/app.js`)
- Admin routes and views → Admin user model: queries and updates (evidence: `admin/app.js`)
- Admin routes and views → Category model: queries and updates (evidence: `admin/app.js`)
- Admin routes and views → MongoDB: connects (evidence: `admin/app.js`)
- Admin routes and views → Admin post model: renders post administration (evidence: `admin/app.js`)
