# haerinzue/iphonestore architecture

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

- Interactive diagram: https://gitdiagram.com/haerinzue/iphonestore
- Repository: https://github.com/haerinzue/iphonestore

## Overview

MGH iPhone Store is a phone-listing storefront with browser-based administration. Shoppers browse and search published listings, inspect photos and specifications, then contact the seller; administrators manage listings and images. The README documents Supabase as the primary backend, while server.js provides a separate local Express/JSON API and legacy scripts preserve older storefront/cart behavior. Admin excerpts show authentication and listing operations, but the complete page wiring and some backend configuration were not sampled.

Main entry points: [`admin.js`](https://github.com/haerinzue/iphonestore/blob/main/admin.js) (Listing Console), [`store.js`](https://github.com/haerinzue/iphonestore/blob/main/store.js) (Live Catalog), [`server.js`](https://github.com/haerinzue/iphonestore/blob/main/server.js) (Express API), [`index.html`](https://github.com/haerinzue/iphonestore/blob/main/index.html) (Storefront Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_storefront_page["Storefront Page<br/>[index.html]"]
  node_catalog["Live Catalog<br/>[store.js]"]
  node_listing_detail["Listing Details<br/>[store.js]"]
  node_seller_contact["Seller Contact<br/>[store.js]"]
  node_legacy_catalog["Legacy Catalog<br/>[legacy-store.js]"]
  node_legacy_demo["Cart Demo<br/>[legacy-script.js]"]
end

subgraph group_admin["Administration"]
  node_admin_page["Admin Page<br/>[admin.html]"]
  node_admin_console["Listing Console<br/>[admin.js]"]
end

subgraph group_supabase["Supabase Services"]
  node_supabase_auth["Supabase Auth"]
  node_phones_table[("Phones Table")]
  node_image_bucket[("Phone Images")]
end

subgraph group_local["Local API"]
  node_local_server["Express API<br/>[server.js]"]
  node_local_catalog[("JSON Listings<br/>[phones.json]")]
  node_local_images[("Uploaded Images<br/>[server.js]")]
end

node_shopper(("Shopper"))
node_admin_user(("Administrator"))

node_shopper -->|"opens"| node_storefront_page
node_storefront_page -->|"loads"| node_catalog
node_catalog -->|"reads listings"| node_phones_table
node_phones_table -->|"updates listings"| node_catalog
node_shopper -->|"selects listing"| node_listing_detail
node_listing_detail -->|"opens contact"| node_seller_contact
node_shopper -.->|"opens legacy page"| node_legacy_catalog
node_legacy_catalog -->|"reads listings"| node_phones_table
node_shopper -.->|"uses demo cart"| node_legacy_demo
node_admin_user -->|"opens"| node_admin_page
node_admin_page -->|"loads"| node_admin_console
node_admin_console -->|"authenticates"| node_supabase_auth
node_admin_console -->|"manages listings"| node_phones_table
node_admin_console -->|"uploads images"| node_image_bucket
node_admin_console -->|"removes images"| node_image_bucket
node_local_server -->|"reads and writes"| node_local_catalog
node_local_server -->|"stores uploads"| node_local_images

click node_storefront_page "https://github.com/haerinzue/iphonestore/blob/main/index.html"
click node_catalog "https://github.com/haerinzue/iphonestore/blob/main/store.js"
click node_listing_detail "https://github.com/haerinzue/iphonestore/blob/main/store.js"
click node_seller_contact "https://github.com/haerinzue/iphonestore/blob/main/store.js"
click node_legacy_catalog "https://github.com/haerinzue/iphonestore/blob/main/legacy-store.js"
click node_legacy_demo "https://github.com/haerinzue/iphonestore/blob/main/legacy-script.js"
click node_admin_page "https://github.com/haerinzue/iphonestore/blob/main/admin.html"
click node_admin_console "https://github.com/haerinzue/iphonestore/blob/main/admin.js"
click node_local_server "https://github.com/haerinzue/iphonestore/blob/main/server.js"
click node_local_catalog "https://github.com/haerinzue/iphonestore/blob/main/phones.json"
click node_local_images "https://github.com/haerinzue/iphonestore/blob/main/server.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_storefront_page,node_catalog,node_listing_detail,node_seller_contact,node_legacy_catalog,node_legacy_demo toneBlue
class node_admin_page,node_admin_console toneAmber
class node_supabase_auth,node_phones_table,node_image_bucket toneMint
class node_local_server,node_local_catalog,node_local_images toneRose
class node_shopper,node_admin_user toneIndigo
```

## Components

### Storefront

- [Storefront Page](https://github.com/haerinzue/iphonestore/blob/main/index.html): `index.html`
- [Live Catalog](https://github.com/haerinzue/iphonestore/blob/main/store.js): `store.js`
- [Listing Details](https://github.com/haerinzue/iphonestore/blob/main/store.js): `store.js`
- [Seller Contact](https://github.com/haerinzue/iphonestore/blob/main/store.js): `store.js`
- [Legacy Catalog](https://github.com/haerinzue/iphonestore/blob/main/legacy-store.js): `legacy-store.js`
- [Cart Demo](https://github.com/haerinzue/iphonestore/blob/main/legacy-script.js): `legacy-script.js`

### Administration

- [Admin Page](https://github.com/haerinzue/iphonestore/blob/main/admin.html): `admin.html`
- [Listing Console](https://github.com/haerinzue/iphonestore/blob/main/admin.js): `admin.js`

### Supabase Services

- **Supabase Auth**
- **Phones Table**
- **Phone Images**

### Local API

- [Express API](https://github.com/haerinzue/iphonestore/blob/main/server.js): `server.js`
- [JSON Listings](https://github.com/haerinzue/iphonestore/blob/main/phones.json): `phones.json`
- [Uploaded Images](https://github.com/haerinzue/iphonestore/blob/main/server.js): `server.js`

### Other components

- **Shopper**
- **Administrator**

## Connections

- Shopper → Storefront Page: opens (evidence: `README.md`)
- Storefront Page → Live Catalog: loads (evidence: `README.md`)
- Live Catalog → Phones Table: reads listings (evidence: `store.js`)
- Phones Table → Live Catalog: updates listings (evidence: `store.js`)
- Shopper → Listing Details: selects listing (evidence: `store.js`)
- Listing Details → Seller Contact: opens contact (evidence: `store.js`)
- Shopper → Legacy Catalog: opens legacy page
- Legacy Catalog → Phones Table: reads listings (evidence: `legacy-store.js`)
- Shopper → Cart Demo: uses demo cart
- Administrator → Admin Page: opens (evidence: `README.md`)
- Admin Page → Listing Console: loads (evidence: `README.md`)
- Listing Console → Supabase Auth: authenticates (evidence: `admin.js`)
- Listing Console → Phones Table: manages listings (evidence: `admin.js`)
- Listing Console → Phone Images: uploads images (evidence: `admin.js`)
- Listing Console → Phone Images: removes images (evidence: `admin.js`)
- Express API → JSON Listings: reads and writes (evidence: `server.js`)
- Express API → Uploaded Images: stores uploads (evidence: `server.js`)
