# hlua4312-hub/pr-marketplace architecture

> Architecture diagram of the GitHub repository hlua4312-hub/pr-marketplace, 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/hlua4312-hub/pr-marketplace
- Repository: https://github.com/hlua4312-hub/pr-marketplace

## Overview

PR Marketplace is a campus peer-to-peer marketplace delivered as an installable web app and an Android WebView wrapper. The main user journey is browse/search listings, inspect a listing, then sign in when needed to post, message, or contact a seller; optional branches cover wanted requests, reviews, and direct UPI payment claims. The browser app orchestrates feature modules, which use a shared API and device-local state. Supabase supplies backend services. Several module links are supported by the SOURCE INDEX or README; unsampled implementation details are not inferred.

Main entry points: [`js/app.js`](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/app.js) (App coordinator), [`js/api.js`](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/api.js) (Marketplace API), [`js/sell.js`](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/sell.js) (Create listings), [`js/payments.js`](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/payments.js) (Payment claims)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client shell"]
  node_android["Android WebView<br/>[MainActivity.java]"]
  node_app["App coordinator<br/>[app.js]"]
  node_pwa["PWA worker<br/>[sw.js]"]
  node_ui["Shared UI<br/>[ui.js]"]
  node_updates["Update checks<br/>[updates.js]"]
end

subgraph group_marketplace["Marketplace features"]
  node_feed["Browse and search<br/>[feed.js]"]
  node_detail["Listing details<br/>[detail.js]"]
  node_sell["Create listings<br/>[sell.js]"]
  node_cropper["Photo cropper<br/>[cropper.js]"]
  node_requests["Wanted board<br/>[requests.js]"]
  node_campus["Campus setup<br/>[campus.js]"]
end

subgraph group_engagement["Accounts and engagement"]
  node_auth["Student accounts<br/>[auth.js]"]
  node_account["Profile and account<br/>[account.js]"]
  node_messaging["Messaging<br/>[messaging.js]"]
  node_payments["Payment claims<br/>[payments.js]"]
  node_upi["UPI utilities<br/>[upi.js]"]
end

subgraph group_services["Data and integrations"]
  node_api["Marketplace API<br/>[api.js]"]
  node_store[("Local state<br/>[store.js]")]
  node_supabase[("Supabase services")]
end

node_browser(("Marketplace user"))
node_upiapps["UPI apps"]

node_browser -->|"opens app"| node_android
node_browser -->|"uses"| node_app
node_android -->|"wraps web app"| node_app
node_app -->|"initializes"| node_feed
node_app -->|"routes listing"| node_detail
node_app -->|"initializes"| node_sell
node_app -->|"initializes"| node_messaging
node_app -->|"initializes"| node_auth
node_app -->|"initializes"| node_account
node_app -->|"initializes"| node_payments
node_app -->|"closes board"| node_requests
node_app -->|"sets tab"| node_store
node_app -->|"purges sold items"| node_api
node_app -.->|"manages updates"| node_updates
node_app -->|"initializes"| node_campus
node_feed -->|"fetches listings"| node_api
node_feed -->|"reads filters"| node_store
node_sell -->|"opens cropper"| node_cropper
node_sell -->|"validates UPI"| node_upi
node_detail -.->|"listing actions"| node_api
node_requests -.->|"request actions"| node_api
node_messaging -.->|"sends messages"| node_api
node_payments -.->|"files payment claim"| node_api
node_payments -->|"renders QR"| node_upi
node_payments -->|"opens payment link"| node_upiapps
node_account -.->|"loads account data"| node_api
node_auth -->|"authenticates"| node_supabase
node_api -->|"uses backend"| node_supabase
node_messaging -->|"uses Realtime"| node_supabase
node_sell -->|"uploads listing photos"| node_supabase
node_app -.->|"registers worker"| node_pwa
node_updates -->|"checks worker updates"| node_pwa
node_feed -->|"renders with helpers"| node_ui
node_sell -->|"uses shared UI"| node_ui
node_cropper -->|"uses image helpers"| node_ui
node_payments -->|"uses shared UI"| node_ui
node_account -->|"checks Android build"| node_updates

