# prem7713/geartrade architecture

> Architecture diagram of the GitHub repository prem7713/geartrade, 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/prem7713/geartrade
- Repository: https://github.com/prem7713/geartrade

## Overview

This is GearTrade, a used auto-parts marketplace with vehicle-aware discovery, product details, cart and checkout, bargain offers, customer accounts, and administrative management. The shopper flow begins at the storefront, continues through catalog and product interactions, then uses cart state to prepare checkout; the order API persists orders. Account and admin features form parallel workflows. Sampled source confirms key client-state, authentication, and API-to-database links; several route and page implementations were not sampled, so their internal connections are left unspecified.

Main entry points: [`lib/prisma.ts`](https://github.com/prem7713/geartrade/blob/main/lib/prisma.ts) (Prisma Client), [`lib/auth.ts`](https://github.com/prem7713/geartrade/blob/main/lib/auth.ts) (Authentication), [`app/page.tsx`](https://github.com/prem7713/geartrade/blob/main/app/page.tsx) (Storefront), [`components/ProductCard.tsx`](https://github.com/prem7713/geartrade/blob/main/components/ProductCard.tsx) (Product Card)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront &amp; Catalog"]
  node_home["Storefront<br/>[page.tsx]"]
  node_catalog["Catalog Pages<br/>[page.tsx]"]
  node_vehicle["Vehicle Selector"]
  node_product["Product Details"]
  node_product_card["Product Card<br/>[ProductCard.tsx]"]
end

subgraph group_purchase["Purchase &amp; Offers"]
  node_product_api["Product API<br/>[route.ts]"]
  node_cart["Cart State<br/>[cart-context.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_orders_api["Order API<br/>[route.ts]"]
  node_offers_api["Offers API<br/>[route.ts]"]
  node_bargain["Bargain Flow<br/>[BargainModal.tsx]"]
end

subgraph group_identity["Identity &amp; Accounts"]
  node_account["Customer Account<br/>[page.tsx]"]
  node_user_context["User State<br/>[user-context.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_auth_api["Auth Routes"]
end

subgraph group_operations["Administration"]
  node_admin["Admin Console"]
  node_admin_routes["Admin Routes"]
end

subgraph group_foundation["Runtime &amp; Data"]
  node_prisma["Prisma Client<br/>[prisma.ts]"]
  node_database[("PostgreSQL Database")]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_home
node_home -->|"renders"| node_vehicle
node_home -->|"renders"| node_product_card
node_home -->|"queries"| node_prisma
node_catalog -->|"renders"| node_vehicle
node_catalog -->|"renders"| node_product_card
node_catalog -->|"queries"| node_prisma
node_product -->|"updates"| node_cart
node_product -->|"opens"| node_bargain
node_product_card -->|"updates"| node_cart
node_product_card -->|"opens"| node_bargain
node_product_api -->|"checks user"| node_auth
node_product_api -->|"reads/writes"| node_prisma
node_checkout -->|"reads"| node_cart
node_checkout -->|"reads"| node_user_context
node_orders_api -->|"checks user"| node_auth
node_orders_api -->|"reads/writes"| node_prisma
node_bargain -->|"reads"| node_user_context
node_offers_api -->|"checks user"| node_auth
node_offers_api -->|"reads/writes"| node_prisma
node_account -->|"resolves user"| node_auth
node_account -->|"queries"| node_prisma
node_user_context -->|"fetches session"| node_auth_api
node_auth_api -->|"uses auth"| node_auth
node_admin -->|"queries"| node_prisma
node_admin_routes -.->|"uses auth"| node_auth
node_prisma -->|"connects"| node_database
node_auth -->|"loads user"| node_prisma

click node_home "https://github.com/prem7713/geartrade/blob/main/app/page.tsx"
click node_catalog "https://github.com/prem7713/geartrade/blob/main/app/shop/page.tsx"
click node_vehicle "https://github.com/prem7713/geartrade/blob/main/components/VehicleSelector.tsx"
click node_product "https://github.com/prem7713/geartrade/blob/main/components/ProductDetailClient.tsx"
click node_product_card "https://github.com/prem7713/geartrade/blob/main/components/ProductCard.tsx"
click node_product_api "https://github.com/prem7713/geartrade/blob/main/app/api/products/route.ts"
click node_cart "https://github.com/prem7713/geartrade/blob/main/lib/cart-context.tsx"
click node_checkout "https://github.com/prem7713/geartrade/blob/main/app/checkout/page.tsx"
click node_orders_api "https://github.com/prem7713/geartrade/blob/main/app/api/orders/route.ts"
click node_offers_api "https://github.com/prem7713/geartrade/blob/main/app/api/offers/route.ts"
click node_bargain "https://github.com/prem7713/geartrade/blob/main/components/BargainModal.tsx"
click node_account "https://github.com/prem7713/geartrade/blob/main/app/account/page.tsx"
click node_user_context "https://github.com/prem7713/geartrade/blob/main/lib/user-context.tsx"
click node_auth "https://github.com/prem7713/geartrade/blob/main/lib/auth.ts"
click node_auth_api "https://github.com/prem7713/geartrade/tree/main/app/api/auth"
click node_admin "https://github.com/prem7713/geartrade/tree/main/app/admin"
click node_admin_routes "https://github.com/prem7713/geartrade/tree/main/app/api/admin"
click node_prisma "https://github.com/prem7713/geartrade/blob/main/lib/prisma.ts"

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_home,node_catalog,node_vehicle,node_product,node_product_card toneBlue
class node_product_api,node_cart,node_checkout,node_orders_api,node_offers_api,node_bargain toneAmber
class node_account,node_user_context,node_auth,node_auth_api toneMint
class node_admin,node_admin_routes toneRose
class node_prisma,node_database,node_shopper toneIndigo
```

## Components

### Storefront & Catalog

- [Storefront](https://github.com/prem7713/geartrade/blob/main/app/page.tsx): `app/page.tsx`
- [Catalog Pages](https://github.com/prem7713/geartrade/blob/main/app/shop/page.tsx): `app/shop/page.tsx`
- [Vehicle Selector](https://github.com/prem7713/geartrade/blob/main/components/VehicleSelector.tsx): `components/VehicleSelector.tsx`
- [Product Details](https://github.com/prem7713/geartrade/blob/main/components/ProductDetailClient.tsx): `components/ProductDetailClient.tsx`
- [Product Card](https://github.com/prem7713/geartrade/blob/main/components/ProductCard.tsx): `components/ProductCard.tsx`

### Purchase & Offers

- [Product API](https://github.com/prem7713/geartrade/blob/main/app/api/products/route.ts): `app/api/products/route.ts`
- [Cart State](https://github.com/prem7713/geartrade/blob/main/lib/cart-context.tsx): `lib/cart-context.tsx`
- [Checkout](https://github.com/prem7713/geartrade/blob/main/app/checkout/page.tsx): `app/checkout/page.tsx`
- [Order API](https://github.com/prem7713/geartrade/blob/main/app/api/orders/route.ts): `app/api/orders/route.ts`
- [Offers API](https://github.com/prem7713/geartrade/blob/main/app/api/offers/route.ts): `app/api/offers/route.ts`
- [Bargain Flow](https://github.com/prem7713/geartrade/blob/main/components/BargainModal.tsx): `components/BargainModal.tsx`

### Identity & Accounts

- [Customer Account](https://github.com/prem7713/geartrade/blob/main/app/account/page.tsx): `app/account/page.tsx`
- [User State](https://github.com/prem7713/geartrade/blob/main/lib/user-context.tsx): `lib/user-context.tsx`
- [Authentication](https://github.com/prem7713/geartrade/blob/main/lib/auth.ts): `lib/auth.ts`
- [Auth Routes](https://github.com/prem7713/geartrade/tree/main/app/api/auth): `app/api/auth`

### Administration

- [Admin Console](https://github.com/prem7713/geartrade/tree/main/app/admin): `app/admin`
- [Admin Routes](https://github.com/prem7713/geartrade/tree/main/app/api/admin): `app/api/admin`

### Runtime & Data

- [Prisma Client](https://github.com/prem7713/geartrade/blob/main/lib/prisma.ts): `lib/prisma.ts`
- **PostgreSQL Database**

### Other components

- **Shopper**

## Connections

- Shopper → Storefront: browses (evidence: `app/page.tsx`)
- Storefront → Vehicle Selector: renders (evidence: `app/page.tsx`)
- Storefront → Product Card: renders (evidence: `app/page.tsx`)
- Storefront → Prisma Client: queries (evidence: `app/page.tsx`)
- Catalog Pages → Vehicle Selector: renders (evidence: `app/shop/page.tsx`)
- Catalog Pages → Product Card: renders (evidence: `app/shop/page.tsx`)
- Catalog Pages → Prisma Client: queries (evidence: `app/shop/page.tsx`)
- Product Details → Cart State: updates (evidence: `components/ProductDetailClient.tsx`)
- Product Details → Bargain Flow: opens (evidence: `components/ProductDetailClient.tsx`)
- Product Card → Cart State: updates (evidence: `components/ProductCard.tsx`)
- Product Card → Bargain Flow: opens (evidence: `components/ProductCard.tsx`)
- Product API → Authentication: checks user (evidence: `app/api/products/route.ts`)
- Product API → Prisma Client: reads/writes (evidence: `app/api/products/route.ts`)
- Checkout → Cart State: reads (evidence: `app/checkout/page.tsx`)
- Checkout → User State: reads (evidence: `app/checkout/page.tsx`)
- Order API → Authentication: checks user (evidence: `app/api/orders/route.ts`)
- Order API → Prisma Client: reads/writes (evidence: `app/api/orders/route.ts`)
- Bargain Flow → User State: reads (evidence: `components/BargainModal.tsx`)
- Offers API → Authentication: checks user (evidence: `app/api/offers/route.ts`)
- Offers API → Prisma Client: reads/writes (evidence: `app/api/offers/route.ts`)
- Customer Account → Authentication: resolves user (evidence: `app/account/page.tsx`)
- Customer Account → Prisma Client: queries (evidence: `app/account/page.tsx`)
- User State → Auth Routes: fetches session (evidence: `lib/user-context.tsx`)
- Auth Routes → Authentication: uses auth
- Admin Console → Prisma Client: queries (evidence: `app/admin/page.tsx`)
- Admin Routes → Authentication: uses auth
- Prisma Client → PostgreSQL Database: connects (evidence: `README.md`)
- Authentication → Prisma Client: loads user (evidence: `lib/auth.ts`)
