# amuthavanmoorthi/taiwan-mobile-client architecture

> Architecture diagram of the GitHub repository amuthavanmoorthi/taiwan-mobile-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amuthavanmoorthi/taiwan-mobile-client
- Repository: https://github.com/amuthavanmoorthi/taiwan-mobile-client

## Overview

#### Purpose and Runtime
This is a Next.js frontend for a marketplace/catalog of physical items with buyer accounts, bids, checkout/orders, and staff administration. It runs on port 3000 and depends on a separately running backend API, configurable through `NEXT_PUBLIC_API_URL`. The App Router shell originates at `src/app/layout.tsx`; public discovery begins at `src/app/page.tsx` and `src/app/products/page.tsx`.

#### Application Routing and UI Shell
Route pages compose reusable client-facing UI for catalog browsing, product detail, authentication, account management, and checkout. Shared navigation and global styling establish the site-wide presentation boundary in `src/components/HeaderNav.tsx`, `src/app/layout.tsx`, and `src/app/globals.css`. Product and order detail routes are parameterized under `src/app/products/[id]/page.tsx` and `src/app/orders/[id]/page.tsx`.

#### Catalog, Listings, and Bidding
The buyer flow is: browse/filter product listings, inspect a product, view its media/model, place bids, then proceed to checkout and order views. Core UI components are `src/components/ProductCard.tsx`, `src/components/FilterRail.tsx`, and `src/components/BidPanel.tsx`. Local Next API boundaries for bid and order operations are `src/app/api/bids/route.ts` and `src/app/api/orders/route.ts`; these likely proxy or adapt requests to the required backend rather than owning persistence.

#### Authentication, Session, and Account
Authentication is exposed through login/register/logout API routes and corresponding screens, while session handling is centralized in `src/lib/session.ts`. Main boundaries are `src/app/api/auth/login/route.ts`, `src/app/api/auth/register/route.ts`, and `src/app/account/page.tsx`. Account profile changes use `src/app/api/account/route.ts`; UI should rely on this API/session boundary rather than directly managing backend credentials.

#### Staff and Admin Operations
A protected staff area supports inventory, order oversight, FAQ management, verification, and team administration. The staff dashboard and inventory workflows start at `src/app/staff/page.tsx`, `src/app/staff/inventory/page.tsx`, and `src/app/staff/inventory/[id]/review/page.tsx`. Server endpoints separate staff capabilities by domain: inventory CRUD/model upload at `src/app/api/staff/inventory/route.ts` and `src/app/api/staff/inventory/[id]/model/route.ts`, FAQ management at `src/app/api/staff/faqs/route.ts`, and admin team/password management at `src/app/api/admin/team/route.ts`.

#### 3D/AR Asset Pipeline
Catalog items can be presented in browser viewers and mobile AR handoff flows. Viewer and measurement surfaces are implemented in `src/components/ProductViewer.tsx`, `src/components/ModelViewer.tsx`, and `src/components/ArRuler.tsx`. Static GLB and USDZ assets are served directly from `public/models/`, enabling Android-oriented GLB and iOS-oriented USDZ delivery; asset placeholders are regenerated by `scripts/make-placeholder-glb.mjs` and `scripts/usdz.mjs`.

#### Integration Boundaries and Shared Domain Utilities
`src/lib/api.ts` is the primary client/server API integration seam to the external backend. Shared domain and presentation concerns are separated into category data (`src/lib/categories.ts`), locale/i18n (`src/lib/locale.ts`, `src/lib/i18n.ts`), and server-aware district/theme utilities (`src/lib/district.server.ts`, `src/lib/theme.server.ts`). Next configuration resides in `next.config.ts`; there is no database or backend implementation in this repository.

