# hauqianq/be_swp391_goodsexchange architecture

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

- Interactive diagram: https://gitdiagram.com/hauqianq/be_swp391_goodsexchange
- Repository: https://github.com/hauqianq/be_swp391_goodsexchange

## Overview

GoodsExchange is a .NET backend for university students to list school supplies and exchange them. The main workflow is to browse or manage product listings, submit an exchange request, and progress the request through participant decisions; the exchange service also updates product status and sends an email. The API exposes additional account, category, rating, report, role, and transaction capabilities. The README names SQL Server and the source shows the EF Core context. Some service wiring and unsampled controller behavior are not shown, so those relationships are omitted.

Main entry points: [`GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs) (Exchange workflow), [`GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs`](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs) (Product services), [`GoodsExchange.Data/Context/GoodsExchangeDbContext.cs`](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Context/GoodsExchangeDbContext.cs) (EF Core context), [`GoodsExchange.API/Controllers/UserController.cs`](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/UserController.cs) (User endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api_entry["API endpoints<br/>[Controllers]"]
  node_user_api["User endpoints<br/>[UserController.cs]"]
  node_product_api["Product endpoints"]
  node_exchange_api["Exchange endpoints"]
  node_other_api["Other endpoints<br/>[Controllers]"]
end

subgraph group_market["Listings and exchange"]
  node_product_svc["Product services<br/>[ProductService.cs]"]
  node_exchange_svc["Exchange workflow"]
  node_product_model["Product listings<br/>[Product.cs]"]
  node_exchange_model["Exchange requests<br/>[ExchangeRequest.cs]"]
  node_category_model["Categories<br/>[Category.cs]"]
end

subgraph group_accounts["Accounts and services"]
  node_accounts_svc["Account services<br/>[UserService.cs]"]
  node_other_services["Supporting services<br/>[Implementation]"]
  node_email_svc["Email delivery<br/>[EmailService.cs]"]
  node_firebase_svc["Image storage"]
  node_user_model["User accounts<br/>[User.cs]"]
end

subgraph group_persistence["Data persistence"]
  node_db_context["EF Core context"]
  node_sql_server[("SQL Server")]
end

node_students(("Students"))

node_students -->|"browse listings"| node_product_api
node_students -->|"manage account"| node_user_api
node_students -->|"request exchange"| node_exchange_api
node_user_api -->|"calls services"| node_accounts_svc
node_product_api -->|"calls services"| node_product_svc
node_exchange_api -->|"calls services"| node_exchange_svc
node_product_svc -->|"reads and writes"| node_db_context
node_exchange_svc -->|"reads and writes"| node_db_context
node_exchange_svc -->|"gets participants"| node_accounts_svc
node_exchange_svc -->|"updates status"| node_product_svc
node_exchange_svc -->|"sends request email"| node_email_svc
node_db_context -->|"persists data"| node_sql_server

click node_api_entry "https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.API/Controllers"
click node_user_api "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/UserController.cs"
click node_product_api "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/ProductController.cs"
click node_exchange_api "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/ExchangeController.cs"
click node_other_api "https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.API/Controllers"
click node_accounts_svc "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/UserService.cs"
click node_product_svc "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs"
click node_exchange_svc "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs"
click node_other_services "https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.BusinessLogic/Services/Implementation"
click node_email_svc "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/EmailService.cs"
click node_firebase_svc "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/FirebaseStorageService.cs"
click node_product_model "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/Product.cs"
click node_exchange_model "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/ExchangeRequest.cs"
click node_user_model "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/User.cs"
click node_category_model "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/Category.cs"
click node_db_context "https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Context/GoodsExchangeDbContext.cs"

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_api_entry,node_user_api,node_product_api,node_exchange_api,node_other_api toneBlue
class node_product_svc,node_exchange_svc,node_product_model,node_exchange_model,node_category_model toneAmber
class node_accounts_svc,node_other_services,node_email_svc,node_firebase_svc,node_user_model toneMint
class node_db_context,node_sql_server toneRose
class node_students toneIndigo
```

## Components

### HTTP API

- [API endpoints](https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.API/Controllers): `GoodsExchange.API/Controllers`
- [User endpoints](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/UserController.cs): `GoodsExchange.API/Controllers/UserController.cs`
- [Product endpoints](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/ProductController.cs): `GoodsExchange.API/Controllers/ProductController.cs`
- [Exchange endpoints](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.API/Controllers/ExchangeController.cs): `GoodsExchange.API/Controllers/ExchangeController.cs`
- [Other endpoints](https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.API/Controllers): `GoodsExchange.API/Controllers`

### Listings and exchange

- [Product services](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs): `GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs`
- [Exchange workflow](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs): `GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`
- [Product listings](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/Product.cs): `GoodsExchange.Data/Models/Product.cs`
- [Exchange requests](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/ExchangeRequest.cs): `GoodsExchange.Data/Models/ExchangeRequest.cs`
- [Categories](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/Category.cs): `GoodsExchange.Data/Models/Category.cs`

### Accounts and services

- [Account services](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/UserService.cs): `GoodsExchange.BusinessLogic/Services/Implementation/UserService.cs`
- [Supporting services](https://github.com/hauqianq/be_swp391_goodsexchange/tree/dev/GoodsExchange.BusinessLogic/Services/Implementation): `GoodsExchange.BusinessLogic/Services/Implementation`
- [Email delivery](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/EmailService.cs): `GoodsExchange.BusinessLogic/Services/Implementation/EmailService.cs`
- [Image storage](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.BusinessLogic/Services/Implementation/FirebaseStorageService.cs): `GoodsExchange.BusinessLogic/Services/Implementation/FirebaseStorageService.cs`
- [User accounts](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Models/User.cs): `GoodsExchange.Data/Models/User.cs`

### Data persistence

- [EF Core context](https://github.com/hauqianq/be_swp391_goodsexchange/blob/dev/GoodsExchange.Data/Context/GoodsExchangeDbContext.cs): `GoodsExchange.Data/Context/GoodsExchangeDbContext.cs`
- **SQL Server**

### Other components

- **Students**

## Connections

- Students → Product endpoints: browse listings (evidence: `GoodsExchange.API/Controllers/ProductController.cs`)
- Students → User endpoints: manage account (evidence: `GoodsExchange.API/Controllers/UserController.cs`)
- Students → Exchange endpoints: request exchange (evidence: `GoodsExchange.API/Controllers/ExchangeController.cs`)
- User endpoints → Account services: calls services (evidence: `GoodsExchange.API/Controllers/UserController.cs`)
- Product endpoints → Product services: calls services (evidence: `GoodsExchange.API/Controllers/ProductController.cs`)
- Exchange endpoints → Exchange workflow: calls services (evidence: `GoodsExchange.API/Controllers/ExchangeController.cs`)
- Product services → EF Core context: reads and writes (evidence: `GoodsExchange.BusinessLogic/Services/Implementation/ProductService.cs`)
- Exchange workflow → EF Core context: reads and writes (evidence: `GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`)
- Exchange workflow → Account services: gets participants (evidence: `GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`)
- Exchange workflow → Product services: updates status (evidence: `GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`)
- Exchange workflow → Email delivery: sends request email (evidence: `GoodsExchange.BusinessLogic/Services/Implementation/ExchangeRequestService.cs`)
- EF Core context → SQL Server: persists data (evidence: `GoodsExchange.Data/Context/GoodsExchangeDbContext.cs`)
