# vampire0011/peripherals-hub architecture

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

- Interactive diagram: https://gitdiagram.com/vampire0011/peripherals-hub
- Repository: https://github.com/vampire0011/peripherals-hub

## Overview

PeripheralsHub is a mouse-and-keyboard catalog with price tracking, wishlists, affiliate purchase links, OAuth accounts, and an admin ingestion console. Shoppers browse and filter the catalog, save products to a wishlist, or follow a localized buy link; admins trigger mock or Playwright syncs whose product updates and logs persist for the console. The graph follows documented capabilities and indexed references; unsampled route and scraper internals are represented only where the README or index supports them.

Main entry points: [`src/auth.ts`](https://github.com/vampire0011/peripherals-hub/blob/main/src/auth.ts) (Auth configuration), [`src/lib/actions/products.ts`](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/actions/products.ts) (Catalog and wishlist actions), [`prisma/schema.prisma`](https://github.com/vampire0011/peripherals-hub/blob/main/prisma/schema.prisma) (Application database), [`src/lib/engine/syncEngine.ts`](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/syncEngine.ts) (Sync orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Catalog storefront"]
  node_home["Catalog page<br/>[page.tsx]"]
  node_hero["Storefront hero<br/>[hero.tsx]"]
  node_grid["Filter and sort<br/>[product-grid.tsx]"]
  node_card["Product card<br/>[product-card.tsx]"]
  node_buy["Affiliate links<br/>[affiliate.ts]"]
end

subgraph group_identity["Accounts and wishlist"]
  node_login["Sign-in pages<br/>[page.tsx]"]
  node_oauth["OAuth controls<br/>[oauth-buttons.tsx]"]
  node_auth["Auth configuration<br/>[auth.ts]"]
  node_authroute["Auth handler<br/>[route.ts]"]
  node_protection["Route protection<br/>[middleware.ts]"]
  node_dashboard["Profile and wishlist<br/>[page.tsx]"]
end

subgraph group_ingestion["Catalog ingestion"]
  node_sync["Sync orchestrator<br/>[syncEngine.ts]"]
  node_mock["Mock feed<br/>[mockSource.ts]"]
  node_playwright["Playwright scraper"]
  node_upsert["Product upsert<br/>[upsertProduct.ts]"]
end

subgraph group_operations["Admin operations"]
  node_adminpage["Admin page<br/>[page.tsx]"]
  node_console["Live sync console<br/>[admin-console.tsx]"]
  node_adminactions["Admin actions<br/>[admin.ts]"]
  node_logsroute["Sync log endpoint<br/>[route.ts]"]
end

subgraph group_data["Persistence and pricing"]
  node_productactions["Catalog and wishlist actions<br/>[products.ts]"]
  node_database[("Application database<br/>[schema.prisma]")]
  node_trend["Price trend calculation<br/>[priceTrend.ts]"]
end

node_shopper(("Shopper"))
node_admin(("Administrator"))
node_google["Google OAuth"]
node_github["GitHub OAuth"]
node_scrape_targets["Configured scrape sites"]

node_shopper -->|"browses"| node_home
node_home -->|"renders"| node_hero
node_home -->|"renders"| node_grid
node_home -->|"loads catalog"| node_productactions
node_grid -->|"renders products"| node_card
node_card -->|"localizes link"| node_buy
node_card -->|"toggles wishlist"| node_productactions
node_shopper -->|"signs in"| node_login
node_login -->|"renders"| node_oauth
node_oauth -->|"starts sign-in"| node_auth
node_auth -->|"authenticates"| node_google
node_auth -->|"authenticates"| node_github
node_authroute -->|"exposes handlers"| node_auth
node_protection -->|"checks session"| node_auth
node_shopper -->|"views saved gear"| node_dashboard
node_dashboard -->|"reads session"| node_auth
node_dashboard -->|"loads wishlist"| node_productactions
node_productactions -->|"checks identity"| node_auth
node_productactions -->|"reads and writes"| node_database
node_productactions -->|"computes price drops"| node_trend
node_productactions -->|"returns catalog data"| node_shopper
node_admin -->|"runs sync"| node_adminpage
node_adminpage -->|"renders"| node_console
node_console -->|"requests sync"| node_adminactions
node_adminactions -->|"checks admin"| node_auth
node_adminactions -->|"starts sync"| node_sync
node_adminactions -->|"reads stats and logs"| node_database
node_adminpage -->|"loads admin data"| node_adminactions
node_logsroute -->|"checks identity"| node_auth
node_logsroute -->|"reads logs"| node_database
node_sync -->|"fetches mock feed"| node_mock
node_sync -->|"fetches scrape feed"| node_playwright
node_playwright -->|"scrapes configured targets"| node_scrape_targets
node_sync -->|"upserts each item"| node_upsert
node_sync -->|"writes sync logs"| node_database
node_upsert -->|"updates products and history"| node_database
node_trend -->|"uses price history"| node_database

click node_home "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/page.tsx"
click node_hero "https://github.com/vampire0011/peripherals-hub/blob/main/src/components/hero.tsx"
click node_grid "https://github.com/vampire0011/peripherals-hub/blob/main/src/components/product-grid.tsx"
click node_card "https://github.com/vampire0011/peripherals-hub/blob/main/src/components/product-card.tsx"
click node_buy "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/affiliate.ts"
click node_login "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/login/page.tsx"
click node_oauth "https://github.com/vampire0011/peripherals-hub/blob/main/src/components/oauth-buttons.tsx"
click node_auth "https://github.com/vampire0011/peripherals-hub/blob/main/src/auth.ts"
click node_authroute "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_protection "https://github.com/vampire0011/peripherals-hub/blob/main/src/middleware.ts"
click node_dashboard "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/dashboard/page.tsx"
click node_productactions "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/actions/products.ts"
click node_adminpage "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/admin/page.tsx"
click node_console "https://github.com/vampire0011/peripherals-hub/blob/main/src/components/admin-console.tsx"
click node_adminactions "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/actions/admin.ts"
click node_logsroute "https://github.com/vampire0011/peripherals-hub/blob/main/src/app/api/admin/logs/route.ts"
click node_sync "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/syncEngine.ts"
click node_mock "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/mockSource.ts"
click node_playwright "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/playwrightSource.ts"
click node_upsert "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/upsertProduct.ts"
click node_database "https://github.com/vampire0011/peripherals-hub/blob/main/prisma/schema.prisma"
click node_trend "https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/priceTrend.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_hero,node_grid,node_card,node_buy toneBlue
class node_login,node_oauth,node_auth,node_authroute,node_protection,node_dashboard toneAmber
class node_sync,node_mock,node_playwright,node_upsert toneMint
class node_adminpage,node_console,node_adminactions,node_logsroute toneRose
class node_productactions,node_database,node_trend,node_shopper,node_admin,node_google,node_github,node_scrape_targets toneIndigo
```

## Components

### Catalog storefront

- [Catalog page](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Storefront hero](https://github.com/vampire0011/peripherals-hub/blob/main/src/components/hero.tsx): `src/components/hero.tsx`
- [Filter and sort](https://github.com/vampire0011/peripherals-hub/blob/main/src/components/product-grid.tsx): `src/components/product-grid.tsx`
- [Product card](https://github.com/vampire0011/peripherals-hub/blob/main/src/components/product-card.tsx): `src/components/product-card.tsx`
- [Affiliate links](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/affiliate.ts): `src/lib/affiliate.ts`

### Accounts and wishlist

- [Sign-in pages](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [OAuth controls](https://github.com/vampire0011/peripherals-hub/blob/main/src/components/oauth-buttons.tsx): `src/components/oauth-buttons.tsx`
- [Auth configuration](https://github.com/vampire0011/peripherals-hub/blob/main/src/auth.ts): `src/auth.ts`
- [Auth handler](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts): `src/app/api/auth/[...nextauth]/route.ts`
- [Route protection](https://github.com/vampire0011/peripherals-hub/blob/main/src/middleware.ts): `src/middleware.ts`
- [Profile and wishlist](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`

### Catalog ingestion

- [Sync orchestrator](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/syncEngine.ts): `src/lib/engine/syncEngine.ts`
- [Mock feed](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/mockSource.ts): `src/lib/engine/mockSource.ts`
- [Playwright scraper](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/playwrightSource.ts): `src/lib/engine/playwrightSource.ts`
- [Product upsert](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/engine/upsertProduct.ts): `src/lib/engine/upsertProduct.ts`

### Admin operations

- [Admin page](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Live sync console](https://github.com/vampire0011/peripherals-hub/blob/main/src/components/admin-console.tsx): `src/components/admin-console.tsx`
- [Admin actions](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/actions/admin.ts): `src/lib/actions/admin.ts`
- [Sync log endpoint](https://github.com/vampire0011/peripherals-hub/blob/main/src/app/api/admin/logs/route.ts): `src/app/api/admin/logs/route.ts`

### Persistence and pricing

- [Catalog and wishlist actions](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/actions/products.ts): `src/lib/actions/products.ts`
- [Application database](https://github.com/vampire0011/peripherals-hub/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Price trend calculation](https://github.com/vampire0011/peripherals-hub/blob/main/src/lib/priceTrend.ts): `src/lib/priceTrend.ts`

### Other components

- **Shopper**
- **Administrator**
- **Google OAuth**
- **GitHub OAuth**
- **Configured scrape sites**

## Connections

- Shopper → Catalog page: browses (evidence: `README.md`)
- Catalog page → Storefront hero: renders (evidence: `src/app/page.tsx`)
- Catalog page → Filter and sort: renders (evidence: `src/app/page.tsx`)
- Catalog page → Catalog and wishlist actions: loads catalog (evidence: `src/app/page.tsx`)
- Filter and sort → Product card: renders products (evidence: `src/components/product-grid.tsx`)
- Product card → Affiliate links: localizes link (evidence: `src/components/product-card.tsx`)
- Product card → Catalog and wishlist actions: toggles wishlist (evidence: `src/components/product-card.tsx`)
- Shopper → Sign-in pages: signs in (evidence: `README.md`)
- Sign-in pages → OAuth controls: renders (evidence: `src/app/login/page.tsx`)
- OAuth controls → Auth configuration: starts sign-in (evidence: `src/components/oauth-buttons.tsx`)
- Auth configuration → Google OAuth: authenticates (evidence: `src/auth.ts`)
- Auth configuration → GitHub OAuth: authenticates (evidence: `src/auth.ts`)
- Auth handler → Auth configuration: exposes handlers (evidence: `src/app/api/auth/[...nextauth]/route.ts`)
- Route protection → Auth configuration: checks session (evidence: `src/middleware.ts`)
- Shopper → Profile and wishlist: views saved gear (evidence: `README.md`)
- Profile and wishlist → Auth configuration: reads session (evidence: `src/app/dashboard/page.tsx`)
- Profile and wishlist → Catalog and wishlist actions: loads wishlist (evidence: `src/app/dashboard/page.tsx`)
- Catalog and wishlist actions → Auth configuration: checks identity (evidence: `src/lib/actions/products.ts`)
- Catalog and wishlist actions → Application database: reads and writes (evidence: `src/lib/actions/products.ts`)
- Catalog and wishlist actions → Price trend calculation: computes price drops (evidence: `src/lib/actions/products.ts`)
- Catalog and wishlist actions → Shopper: returns catalog data (evidence: `src/lib/actions/products.ts`)
- Administrator → Admin page: runs sync (evidence: `README.md`)
- Admin page → Live sync console: renders (evidence: `src/app/admin/page.tsx`)
- Live sync console → Admin actions: requests sync (evidence: `src/components/admin-console.tsx`)
- Admin actions → Auth configuration: checks admin (evidence: `src/lib/actions/admin.ts`)
- Admin actions → Sync orchestrator: starts sync (evidence: `src/lib/actions/admin.ts`)
- Admin actions → Application database: reads stats and logs (evidence: `src/lib/actions/admin.ts`)
- Admin page → Admin actions: loads admin data (evidence: `src/app/admin/page.tsx`)
- Sync log endpoint → Auth configuration: checks identity (evidence: `src/app/api/admin/logs/route.ts`)
- Sync log endpoint → Application database: reads logs (evidence: `src/app/api/admin/logs/route.ts`)
- Sync orchestrator → Mock feed: fetches mock feed (evidence: `src/lib/engine/syncEngine.ts`)
- Sync orchestrator → Playwright scraper: fetches scrape feed (evidence: `src/lib/engine/syncEngine.ts`)
- Playwright scraper → Configured scrape sites: scrapes configured targets (evidence: `README.md`)
- Sync orchestrator → Product upsert: upserts each item (evidence: `src/lib/engine/syncEngine.ts`)
- Sync orchestrator → Application database: writes sync logs (evidence: `src/lib/engine/syncEngine.ts`)
- Product upsert → Application database: updates products and history
- Price trend calculation → Application database: uses price history
