# phone-myint-arkar/rsu-bgc architecture

> Architecture diagram of the GitHub repository phone-myint-arkar/rsu-bgc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phone-myint-arkar/rsu-bgc
- Repository: https://github.com/phone-myint-arkar/rsu-bgc

## Overview

BoardHub is a board-game lending application: members browse games, request quantities, and track borrowing status; staff manage inventory and requests, while admins manage user roles. The graph follows the documented UI-to-API paths where excerpts show them and the auth/database layer. Several pages and endpoints are indexed but not excerpted, so links for those capabilities rely on index references; uncertain internal calls are omitted.

Main entry points: [`lib/auth.js`](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/auth.js) (Session and permissions), [`lib/db.js`](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/db.js) (MySQL pool), [`app/api/borrowings/route.js`](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/borrowings/route.js) (Borrowings API), [`components/AuthForm.js`](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/AuthForm.js) (Login and registration form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_member["Member experience"]
  node_catalog_ui["Catalog and game cards<br/>[GameCatalog.js]"]
  node_game_detail["Game detail<br/>[page.js]"]
  node_borrow_action["Borrow request action<br/>[BorrowButton.js]"]
  node_auth_ui["Login and registration form<br/>[AuthForm.js]"]
  node_my_borrowings["My borrowings<br/>[page.js]"]
end

subgraph group_staff["Staff operations"]
  node_staff_inventory["Inventory management"]
  node_staff_requests["Request review<br/>[RequestManager.js]"]
  node_admin_users["User role management<br/>[UserManager.js]"]
end

subgraph group_api["Application API"]
  node_games_api["Games API<br/>[route.js]"]
  node_game_item_api["Game item API<br/>[route.js]"]
  node_borrowings_api["Borrowings API<br/>[route.js]"]
  node_borrowing_item_api["Borrowing status API<br/>[route.js]"]
  node_users_api["Users API<br/>[route.js]"]
  node_login_api["Login endpoint<br/>[route.js]"]
  node_register_api["Registration endpoint<br/>[route.js]"]
  node_session_api["Session endpoints<br/>[route.js]"]
end

subgraph group_core["Identity and persistence"]
  node_auth["Session and permissions<br/>[auth.js]"]
  node_rbac["Role permission rules<br/>[rbac.js]"]
  node_database[("MySQL pool<br/>[db.js]")]
end

node_visitor(("Member or visitor"))

node_visitor -->|"browses"| node_catalog_ui
node_catalog_ui -->|"opens game"| node_game_detail
node_game_detail -->|"offers request"| node_borrow_action
node_borrow_action -->|"creates request"| node_borrowings_api
node_visitor -->|"submits credentials"| node_auth_ui
node_auth_ui -->|"posts login"| node_login_api
node_auth_ui -->|"posts registration"| node_register_api
node_my_borrowings -->|"loads requests"| node_borrowings_api
node_staff_inventory -->|"adds game"| node_games_api
node_staff_requests -->|"updates status"| node_borrowing_item_api
node_admin_users -->|"changes role"| node_users_api
node_games_api -->|"checks permission"| node_auth
node_game_item_api -->|"checks permission"| node_auth
node_borrowings_api -->|"checks permission"| node_auth
node_borrowing_item_api -->|"checks permission"| node_auth
node_users_api -->|"checks permission"| node_auth
node_login_api -->|"creates session"| node_auth
node_register_api -->|"creates session"| node_auth
node_session_api -->|"reads session"| node_auth
node_auth -->|"loads current user"| node_database
node_auth -->|"checks role"| node_rbac
node_games_api -->|"reads and writes games"| node_database
node_game_item_api -->|"accesses game"| node_database
node_borrowings_api -->|"creates and lists"| node_database
node_borrowing_item_api -->|"updates borrowing"| node_database
node_users_api -->|"reads and updates users"| node_database
node_register_api -->|"creates account"| node_database

click node_catalog_ui "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/GameCatalog.js"
click node_game_detail "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/games/%5Bid%5D/page.js"
click node_borrow_action "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/BorrowButton.js"
click node_auth_ui "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/AuthForm.js"
click node_my_borrowings "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/my-borrowings/page.js"
click node_staff_inventory "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/StaffGameManager.js"
click node_staff_requests "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/RequestManager.js"
click node_admin_users "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/UserManager.js"
click node_games_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/games/route.js"
click node_game_item_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/games/%5Bid%5D/route.js"
click node_borrowings_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/borrowings/route.js"
click node_borrowing_item_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/borrowings/%5Bid%5D/route.js"
click node_users_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/users/route.js"
click node_login_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/login/route.js"
click node_register_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/register/route.js"
click node_session_api "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/me/route.js"
click node_auth "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/auth.js"
click node_rbac "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/rbac.js"
click node_database "https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/db.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_catalog_ui,node_game_detail,node_borrow_action,node_auth_ui,node_my_borrowings toneBlue
class node_staff_inventory,node_staff_requests,node_admin_users toneAmber
class node_games_api,node_game_item_api,node_borrowings_api,node_borrowing_item_api,node_users_api,node_login_api,node_register_api,node_session_api toneMint
class node_auth,node_rbac,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Member experience

- [Catalog and game cards](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/GameCatalog.js): `components/GameCatalog.js`
- [Game detail](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/games/%5Bid%5D/page.js): `app/games/[id]/page.js`
- [Borrow request action](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/BorrowButton.js): `components/BorrowButton.js`
- [Login and registration form](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/AuthForm.js): `components/AuthForm.js`
- [My borrowings](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/my-borrowings/page.js): `app/my-borrowings/page.js`

### Staff operations

- [Inventory management](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/StaffGameManager.js): `components/StaffGameManager.js`
- [Request review](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/RequestManager.js): `components/RequestManager.js`
- [User role management](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/components/UserManager.js): `components/UserManager.js`

### Application API

- [Games API](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/games/route.js): `app/api/games/route.js`
- [Game item API](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/games/%5Bid%5D/route.js): `app/api/games/[id]/route.js`
- [Borrowings API](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/borrowings/route.js): `app/api/borrowings/route.js`
- [Borrowing status API](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/borrowings/%5Bid%5D/route.js): `app/api/borrowings/[id]/route.js`
- [Users API](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/users/route.js): `app/api/users/route.js`
- [Login endpoint](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/login/route.js): `app/api/login/route.js`
- [Registration endpoint](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/register/route.js): `app/api/register/route.js`
- [Session endpoints](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/app/api/me/route.js): `app/api/me/route.js`

### Identity and persistence

- [Session and permissions](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/auth.js): `lib/auth.js`
- [Role permission rules](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/rbac.js): `lib/rbac.js`
- [MySQL pool](https://github.com/phone-myint-arkar/rsu-bgc/blob/main/lib/db.js): `lib/db.js`

### Other components

- **Member or visitor**

## Connections

- Member or visitor → Catalog and game cards: browses
- Catalog and game cards → Game detail: opens game
- Game detail → Borrow request action: offers request (evidence: `app/games/[id]/page.js`)
- Borrow request action → Borrowings API: creates request (evidence: `app/api/borrowings/route.js`)
- Member or visitor → Login and registration form: submits credentials (evidence: `components/AuthForm.js`)
- Login and registration form → Login endpoint: posts login (evidence: `components/AuthForm.js`)
- Login and registration form → Registration endpoint: posts registration (evidence: `components/AuthForm.js`)
- My borrowings → Borrowings API: loads requests (evidence: `app/api/borrowings/route.js`)
- Inventory management → Games API: adds game (evidence: `components/StaffGameManager.js`)
- Request review → Borrowing status API: updates status (evidence: `components/RequestManager.js`)
- User role management → Users API: changes role (evidence: `components/UserManager.js`)
- Games API → Session and permissions: checks permission (evidence: `app/api/games/route.js`)
- Game item API → Session and permissions: checks permission (evidence: `app/api/games/[id]/route.js`)
- Borrowings API → Session and permissions: checks permission (evidence: `app/api/borrowings/route.js`)
- Borrowing status API → Session and permissions: checks permission (evidence: `app/api/borrowings/[id]/route.js`)
- Users API → Session and permissions: checks permission (evidence: `app/api/users/route.js`)
- Login endpoint → Session and permissions: creates session (evidence: `app/api/login/route.js`)
- Registration endpoint → Session and permissions: creates session (evidence: `app/api/register/route.js`)
- Session endpoints → Session and permissions: reads session (evidence: `app/api/me/route.js`)
- Session and permissions → MySQL pool: loads current user (evidence: `lib/auth.js`)
- Session and permissions → Role permission rules: checks role (evidence: `lib/auth.js`)
- Games API → MySQL pool: reads and writes games (evidence: `app/api/games/route.js`)
- Game item API → MySQL pool: accesses game (evidence: `app/api/games/[id]/route.js`)
- Borrowings API → MySQL pool: creates and lists (evidence: `app/api/borrowings/route.js`)
- Borrowing status API → MySQL pool: updates borrowing (evidence: `app/api/borrowings/[id]/route.js`)
- Users API → MySQL pool: reads and updates users (evidence: `app/api/users/route.js`)
- Registration endpoint → MySQL pool: creates account (evidence: `app/api/register/route.js`)
