# hasanasiabd/affiliate-template-pro architecture

> Architecture diagram of the GitHub repository hasanasiabd/affiliate-template-pro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hasanasiabd/affiliate-template-pro
- Repository: https://github.com/hasanasiabd/affiliate-template-pro

## Overview

DevGear Pro is a Next.js affiliate-review site with a JSON-file catalog, product discovery and reviews, comparison, buying guides, and a Gemini shopping assistant. Visitors browse and filter products, inspect reviews or compare up to three items, then follow affiliate links; the chat API separately grounds recommendations in the catalog. Admins configure products, site settings, pixels, and AI behavior through protected tools, with changes stored in JSON and optionally synced to GitHub. The tree and README establish several capabilities whose internal wiring was not sampled, so those links are documented rather than inferred from imports.

Main entry points: [`src/app/products/[slug]/page.tsx`](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/products/%5Bslug%5D/page.tsx) (Product review), [`src/lib/admin/fileStorage.ts`](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/fileStorage.ts) (JSON file storage), [`src/app/compare/page.tsx`](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/compare/page.tsx) (Compare page), [`src/components/compare/SideBySideTable.tsx`](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/compare/SideBySideTable.tsx) (Comparison table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Product discovery"]
  node_home["Home catalog<br/>[page.tsx]"]
  node_search["Search and filters"]
  node_productcard["Product cards<br/>[ProductCard.tsx]"]
  node_comparepage["Compare page<br/>[page.tsx]"]
  node_comparetray["Compare selection"]
  node_comparison["Comparison table"]
end

subgraph group_content["Reviews and guides"]
  node_productreview["Product review<br/>[page.tsx]"]
  node_reviewheader["Review header<br/>[ReviewHeader.tsx]"]
  node_blog["Buying guides<br/>[page.tsx]"]
end

subgraph group_assistant["AI concierge"]
  node_chatwidget["Chat widget<br/>[ChatWidget.tsx]"]
  node_chatapi["Chat API<br/>[route.ts]"]
  node_prompt["Catalog prompt<br/>[buildPrompt.ts]"]
  node_gemini["Gemini client<br/>[geminiClient.ts]"]
end

subgraph group_management["Admin and data"]
  node_admin["Admin studio"]
  node_adminforms["Admin forms"]
  node_saveconfig["Config save API<br/>[route.ts]"]
  node_saveproduct["Product save API<br/>[route.ts]"]
  node_auth["Admin sessions<br/>[authSession.ts]"]
  node_storage["JSON file storage<br/>[fileStorage.ts]"]
  node_github["GitHub sync<br/>[githubSync.ts]"]
  node_tracking["Click tracking<br/>[route.ts]"]
  node_jsondata[("JSON content store")]
end

subgraph group_platform["Site platform"]
  node_layout["Shared site layout<br/>[layout.tsx]"]
  node_pixels["Analytics pixels"]
  node_seo["SEO metadata"]
end

node_visitor(("Visitor"))
node_affiliate["Affiliate retailer"]
node_githubservice["GitHub API"]

node_visitor -->|"browses"| node_home
node_home -->|"renders"| node_search
node_search -->|"renders results"| node_productcard
node_visitor -->|"compares gear"| node_comparepage
node_comparepage -->|"renders"| node_comparetray
node_comparepage -->|"renders"| node_comparison
node_comparison -->|"links reviews"| node_productreview
node_comparison -->|"links to retailer"| node_affiliate
node_visitor -->|"reads review"| node_productreview
node_productreview -->|"renders"| node_reviewheader
node_visitor -->|"reads guides"| node_blog
node_visitor -->|"asks advice"| node_chatwidget
node_chatwidget -->|"sends messages"| node_chatapi
node_chatapi -->|"builds prompt"| node_prompt
node_chatapi -->|"requests response"| node_gemini
node_admin -.->|"offers controls"| node_adminforms
node_adminforms -->|"submits settings"| node_saveconfig
node_saveconfig -->|"writes config"| node_storage
node_saveproduct -->|"writes product"| node_storage
node_storage -->|"reads and writes"| node_jsondata
node_saveconfig -->|"syncs changes"| node_github
node_saveproduct -->|"syncs changes"| node_github
node_github -.->|"commits changes"| node_githubservice
node_admin -->|"protected by"| node_auth
node_visitor -.->|"clicks affiliate"| node_tracking
node_tracking -->|"updates counts"| node_storage
node_layout -.->|"includes tracking"| node_pixels
node_productreview -.->|"provides rich snippets"| node_seo

click node_home "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/page.tsx"
click node_search "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/home/SearchAndFilterBar.tsx"
click node_productcard "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/home/ProductCard.tsx"
click node_comparepage "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/compare/page.tsx"
click node_comparetray "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/compare/FloatingCompareTray.tsx"
click node_comparison "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/compare/SideBySideTable.tsx"
click node_productreview "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/products/%5Bslug%5D/page.tsx"
click node_reviewheader "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/product/ReviewHeader.tsx"
click node_blog "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/blog/page.tsx"
click node_chatwidget "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/chat/ChatWidget.tsx"
click node_chatapi "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/route.ts"
click node_prompt "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/ai/buildPrompt.ts"
click node_gemini "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/ai/geminiClient.ts"
click node_admin "https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/app/admin"
click node_adminforms "https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/components/admin"
click node_saveconfig "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/admin/save-config/route.ts"
click node_saveproduct "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/admin/save-product/route.ts"
click node_auth "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/authSession.ts"
click node_storage "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/fileStorage.ts"
click node_github "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/githubSync.ts"
click node_tracking "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/track-click/route.ts"
click node_jsondata "https://github.com/hasanasiabd/affiliate-template-pro/tree/main/data"
click node_layout "https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/layout.tsx"
click node_pixels "https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/components/tracking"
click node_seo "https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/lib/schema"

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_search,node_productcard,node_comparepage,node_comparetray,node_comparison toneBlue
class node_productreview,node_reviewheader,node_blog toneAmber
class node_chatwidget,node_chatapi,node_prompt,node_gemini,node_githubservice toneMint
class node_admin,node_adminforms,node_saveconfig,node_saveproduct,node_auth,node_storage,node_github,node_tracking,node_jsondata toneRose
class node_layout,node_pixels,node_seo,node_visitor,node_affiliate toneIndigo
```

## Components

### Product discovery

- [Home catalog](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Search and filters](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/home/SearchAndFilterBar.tsx): `src/components/home/SearchAndFilterBar.tsx`
- [Product cards](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/home/ProductCard.tsx): `src/components/home/ProductCard.tsx`
- [Compare page](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/compare/page.tsx): `src/app/compare/page.tsx`
- [Compare selection](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/compare/FloatingCompareTray.tsx): `src/components/compare/FloatingCompareTray.tsx`
- [Comparison table](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/compare/SideBySideTable.tsx): `src/components/compare/SideBySideTable.tsx`

### Reviews and guides

- [Product review](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/products/%5Bslug%5D/page.tsx): `src/app/products/[slug]/page.tsx`
- [Review header](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/product/ReviewHeader.tsx): `src/components/product/ReviewHeader.tsx`
- [Buying guides](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/blog/page.tsx): `src/app/blog/page.tsx`

### AI concierge

- [Chat widget](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/components/chat/ChatWidget.tsx): `src/components/chat/ChatWidget.tsx`
- [Chat API](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/route.ts): `src/app/api/route.ts`
- [Catalog prompt](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/ai/buildPrompt.ts): `src/lib/ai/buildPrompt.ts`
- [Gemini client](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/ai/geminiClient.ts): `src/lib/ai/geminiClient.ts`

### Admin and data

- [Admin studio](https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/app/admin): `src/app/admin`
- [Admin forms](https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/components/admin): `src/components/admin`
- [Config save API](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/admin/save-config/route.ts): `src/app/api/admin/save-config/route.ts`
- [Product save API](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/admin/save-product/route.ts): `src/app/api/admin/save-product/route.ts`
- [Admin sessions](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/authSession.ts): `src/lib/admin/authSession.ts`
- [JSON file storage](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/fileStorage.ts): `src/lib/admin/fileStorage.ts`
- [GitHub sync](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/lib/admin/githubSync.ts): `src/lib/admin/githubSync.ts`
- [Click tracking](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/api/track-click/route.ts): `src/app/api/track-click/route.ts`
- [JSON content store](https://github.com/hasanasiabd/affiliate-template-pro/tree/main/data): `data`

### Site platform

- [Shared site layout](https://github.com/hasanasiabd/affiliate-template-pro/blob/main/src/app/layout.tsx): `src/app/layout.tsx`
- [Analytics pixels](https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/components/tracking): `src/components/tracking`
- [SEO metadata](https://github.com/hasanasiabd/affiliate-template-pro/tree/main/src/lib/schema): `src/lib/schema`

### Other components

- **Visitor**
- **Affiliate retailer**
- **GitHub API**

## Connections

- Visitor → Home catalog: browses
- Home catalog → Search and filters: renders (evidence: `src/app/page.tsx`)
- Search and filters → Product cards: renders results (evidence: `src/components/home/SearchAndFilterBar.tsx`)
- Visitor → Compare page: compares gear
- Compare page → Compare selection: renders (evidence: `src/app/compare/page.tsx`)
- Compare page → Comparison table: renders (evidence: `src/app/compare/page.tsx`)
- Comparison table → Product review: links reviews (evidence: `src/components/compare/SideBySideTable.tsx`)
- Comparison table → Affiliate retailer: links to retailer (evidence: `src/components/compare/SideBySideTable.tsx`)
- Visitor → Product review: reads review
- Product review → Review header: renders (evidence: `src/components/product/ReviewHeader.tsx`)
- Visitor → Buying guides: reads guides
- Visitor → Chat widget: asks advice
- Chat widget → Chat API: sends messages (evidence: `src/components/chat/ChatWidget.tsx`)
- Chat API → Catalog prompt: builds prompt (evidence: `src/app/api/route.ts`)
- Chat API → Gemini client: requests response (evidence: `src/app/api/route.ts`)
- Admin studio → Admin forms: offers controls
- Admin forms → Config save API: submits settings (evidence: `src/components/admin/AiControllerForm.tsx`)
- Config save API → JSON file storage: writes config (evidence: `src/app/api/admin/save-config/route.ts`)
- Product save API → JSON file storage: writes product (evidence: `src/app/api/admin/save-product/route.ts`)
- JSON file storage → JSON content store: reads and writes (evidence: `src/lib/admin/fileStorage.ts`)
- Config save API → GitHub sync: syncs changes (evidence: `src/app/api/admin/save-config/route.ts`)
- Product save API → GitHub sync: syncs changes (evidence: `src/app/api/admin/save-product/route.ts`)
- GitHub sync → GitHub API: commits changes
- Admin studio → Admin sessions: protected by
- Visitor → Click tracking: clicks affiliate
- Click tracking → JSON file storage: updates counts (evidence: `src/app/api/track-click/route.ts`)
- Shared site layout → Analytics pixels: includes tracking
- Product review → SEO metadata: provides rich snippets
