# tboi0602/sos architecture

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

- Interactive diagram: https://gitdiagram.com/tboi0602/sos
- Repository: https://github.com/tboi0602/sos

## Overview

SOS · Tinh Hoa Việt là nền tảng cộng đồng gồm website Next.js, API Express và PostgreSQL. Thành viên đăng ký hoặc đăng nhập, tham gia cộng đồng qua hồ sơ, bài viết và hoạt động, học tập và hoàn tất quy trình thành viên; quản trị viên quản lý nội dung, người dùng và luồng duyệt. README cũng nêu bảng xếp hạng, thông báo, chat tư vấn, email, Google login và SSO. Các nhánh tính năng chưa có trích đoạn triển khai được giữ ở mức thư mục; sơ đồ không suy diễn cách chúng được nối nội bộ.

Main entry points: [`TTL-Website/src/app`](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app) (Website Next.js), [`TTL-Website/src/service`](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/service) (Dịch vụ web), [`TTL-Server/src/db/index.ts`](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/db/index.ts) (PostgreSQL), [`TTL-Server/src/services/authService.ts`](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/authService.ts) (Dịch vụ xác thực)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Website cộng đồng"]
  node_website["Website Next.js"]
  node_auth_ui["Đăng nhập và tài khoản"]
  node_community_ui["Cộng đồng và hồ sơ"]
  node_admin_ui["Giao diện quản trị"]
  node_web_services["Dịch vụ web"]
  node_api_client["HTTP client<br/>[client.ts]"]
end

subgraph group_api["API và dịch vụ"]
  node_api_entry["API Express<br/>[index.ts]"]
  node_routers["Router phiên bản 1"]
  node_controllers["Bộ điều khiển"]
  node_auth_service["Dịch vụ xác thực<br/>[authService.ts]"]
  node_post_controller["Bài viết controller<br/>[postController.ts]"]
  node_post_service["Dịch vụ bài viết<br/>[postService.ts]"]
  node_membership_flow["Luồng thành viên<br/>[flowService.ts]"]
  node_admin_membership["Quản trị thành viên"]
  node_admin_users["Quản lý người dùng"]
  node_chat["Trợ lý chat<br/>[chatController.ts]"]
end

subgraph group_domains["Cộng đồng và học tập"]
  node_membership_ui["Học và gia nhập"]
  node_learning["Bài học trực tuyến"]
  node_activity["Nhật ký và tác phẩm"]
  node_rank_profile["Hồ sơ và xếp hạng"]
end

subgraph group_state["Lưu trữ và tích hợp"]
  node_database[("PostgreSQL<br/>[index.ts]")]
  node_email["Dịch vụ email<br/>[mail.ts]"]
  node_google["Google Gemini"]
  node_oidc["Nhà cung cấp TBV SSO<br/>[oidcService.ts]"]
  node_uploads[("Tệp tải lên<br/>[index.ts]")]
end

node_member(("Thành viên"))
node_admin(("Quản trị viên"))

node_member -->|"truy cập"| node_website
node_admin -->|"truy cập"| node_website
node_website -->|"dùng tài khoản"| node_auth_ui
node_website -->|"dùng cộng đồng"| node_community_ui
node_website -->|"dùng học tập"| node_membership_ui
node_website -->|"quản trị"| node_admin_ui
node_auth_ui -->|"gọi dịch vụ"| node_web_services
node_community_ui -->|"gọi dịch vụ"| node_web_services
node_admin_ui -->|"gọi dịch vụ"| node_web_services
node_membership_ui -->|"gọi dịch vụ"| node_web_services
node_web_services -->|"gửi yêu cầu"| node_api_client
node_api_client -->|"HTTP API"| node_api_entry
node_api_entry -->|"đăng ký tuyến"| node_routers
node_routers -->|"định tuyến"| node_controllers
node_controllers -->|"xử lý xác thực"| node_auth_service
node_post_controller -->|"gọi nghiệp vụ"| node_post_service
node_auth_service -->|"đọc và ghi"| node_database
node_auth_service -->|"gửi kích hoạt"| node_email
node_post_service -->|"đọc và ghi"| node_database
node_admin_membership -->|"gọi luồng"| node_membership_flow
node_membership_flow -->|"đọc và ghi"| node_database
node_membership_flow -->|"đọc nội dung học"| node_learning
node_admin_users -->|"đọc và ghi"| node_database
node_activity -->|"lưu hoạt động"| node_database
node_rank_profile -->|"lấy dữ liệu"| node_web_services
node_api_entry -->|"phục vụ tệp"| node_uploads
node_chat -.->|"gọi mô hình"| node_google
node_auth_service -.->|"xác thực SSO"| node_oidc

