# phone-myint-arkar/gamestack architecture

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

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

## Overview

GameStack is a board-game club management web app. Members browse games, request borrowing, and track their loans; staff process requests and manage inventory, while admins also manage users and roles. The graph separates the member experience, lending operations, administration, and shared platform services. Source excerpts show key API, database, and authorization behavior; some page and component connections are supported by the SOURCE INDEX or README rather than full excerpts, so unverified implementation details are omitted.

Main entry points: [`lib/auth.js`](https://github.com/phone-myint-arkar/gamestack/blob/main/lib/auth.js) (Session and permissions), [`lib/db.js`](https://github.com/phone-myint-arkar/gamestack/blob/main/lib/db.js) (MySQL pool), [`components/ui`](https://github.com/phone-myint-arkar/gamestack/tree/main/components/ui) (UI component kit), [`components/StaffGameManager.js`](https://github.com/phone-myint-arkar/gamestack/blob/main/components/StaffGameManager.js) (Game manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_member["Member experience"]
  node_landing["Landing page<br/>[page.js]"]
  node_catalogpage["Game library page<br/>[page.js]"]
  node_catalog["Game catalog<br/>[GameCatalog.js]"]
  node_gamecard["Game card<br/>[GameCard.js]"]
  node_gamedetail["Game detail<br/>[page.js]"]
  node_dashboard["Role dashboard<br/>[page.js]"]
end

subgraph group_lending["Lending operations"]
  node_borrowbutton["Borrow action<br/>[BorrowButton.js]"]
  node_myloans["My borrowings<br/>[page.js]"]
  node_borrowapi["Borrowing API<br/>[route.js]"]
  node_loanitemapi["Loan status API<br/>[route.js]"]
  node_requestpage["Staff requests page<br/>[page.js]"]
  node_requestmanager["Request manager<br/>[RequestManager.js]"]
end

subgraph group_admin["Administration"]
  node_gamespage["Staff games page<br/>[page.js]"]
  node_gamemanager["Game manager"]
  node_gamesapi["Game catalog API<br/>[route.js]"]
  node_gameitemapi["Game item API<br/>[route.js]"]
  node_userpage["Admin users page<br/>[page.js]"]
  node_usermanager["User manager<br/>[UserManager.js]"]
  node_usersapi["User management API<br/>[route.js]"]
end

subgraph group_platform["Shared platform"]
  node_authapi["Authentication API<br/>[route.js]"]
  node_registerapi["Registration API<br/>[route.js]"]
  node_sessionapi["Session endpoints<br/>[route.js]"]
  node_authlib["Session and permissions<br/>[auth.js]"]
  node_rbac["Role permissions<br/>[rbac.js]"]
  node_database[("MySQL pool<br/>[db.js]")]
  node_uikit["UI component kit"]
end

node_members(("Club members"))
node_staff(("Club staff"))
node_admins(("Club admins"))

node_members -->|"browse"| node_landing
node_members -->|"open catalog"| node_catalogpage
node_catalogpage -->|"renders"| node_catalog
node_landing -->|"renders"| node_gamecard
node_catalog -->|"renders"| node_gamecard
node_members -->|"view game"| node_gamedetail
node_gamedetail -->|"renders"| node_borrowbutton
node_members -->|"request loan"| node_borrowbutton
node_members -->|"track loans"| node_myloans
node_members -->|"view dashboard"| node_dashboard
node_staff -->|"manage loans"| node_requestpage
node_requestpage -->|"renders"| node_requestmanager
node_requestmanager -->|"updates status"| node_loanitemapi
node_staff -->|"manage inventory"| node_gamespage
node_gamespage -->|"renders"| node_gamemanager
node_gamemanager -->|"adds games"| node_gamesapi
node_gamemanager -->|"deletes games"| node_gameitemapi
node_admins -->|"manage users"| node_userpage
node_userpage -->|"renders"| node_usermanager
node_usermanager -->|"updates users"| node_usersapi
node_members -->|"sign in"| node_authapi
node_members -->|"register"| node_registerapi
node_authapi -->|"sets session"| node_authlib
node_registerapi -->|"creates account"| node_database
node_authapi -->|"checks account"| node_database
node_sessionapi -->|"reads session"| node_authlib
node_authlib -->|"checks current role"| node_database
node_authlib -->|"checks permission"| node_rbac
node_borrowapi -->|"authorizes request"| node_authlib
node_loanitemapi -->|"authorizes update"| node_authlib
node_gamesapi -->|"authorizes creation"| node_authlib
node_usersapi -->|"requires permission"| node_authlib
node_borrowapi -->|"reads and writes"| node_database
node_loanitemapi -->|"updates loans"| node_database
node_gamesapi -->|"reads and writes"| node_database
node_gameitemapi -->|"manages games"| node_database
node_usersapi -->|"manages accounts"| node_database
node_dashboard -->|"uses components"| node_uikit
node_borrowbutton -->|"uses components"| node_uikit
node_requestmanager -->|"uses components"| node_uikit
node_gamemanager -->|"uses components"| node_uikit
node_usermanager -->|"uses components"| node_uikit

click node_landing "https://github.com/phone-myint-arkar/gamestack/blob/main/app/page.js"
click node_catalogpage "https://github.com/phone-myint-arkar/gamestack/blob/main/app/games/page.js"
click node_catalog "https://github.com/phone-myint-arkar/gamestack/blob/main/components/GameCatalog.js"
click node_gamecard "https://github.com/phone-myint-arkar/gamestack/blob/main/components/GameCard.js"
click node_gamedetail "https://github.com/phone-myint-arkar/gamestack/blob/main/app/games/%5Bid%5D/page.js"
click node_borrowbutton "https://github.com/phone-myint-arkar/gamestack/blob/main/components/BorrowButton.js"
click node_myloans "https://github.com/phone-myint-arkar/gamestack/blob/main/app/my-borrowings/page.js"
click node_dashboard "https://github.com/phone-myint-arkar/gamestack/blob/main/app/dashboard/page.js"
click node_borrowapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/borrowings/route.js"
click node_loanitemapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/borrowings/%5Bid%5D/route.js"
click node_requestpage "https://github.com/phone-myint-arkar/gamestack/blob/main/app/staff/requests/page.js"
click node_requestmanager "https://github.com/phone-myint-arkar/gamestack/blob/main/components/RequestManager.js"
click node_gamespage "https://github.com/phone-myint-arkar/gamestack/blob/main/app/staff/games/page.js"
click node_gamemanager "https://github.com/phone-myint-arkar/gamestack/blob/main/components/StaffGameManager.js"
click node_gamesapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/games/route.js"
click node_gameitemapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/games/%5Bid%5D/route.js"
click node_userpage "https://github.com/phone-myint-arkar/gamestack/blob/main/app/admin/users/page.js"
click node_usermanager "https://github.com/phone-myint-arkar/gamestack/blob/main/components/UserManager.js"
click node_usersapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/users/route.js"
click node_authapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/login/route.js"
click node_registerapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/register/route.js"
click node_sessionapi "https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/me/route.js"
click node_authlib "https://github.com/phone-myint-arkar/gamestack/blob/main/lib/auth.js"
click node_rbac "https://github.com/phone-myint-arkar/gamestack/blob/main/lib/rbac.js"
click node_database "https://github.com/phone-myint-arkar/gamestack/blob/main/lib/db.js"
click node_uikit "https://github.com/phone-myint-arkar/gamestack/tree/main/components/ui"

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_landing,node_catalogpage,node_catalog,node_gamecard,node_gamedetail,node_dashboard toneBlue
class node_borrowbutton,node_myloans,node_borrowapi,node_loanitemapi,node_requestpage,node_requestmanager toneAmber
class node_gamespage,node_gamemanager,node_gamesapi,node_gameitemapi,node_userpage,node_usermanager,node_usersapi toneMint
class node_authapi,node_registerapi,node_sessionapi,node_authlib,node_rbac,node_database,node_uikit toneRose
class node_members,node_staff,node_admins toneIndigo
```

## Components

### Member experience

- [Landing page](https://github.com/phone-myint-arkar/gamestack/blob/main/app/page.js): `app/page.js`
- [Game library page](https://github.com/phone-myint-arkar/gamestack/blob/main/app/games/page.js): `app/games/page.js`
- [Game catalog](https://github.com/phone-myint-arkar/gamestack/blob/main/components/GameCatalog.js): `components/GameCatalog.js`
- [Game card](https://github.com/phone-myint-arkar/gamestack/blob/main/components/GameCard.js): `components/GameCard.js`
- [Game detail](https://github.com/phone-myint-arkar/gamestack/blob/main/app/games/%5Bid%5D/page.js): `app/games/[id]/page.js`
- [Role dashboard](https://github.com/phone-myint-arkar/gamestack/blob/main/app/dashboard/page.js): `app/dashboard/page.js`

### Lending operations

- [Borrow action](https://github.com/phone-myint-arkar/gamestack/blob/main/components/BorrowButton.js): `components/BorrowButton.js`
- [My borrowings](https://github.com/phone-myint-arkar/gamestack/blob/main/app/my-borrowings/page.js): `app/my-borrowings/page.js`
- [Borrowing API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/borrowings/route.js): `app/api/borrowings/route.js`
- [Loan status API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/borrowings/%5Bid%5D/route.js): `app/api/borrowings/[id]/route.js`
- [Staff requests page](https://github.com/phone-myint-arkar/gamestack/blob/main/app/staff/requests/page.js): `app/staff/requests/page.js`
- [Request manager](https://github.com/phone-myint-arkar/gamestack/blob/main/components/RequestManager.js): `components/RequestManager.js`

### Administration

- [Staff games page](https://github.com/phone-myint-arkar/gamestack/blob/main/app/staff/games/page.js): `app/staff/games/page.js`
- [Game manager](https://github.com/phone-myint-arkar/gamestack/blob/main/components/StaffGameManager.js): `components/StaffGameManager.js`
- [Game catalog API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/games/route.js): `app/api/games/route.js`
- [Game item API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/games/%5Bid%5D/route.js): `app/api/games/[id]/route.js`
- [Admin users page](https://github.com/phone-myint-arkar/gamestack/blob/main/app/admin/users/page.js): `app/admin/users/page.js`
- [User manager](https://github.com/phone-myint-arkar/gamestack/blob/main/components/UserManager.js): `components/UserManager.js`
- [User management API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/users/route.js): `app/api/users/route.js`

### Shared platform

- [Authentication API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/login/route.js): `app/api/login/route.js`
- [Registration API](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/register/route.js): `app/api/register/route.js`
- [Session endpoints](https://github.com/phone-myint-arkar/gamestack/blob/main/app/api/me/route.js): `app/api/me/route.js`
- [Session and permissions](https://github.com/phone-myint-arkar/gamestack/blob/main/lib/auth.js): `lib/auth.js`
- [Role permissions](https://github.com/phone-myint-arkar/gamestack/blob/main/lib/rbac.js): `lib/rbac.js`
- [MySQL pool](https://github.com/phone-myint-arkar/gamestack/blob/main/lib/db.js): `lib/db.js`
- [UI component kit](https://github.com/phone-myint-arkar/gamestack/tree/main/components/ui): `components/ui`

### Other components

- **Club members**
- **Club staff**
- **Club admins**

## Connections

- Club members → Landing page: browse
- Club members → Game library page: open catalog
- Game library page → Game catalog: renders (evidence: `app/games/page.js`)
- Landing page → Game card: renders (evidence: `app/page.js`)
- Game catalog → Game card: renders (evidence: `components/GameCatalog.js`)
- Club members → Game detail: view game
- Game detail → Borrow action: renders (evidence: `app/games/[id]/page.js`)
- Club members → Borrow action: request loan
- Club members → My borrowings: track loans
- Club members → Role dashboard: view dashboard
- Club staff → Staff requests page: manage loans
- Staff requests page → Request manager: renders (evidence: `app/staff/requests/page.js`)
- Request manager → Loan status API: updates status (evidence: `components/RequestManager.js`)
- Club staff → Staff games page: manage inventory
- Staff games page → Game manager: renders (evidence: `app/staff/games/page.js`)
- Game manager → Game catalog API: adds games (evidence: `components/StaffGameManager.js`)
- Game manager → Game item API: deletes games (evidence: `components/StaffGameManager.js`)
- Club admins → Admin users page: manage users
- Admin users page → User manager: renders (evidence: `app/admin/users/page.js`)
- User manager → User management API: updates users (evidence: `components/UserManager.js`)
- Club members → Authentication API: sign in
- Club members → Registration API: register
- Authentication API → Session and permissions: sets session (evidence: `app/api/login/route.js`)
- Registration API → MySQL pool: creates account (evidence: `app/api/register/route.js`)
- Authentication API → MySQL pool: checks account (evidence: `app/api/login/route.js`)
- Session endpoints → Session and permissions: reads session (evidence: `app/api/me/route.js`)
- Session and permissions → MySQL pool: checks current role (evidence: `lib/auth.js`)
- Session and permissions → Role permissions: checks permission (evidence: `lib/auth.js`)
- Borrowing API → Session and permissions: authorizes request (evidence: `app/api/borrowings/route.js`)
- Loan status API → Session and permissions: authorizes update (evidence: `app/api/borrowings/[id]/route.js`)
- Game catalog API → Session and permissions: authorizes creation (evidence: `app/api/games/route.js`)
- User management API → Session and permissions: requires permission (evidence: `app/api/users/route.js`)
- Borrowing API → MySQL pool: reads and writes (evidence: `app/api/borrowings/route.js`)
- Loan status API → MySQL pool: updates loans (evidence: `app/api/borrowings/[id]/route.js`)
- Game catalog API → MySQL pool: reads and writes (evidence: `app/api/games/route.js`)
- Game item API → MySQL pool: manages games (evidence: `app/api/games/[id]/route.js`)
- User management API → MySQL pool: manages accounts (evidence: `app/api/users/route.js`)
- Role dashboard → UI component kit: uses components (evidence: `app/dashboard/page.js`)
- Borrow action → UI component kit: uses components (evidence: `components/BorrowButton.js`)
- Request manager → UI component kit: uses components (evidence: `components/RequestManager.js`)
- Game manager → UI component kit: uses components (evidence: `components/StaffGameManager.js`)
- User manager → UI component kit: uses components (evidence: `components/UserManager.js`)