Main entry points: [`src/app/products/[id]/page.tsx`](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/%5Bid%5D/page.tsx) (Product detail), [`src/lib/api.ts`](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/lib/api.ts) (Backend API client), [`src/app/layout.tsx`](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/layout.tsx) (App shell), [`src/app/products/page.tsx`](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/page.tsx) (Catalog discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_buyer["Buyer experience"]
  node_app_shell["App shell<br/>Next.js layout<br/>[layout.tsx]"]
  node_catalog["Catalog discovery<br/>route pages<br/>[page.tsx]"]
  node_catalog_ui["Catalog controls<br/>UI components<br/>[ProductCard.tsx]"]
  node_product_detail["Product detail<br/>parameterized route<br/>[page.tsx]"]
  node_bid_panel["Bid panel<br/>UI component<br/>[BidPanel.tsx]"]
  node_checkout_orders["Checkout and orders<br/>order flow<br/>[page.tsx]"]
  node_account["Account and auth<br/>route screens<br/>[page.tsx]"]
end

subgraph group_staff["Staff operations"]
  node_staff_dashboard["Staff dashboard<br/>protected route<br/>[page.tsx]"]
  node_inventory_review["Inventory review<br/>parameterized route<br/>[page.tsx]"]
end

subgraph group_api["Next API boundary"]
  node_staff_endpoints["Staff management APIs<br/>route handlers<br/>[route.ts]"]
  node_auth_account_api["Auth and account APIs<br/>route handlers<br/>[route.ts]"]
  node_commerce_api["Bid and order APIs<br/>route handlers<br/>[route.ts]"]
  node_session["Session handling<br/>shared server utility<br/>[session.ts]"]
  node_api_client["Backend API client<br/>integration utility<br/>[api.ts]"]
end

subgraph group_assets["3D and AR assets"]
  node_viewer["3D viewer and AR ruler<br/>UI components<br/>[ProductViewer.tsx]"]
  node_model_assets["GLB and USDZ models<br/>static assets"]
  node_asset_generation["Asset placeholder generation<br/>build scripts"]
end

node_external_backend{{"External backend API<br/>remote service"}}

node_app_shell -->|"hosts"| node_catalog
node_app_shell -->|"hosts"| node_account
node_app_shell -->|"hosts"| node_staff_dashboard
node_catalog -->|"composes"| node_catalog_ui
node_catalog -->|"select item"| node_product_detail
node_product_detail -->|"offers bidding"| node_bid_panel
node_product_detail -->|"renders model"| node_viewer
node_bid_panel -->|"places bid"| node_commerce_api
node_product_detail -->|"proceeds to checkout"| node_checkout_orders
node_checkout_orders -->|"creates or reads orders"| node_commerce_api
node_account -->|"authenticates and updates profile"| node_auth_account_api
node_auth_account_api -->|"establishes session"| node_session
node_staff_dashboard -->|"opens inventory workflow"| node_inventory_review
node_inventory_review -->|"reviews and uploads models"| node_staff_endpoints
node_staff_endpoints -->|"authorizes staff access"| node_session
node_auth_account_api -->|"uses"| node_api_client
node_commerce_api -->|"uses"| node_api_client
node_staff_endpoints -->|"uses"| node_api_client
node_api_client -->|"backend requests"| node_external_backend
node_viewer -->|"loads GLB or USDZ"| node_model_assets
node_asset_generation -->|"generates placeholders"| node_model_assets

click node_app_shell "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/layout.tsx"
click node_catalog "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/page.tsx"
click node_catalog_ui "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/ProductCard.tsx"
click node_product_detail "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/%5Bid%5D/page.tsx"
click node_bid_panel "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/BidPanel.tsx"
click node_checkout_orders "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/orders/%5Bid%5D/page.tsx"
click node_account "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/account/page.tsx"
click node_staff_dashboard "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/staff/page.tsx"
click node_inventory_review "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/staff/inventory/%5Bid%5D/review/page.tsx"
click node_staff_endpoints "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/staff/inventory/route.ts"
click node_auth_account_api "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/auth/login/route.ts"
click node_commerce_api "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/bids/route.ts"
click node_session "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/lib/session.ts"
click node_api_client "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/lib/api.ts"
click node_viewer "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/ProductViewer.tsx"
click node_asset_generation "https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/scripts/make-placeholder-glb.mjs"

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_shell,node_catalog,node_catalog_ui,node_product_detail,node_bid_panel,node_checkout_orders,node_account toneBlue
class node_staff_dashboard,node_inventory_review toneAmber
class node_staff_endpoints,node_auth_account_api,node_commerce_api,node_session,node_api_client toneMint
class node_viewer,node_model_assets,node_asset_generation toneRose
class node_external_backend toneNeutral
```

## Components

### Buyer experience

- [App shell](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/layout.tsx): Next.js layout · Global navigation and styling boundary. · `src/app/layout.tsx`
- [Catalog discovery](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/page.tsx): route pages · Home and product listing entry points. · `src/app/products/page.tsx`
- [Catalog controls](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/ProductCard.tsx): UI components · Product cards and filtering compose catalog browsing. · `src/components/ProductCard.tsx`
- [Product detail](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/products/%5Bid%5D/page.tsx): parameterized route · Shows item details, media, bidding, and viewer surfaces. · `src/app/products/[id]/page.tsx`
- [Bid panel](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/BidPanel.tsx): UI component · `src/components/BidPanel.tsx`
- [Checkout and orders](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/orders/%5Bid%5D/page.tsx): order flow · Includes parameterized order views. · `src/app/orders/[id]/page.tsx`
- [Account and auth](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/account/page.tsx): route screens · Buyer login, registration, and profile management. · `src/app/account/page.tsx`

### Staff operations

- [Staff dashboard](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/staff/page.tsx): protected route · Entry point for operational workflows. · `src/app/staff/page.tsx`
- [Inventory review](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/staff/inventory/%5Bid%5D/review/page.tsx): parameterized route · Staff review workflow for individual inventory items. · `src/app/staff/inventory/[id]/review/page.tsx`

### Next API boundary

Routes adapt requests to the external backend.

- [Staff management APIs](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/staff/inventory/route.ts): route handlers · Inventory/model, FAQ, and team administration endpoints. · `src/app/api/staff/inventory/route.ts`
- [Auth and account APIs](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/auth/login/route.ts): route handlers · Login, registration, logout, and profile boundary. · `src/app/api/auth/login/route.ts`
- [Bid and order APIs](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/app/api/bids/route.ts): route handlers · Local bid and order operation boundary. · `src/app/api/bids/route.ts`
- [Session handling](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/lib/session.ts): shared server utility · `src/lib/session.ts`
- [Backend API client](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/lib/api.ts): integration utility · Primary seam to the separately deployed backend API. · `src/lib/api.ts`

### 3D and AR assets

- [3D viewer and AR ruler](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/src/components/ProductViewer.tsx): UI components · Browser model viewing, measurement, and AR handoff surfaces. · `src/components/ProductViewer.tsx`
- **GLB and USDZ models**: static assets · GLB supports Android-oriented viewing; USDZ supports iOS handoff.
- [Asset placeholder generation](https://github.com/amuthavanmoorthi/taiwan-mobile-client/blob/master/scripts/make-placeholder-glb.mjs): build scripts · Generates placeholder GLB and USDZ assets. · `scripts/make-placeholder-glb.mjs`

### Other components

- **External backend API**: remote service · Configured through NEXT_PUBLIC_API_URL; persistence is outside this repository.

## Connections

- App shell → Catalog discovery: hosts
- App shell → Account and auth: hosts
- App shell → Staff dashboard: hosts
- Catalog discovery → Catalog controls: composes
- Catalog discovery → Product detail: select item
- Product detail → Bid panel: offers bidding
- Product detail → 3D viewer and AR ruler: renders model
- Bid panel → Bid and order APIs: places bid
- Product detail → Checkout and orders: proceeds to checkout
- Checkout and orders → Bid and order APIs: creates or reads orders
- Account and auth → Auth and account APIs: authenticates and updates profile
- Auth and account APIs → Session handling: establishes session
- Staff dashboard → Inventory review: opens inventory workflow
- Inventory review → Staff management APIs: reviews and uploads models
- Staff management APIs → Session handling: authorizes staff access
- Auth and account APIs → Backend API client: uses
- Bid and order APIs → Backend API client: uses
- Staff management APIs → Backend API client: uses
- Backend API client → External backend API: backend requests
- 3D viewer and AR ruler → GLB and USDZ models: loads GLB or USDZ
- Asset placeholder generation → GLB and USDZ models: generates placeholders