click node_website "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app"
click node_auth_ui "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/hook/auth"
click node_community_ui "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home"
click node_admin_ui "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/admin"
click node_web_services "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/service"
click node_api_client "https://github.com/tboi0602/sos/blob/main/TTL-Website/src/service/client.ts"
click node_api_entry "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/index.ts"
click node_routers "https://github.com/tboi0602/sos/tree/main/TTL-Server/src/router/v1"
click node_controllers "https://github.com/tboi0602/sos/tree/main/TTL-Server/src/controllers"
click node_auth_service "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/authService.ts"
click node_post_controller "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/postController.ts"
click node_post_service "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/postService.ts"
click node_membership_flow "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/membership/flowService.ts"
click node_admin_membership "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/adminMembershipController.ts"
click node_membership_ui "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home/membership"
click node_learning "https://github.com/tboi0602/sos/tree/main/TTL-Server/src/services/membership"
click node_activity "https://github.com/tboi0602/sos/tree/main/TTL-Server/src/services"
click node_rank_profile "https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home/profile"
click node_admin_users "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/admin/adminUserService.ts"
click node_chat "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/chatController.ts"
click node_database "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/db/index.ts"
click node_email "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/mail.ts"
click node_oidc "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/oidcService.ts"
click node_uploads "https://github.com/tboi0602/sos/blob/main/TTL-Server/src/index.ts"

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_website,node_auth_ui,node_community_ui,node_admin_ui,node_web_services,node_api_client toneBlue
class node_api_entry,node_routers,node_controllers,node_auth_service,node_post_controller,node_post_service,node_membership_flow,node_admin_membership,node_admin_users,node_chat toneAmber
class node_membership_ui,node_learning,node_activity,node_rank_profile toneMint
class node_database,node_email,node_google,node_oidc,node_uploads toneRose
class node_member,node_admin toneIndigo
```

## Components

### Website cộng đồng

- [Website Next.js](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app): `TTL-Website/src/app`
- [Đăng nhập và tài khoản](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/hook/auth): `TTL-Website/src/hook/auth`
- [Cộng đồng và hồ sơ](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home): `TTL-Website/src/app/home`
- [Giao diện quản trị](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/admin): `TTL-Website/src/app/admin`
- [Dịch vụ web](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/service): `TTL-Website/src/service`
- [HTTP client](https://github.com/tboi0602/sos/blob/main/TTL-Website/src/service/client.ts): `TTL-Website/src/service/client.ts`

### API và dịch vụ

- [API Express](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/index.ts): `TTL-Server/src/index.ts`
- [Router phiên bản 1](https://github.com/tboi0602/sos/tree/main/TTL-Server/src/router/v1): `TTL-Server/src/router/v1`
- [Bộ điều khiển](https://github.com/tboi0602/sos/tree/main/TTL-Server/src/controllers): `TTL-Server/src/controllers`
- [Dịch vụ xác thực](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/authService.ts): `TTL-Server/src/services/authService.ts`
- [Bài viết controller](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/postController.ts): `TTL-Server/src/controllers/postController.ts`
- [Dịch vụ bài viết](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/postService.ts): `TTL-Server/src/services/postService.ts`
- [Luồng thành viên](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/membership/flowService.ts): `TTL-Server/src/services/membership/flowService.ts`
- [Quản trị thành viên](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/adminMembershipController.ts): `TTL-Server/src/controllers/adminMembershipController.ts`
- [Quản lý người dùng](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/admin/adminUserService.ts): `TTL-Server/src/services/admin/adminUserService.ts`
- [Trợ lý chat](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/controllers/chatController.ts): `TTL-Server/src/controllers/chatController.ts`

### Cộng đồng và học tập

- [Học và gia nhập](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home/membership): `TTL-Website/src/app/home/membership`
- [Bài học trực tuyến](https://github.com/tboi0602/sos/tree/main/TTL-Server/src/services/membership): `TTL-Server/src/services/membership`
- [Nhật ký và tác phẩm](https://github.com/tboi0602/sos/tree/main/TTL-Server/src/services): `TTL-Server/src/services`
- [Hồ sơ và xếp hạng](https://github.com/tboi0602/sos/tree/main/TTL-Website/src/app/home/profile): `TTL-Website/src/app/home/profile`

### Lưu trữ và tích hợp

- [PostgreSQL](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/db/index.ts): `TTL-Server/src/db/index.ts`
- [Dịch vụ email](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/mail.ts): `TTL-Server/src/services/mail.ts`
- **Google Gemini**
- [Nhà cung cấp TBV SSO](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/services/oidcService.ts): `TTL-Server/src/services/oidcService.ts`
- [Tệp tải lên](https://github.com/tboi0602/sos/blob/main/TTL-Server/src/index.ts): `TTL-Server/src/index.ts`

### Other components

- **Thành viên**
- **Quản trị viên**

## Connections

- Thành viên → Website Next.js: truy cập
- Quản trị viên → Website Next.js: truy cập
- Website Next.js → Đăng nhập và tài khoản: dùng tài khoản
- Website Next.js → Cộng đồng và hồ sơ: dùng cộng đồng
- Website Next.js → Học và gia nhập: dùng học tập
- Website Next.js → Giao diện quản trị: quản trị
- Đăng nhập và tài khoản → Dịch vụ web: gọi dịch vụ
- Cộng đồng và hồ sơ → Dịch vụ web: gọi dịch vụ
- Giao diện quản trị → Dịch vụ web: gọi dịch vụ
- Học và gia nhập → Dịch vụ web: gọi dịch vụ
- Dịch vụ web → HTTP client: gửi yêu cầu
- HTTP client → API Express: HTTP API
- API Express → Router phiên bản 1: đăng ký tuyến
- Router phiên bản 1 → Bộ điều khiển: định tuyến
- Bộ điều khiển → Dịch vụ xác thực: xử lý xác thực
- Bài viết controller → Dịch vụ bài viết: gọi nghiệp vụ
- Dịch vụ xác thực → PostgreSQL: đọc và ghi
- Dịch vụ xác thực → Dịch vụ email: gửi kích hoạt
- Dịch vụ bài viết → PostgreSQL: đọc và ghi
- Quản trị thành viên → Luồng thành viên: gọi luồng
- Luồng thành viên → PostgreSQL: đọc và ghi
- Luồng thành viên → Bài học trực tuyến: đọc nội dung học
- Quản lý người dùng → PostgreSQL: đọc và ghi
- Nhật ký và tác phẩm → PostgreSQL: lưu hoạt động
- Hồ sơ và xếp hạng → Dịch vụ web: lấy dữ liệu
- API Express → Tệp tải lên: phục vụ tệp
- Trợ lý chat → Google Gemini: gọi mô hình
- Dịch vụ xác thực → Nhà cung cấp TBV SSO: xác thực SSO