click node_android "https://github.com/hlua4312-hub/pr-marketplace/blob/main/android_app/app/src/main/java/com/prmarketplace/app/MainActivity.java"
click node_app "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/app.js"
click node_pwa "https://github.com/hlua4312-hub/pr-marketplace/blob/main/sw.js"
click node_ui "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/ui.js"
click node_feed "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/feed.js"
click node_detail "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/detail.js"
click node_sell "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/sell.js"
click node_cropper "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/cropper.js"
click node_requests "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/requests.js"
click node_campus "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/campus.js"
click node_auth "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/auth.js"
click node_account "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/account.js"
click node_messaging "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/messaging.js"
click node_payments "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/payments.js"
click node_upi "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/upi.js"
click node_updates "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/updates.js"
click node_api "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/api.js"
click node_store "https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/store.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_android,node_app,node_pwa,node_ui,node_updates,node_browser toneBlue
class node_feed,node_detail,node_sell,node_cropper,node_requests,node_campus toneAmber
class node_auth,node_account,node_messaging,node_payments,node_upi toneMint
class node_api,node_store,node_supabase toneRose
class node_upiapps toneIndigo
```

## Components

### Client shell

- [Android WebView](https://github.com/hlua4312-hub/pr-marketplace/blob/main/android_app/app/src/main/java/com/prmarketplace/app/MainActivity.java): `android_app/app/src/main/java/com/prmarketplace/app/MainActivity.java`
- [App coordinator](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/app.js): `js/app.js`
- [PWA worker](https://github.com/hlua4312-hub/pr-marketplace/blob/main/sw.js): `sw.js`
- [Shared UI](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/ui.js): `js/ui.js`
- [Update checks](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/updates.js): `js/updates.js`

### Marketplace features

- [Browse and search](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/feed.js): `js/feed.js`
- [Listing details](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/detail.js): `js/detail.js`
- [Create listings](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/sell.js): `js/sell.js`
- [Photo cropper](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/cropper.js): `js/cropper.js`
- [Wanted board](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/requests.js): `js/requests.js`
- [Campus setup](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/campus.js): `js/campus.js`

### Accounts and engagement

- [Student accounts](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/auth.js): `js/auth.js`
- [Profile and account](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/account.js): `js/account.js`
- [Messaging](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/messaging.js): `js/messaging.js`
- [Payment claims](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/payments.js): `js/payments.js`
- [UPI utilities](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/upi.js): `js/upi.js`

### Data and integrations

- [Marketplace API](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/api.js): `js/api.js`
- [Local state](https://github.com/hlua4312-hub/pr-marketplace/blob/main/js/store.js): `js/store.js`
- **Supabase services**

### Other components

- **Marketplace user**
- **UPI apps**

## Connections

- Marketplace user → Android WebView: opens app (evidence: `README.md`)
- Marketplace user → App coordinator: uses (evidence: `README.md`)
- Android WebView → App coordinator: wraps web app (evidence: `README.md`)
- App coordinator → Browse and search: initializes (evidence: `js/app.js`)
- App coordinator → Listing details: routes listing (evidence: `js/app.js`)
- App coordinator → Create listings: initializes (evidence: `js/app.js`)
- App coordinator → Messaging: initializes (evidence: `js/app.js`)
- App coordinator → Student accounts: initializes (evidence: `js/app.js`)
- App coordinator → Profile and account: initializes (evidence: `js/app.js`)
- App coordinator → Payment claims: initializes (evidence: `js/app.js`)
- App coordinator → Wanted board: closes board (evidence: `js/app.js`)
- App coordinator → Local state: sets tab (evidence: `js/app.js`)
- App coordinator → Marketplace API: purges sold items (evidence: `js/app.js`)
- App coordinator → Update checks: manages updates (evidence: `js/app.js`)
- App coordinator → Campus setup: initializes (evidence: `js/app.js`)
- Browse and search → Marketplace API: fetches listings (evidence: `js/feed.js`)
- Browse and search → Local state: reads filters (evidence: `js/feed.js`)
- Create listings → Photo cropper: opens cropper (evidence: `js/sell.js`)
- Create listings → UPI utilities: validates UPI (evidence: `js/sell.js`)
- Listing details → Marketplace API: listing actions
- Wanted board → Marketplace API: request actions
- Messaging → Marketplace API: sends messages
- Payment claims → Marketplace API: files payment claim
- Payment claims → UPI utilities: renders QR (evidence: `js/payments.js`)
- Payment claims → UPI apps: opens payment link (evidence: `README.md`)
- Profile and account → Marketplace API: loads account data
- Student accounts → Supabase services: authenticates (evidence: `README.md`)
- Marketplace API → Supabase services: uses backend (evidence: `README.md`)
- Messaging → Supabase services: uses Realtime (evidence: `README.md`)
- Create listings → Supabase services: uploads listing photos (evidence: `js/sell.js`)
- App coordinator → PWA worker: registers worker
- Update checks → PWA worker: checks worker updates (evidence: `js/updates.js`)
- Browse and search → Shared UI: renders with helpers (evidence: `js/feed.js`)
- Create listings → Shared UI: uses shared UI (evidence: `js/sell.js`)
- Photo cropper → Shared UI: uses image helpers (evidence: `js/cropper.js`)
- Payment claims → Shared UI: uses shared UI (evidence: `js/payments.js`)
- Profile and account → Update checks: checks Android build (evidence: `js/account.js`)
