# synapsecodeonline/ofertacoradar architecture

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

- Interactive diagram: https://gitdiagram.com/synapsecodeonline/ofertacoradar
- Repository: https://github.com/synapsecodeonline/ofertacoradar

## Overview

Ofertaço Radar aggregates affiliate products, coupons and offers into a searchable Brazilian shopping catalog. The main visitor journey is browsing and filtering the catalog, opening a product, then following an affiliate redirect that records a click. Separately, scheduled source synchronization imports and validates offers before storing them for the catalog. The map also preserves the documented admin, analytics, SEO/feed and Instagram-kit capabilities. Some routes and scheduled-job implementations were not sampled; those branches are included only where the README documents them.

Main entry points: [`src/lib/db.ts`](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/db.ts) (Product and event store), [`src/lib/syncer.ts`](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/syncer.ts) (Source synchronization), [`src/components/HomeExperience.tsx`](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/HomeExperience.tsx) (Catalog experience), [`src/app/ir/[id]/route.ts`](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/ir/%5Bid%5D/route.ts) (Affiliate redirect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Catalog experience"]
  node_home["Catalog page<br/>[page.tsx]"]
  node_catalog_ui["Catalog experience<br/>[HomeExperience.tsx]"]
  node_search["Search and filters<br/>[SearchBar.tsx]"]
  node_category_taxonomy["Category taxonomy<br/>[categories.ts]"]
  node_product_card["Product card<br/>[ProductCard.tsx]"]
  node_icons["UI icons<br/>[Icons.tsx]"]
  node_hash_navigation["Hash navigation<br/>[HashLink.tsx]"]
end

subgraph group_commerce["Product and conversion"]
  node_product_detail["Product detail<br/>[page.tsx]"]
  node_affiliate_redirect["Affiliate redirect<br/>[route.ts]"]
  node_shortener["Tracked-link shortener<br/>[shortener.ts]"]
  node_product_store[("Product and event store<br/>[db.ts]")]
end

subgraph group_ingestion["Offer ingestion"]
  node_sync_orchestrator["Source synchronization<br/>[syncer.ts]"]
  node_amazon_source["Amazon source<br/>[amazon.ts]"]
  node_awin_source["Awin source<br/>[awin.ts]"]
  node_mercadolivre_source["Mercado Livre source<br/>[mercadolivre.ts]"]
  node_lomadee_feed["Lomadee feed<br/>[feed.ts]"]
end

subgraph group_operations["Admin and analytics"]
  node_admin["Admin dashboard<br/>[page.tsx]"]
  node_admin_api["Admin endpoints<br/>[route.ts]"]
  node_admin_logic["Admin authorization<br/>[admin.ts]"]
  node_pageview_api["Pageview tracking<br/>[route.ts]"]
  node_click_analytics["Click tracking<br/>[route.ts]"]
end

subgraph group_publishing["Distribution and SEO"]
  node_instagram_kit["Instagram content kit<br/>[route.ts]"]
  node_social_card["Social card image<br/>[route.tsx]"]
  node_google_feed["Google Shopping feed<br/>[route.ts]"]
  node_sitemap_index["Sitemap index<br/>[route.ts]"]
  node_sitemap_pages["Page sitemap<br/>[route.ts]"]
end

node_visitor(("Shopper"))
node_google(("Google Merchant Center"))
node_affiliate_shops(("Affiliate merchants"))
node_scheduled_jobs(("Scheduled triggers"))
node_supabase_auth(("Supabase Auth"))

node_visitor -->|"browses"| node_home
node_home -->|"renders"| node_catalog_ui
node_catalog_ui -->|"queries catalog"| node_product_store
node_catalog_ui -->|"renders"| node_search
node_catalog_ui -->|"renders"| node_product_card
node_catalog_ui -->|"filters by category"| node_category_taxonomy
node_search -->|"scrolls after navigation"| node_hash_navigation
node_product_card -->|"renders"| node_icons
node_visitor -->|"opens product"| node_product_detail
node_product_detail -->|"loads product"| node_product_store
node_product_detail -->|"links to offer"| node_affiliate_redirect
node_visitor -->|"follows offer link"| node_affiliate_redirect
node_affiliate_redirect -->|"reads product and records click"| node_product_store
node_affiliate_redirect -->|"requests tracked URL"| node_shortener
node_affiliate_redirect -->|"redirects to merchant"| node_affiliate_shops
node_scheduled_jobs -->|"triggers sync"| node_sync_orchestrator
node_sync_orchestrator -->|"runs Amazon sync"| node_amazon_source
node_sync_orchestrator -->|"runs Awin sync"| node_awin_source
node_sync_orchestrator -->|"runs Mercado Livre sync"| node_mercadolivre_source
node_sync_orchestrator -->|"fetches Lomadee data"| node_lomadee_feed
node_sync_orchestrator -->|"updates catalog"| node_product_store
node_admin -->|"requires login"| node_supabase_auth
node_admin -->|"initiates sync"| node_admin_api
node_admin_api -->|"checks access"| node_admin_logic
node_admin_api -->|"starts sync"| node_sync_orchestrator
node_pageview_api -->|"records pageview"| node_product_store
node_click_analytics -->|"records click"| node_product_store
node_instagram_kit -->|"selects products"| node_product_store
node_instagram_kit -->|"provides card URL"| node_social_card
node_social_card -->|"loads product"| node_product_store
node_google_feed -->|"reads active products"| node_product_store
node_google_feed -->|"publishes feed"| node_google
node_sitemap_index -->|"counts active products"| node_product_store
node_sitemap_index -->|"lists page sitemap"| node_sitemap_pages

click node_home "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/page.tsx"
click node_catalog_ui "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/HomeExperience.tsx"
click node_search "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/SearchBar.tsx"
click node_category_taxonomy "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/categories.ts"
click node_product_card "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/ProductCard.tsx"
click node_icons "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/Icons.tsx"
click node_hash_navigation "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/HashLink.tsx"
click node_product_detail "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/produto/%5Bid%5D/page.tsx"
click node_affiliate_redirect "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/ir/%5Bid%5D/route.ts"
click node_shortener "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/shortener.ts"
click node_product_store "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/db.ts"
click node_sync_orchestrator "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/syncer.ts"
click node_amazon_source "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/amazon.ts"
click node_awin_source "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/awin.ts"
click node_mercadolivre_source "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/mercadolivre.ts"
click node_lomadee_feed "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/feed.ts"
click node_admin "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/admin/page.tsx"
click node_admin_api "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/admin/sync/route.ts"
click node_admin_logic "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/admin.ts"
click node_pageview_api "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/pv/route.ts"
click node_click_analytics "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/ir/%5Bid%5D/route.ts"
click node_instagram_kit "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/instagram/kit/route.ts"
click node_social_card "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/card/%5Bid%5D/route.tsx"
click node_google_feed "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/feed/google.xml/route.ts"
click node_sitemap_index "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/sitemap.xml/route.ts"
click node_sitemap_pages "https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/sitemaps/pages/route.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_ui,node_search,node_category_taxonomy,node_product_card,node_icons,node_hash_navigation toneBlue
class node_product_detail,node_affiliate_redirect,node_shortener,node_product_store toneAmber
class node_sync_orchestrator,node_amazon_source,node_awin_source,node_mercadolivre_source,node_lomadee_feed toneMint
class node_admin,node_admin_api,node_admin_logic,node_pageview_api,node_click_analytics toneRose
class node_instagram_kit,node_social_card,node_google_feed,node_sitemap_index,node_sitemap_pages,node_visitor,node_google,node_affiliate_shops,node_scheduled_jobs,node_supabase_auth toneIndigo
```

## Components

### Catalog experience

- [Catalog page](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Catalog experience](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/HomeExperience.tsx): `src/components/HomeExperience.tsx`
- [Search and filters](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/SearchBar.tsx): `src/components/SearchBar.tsx`
- [Category taxonomy](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/categories.ts): `src/lib/categories.ts`
- [Product card](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/ProductCard.tsx): `src/components/ProductCard.tsx`
- [UI icons](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/Icons.tsx): `src/components/Icons.tsx`
- [Hash navigation](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/components/HashLink.tsx): `src/components/HashLink.tsx`

### Product and conversion

- [Product detail](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/produto/%5Bid%5D/page.tsx): `src/app/produto/[id]/page.tsx`
- [Affiliate redirect](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/ir/%5Bid%5D/route.ts): `src/app/ir/[id]/route.ts`
- [Tracked-link shortener](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/shortener.ts): `src/lib/shortener.ts`
- [Product and event store](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Offer ingestion

- [Source synchronization](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/syncer.ts): `src/lib/syncer.ts`
- [Amazon source](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/amazon.ts): `src/lib/amazon.ts`
- [Awin source](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/awin.ts): `src/lib/awin.ts`
- [Mercado Livre source](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/mercadolivre.ts): `src/lib/mercadolivre.ts`
- [Lomadee feed](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/feed.ts): `src/lib/feed.ts`

### Admin and analytics

- [Admin dashboard](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Admin endpoints](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/admin/sync/route.ts): `src/app/api/admin/sync/route.ts`
- [Admin authorization](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/lib/admin.ts): `src/lib/admin.ts`
- [Pageview tracking](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/pv/route.ts): `src/app/api/pv/route.ts`
- [Click tracking](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/ir/%5Bid%5D/route.ts): `src/app/ir/[id]/route.ts`

### Distribution and SEO

- [Instagram content kit](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/instagram/kit/route.ts): `src/app/api/instagram/kit/route.ts`
- [Social card image](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/api/card/%5Bid%5D/route.tsx): `src/app/api/card/[id]/route.tsx`
- [Google Shopping feed](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/feed/google.xml/route.ts): `src/app/feed/google.xml/route.ts`
- [Sitemap index](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/sitemap.xml/route.ts): `src/app/sitemap.xml/route.ts`
- [Page sitemap](https://github.com/synapsecodeonline/ofertacoradar/blob/main/src/app/sitemaps/pages/route.ts): `src/app/sitemaps/pages/route.ts`

### Other components

- **Shopper**
- **Google Merchant Center**
- **Affiliate merchants**
- **Scheduled triggers**
- **Supabase Auth**

## Connections

- Shopper → Catalog page: browses
- Catalog page → Catalog experience: renders (evidence: `src/components/HomeExperience.tsx`)
- Catalog experience → Product and event store: queries catalog (evidence: `src/components/HomeExperience.tsx`)
- Catalog experience → Search and filters: renders (evidence: `src/components/HomeExperience.tsx`)
- Catalog experience → Product card: renders (evidence: `src/components/HomeExperience.tsx`)
- Catalog experience → Category taxonomy: filters by category (evidence: `src/components/HomeExperience.tsx`)
- Search and filters → Hash navigation: scrolls after navigation (evidence: `src/components/SearchBar.tsx`)
- Product card → UI icons: renders (evidence: `src/components/ProductCard.tsx`)
- Shopper → Product detail: opens product
- Product detail → Product and event store: loads product
- Product detail → Affiliate redirect: links to offer
- Shopper → Affiliate redirect: follows offer link
- Affiliate redirect → Product and event store: reads product and records click (evidence: `src/app/ir/[id]/route.ts`)
- Affiliate redirect → Tracked-link shortener: requests tracked URL (evidence: `src/app/ir/[id]/route.ts`)
- Affiliate redirect → Affiliate merchants: redirects to merchant
- Scheduled triggers → Source synchronization: triggers sync
- Source synchronization → Amazon source: runs Amazon sync (evidence: `src/lib/syncer.ts`)
- Source synchronization → Awin source: runs Awin sync (evidence: `src/lib/syncer.ts`)
- Source synchronization → Mercado Livre source: runs Mercado Livre sync (evidence: `src/lib/syncer.ts`)
- Source synchronization → Lomadee feed: fetches Lomadee data (evidence: `src/lib/syncer.ts`)
- Source synchronization → Product and event store: updates catalog (evidence: `src/lib/syncer.ts`)
- Admin dashboard → Supabase Auth: requires login
- Admin dashboard → Admin endpoints: initiates sync
- Admin endpoints → Admin authorization: checks access
- Admin endpoints → Source synchronization: starts sync
- Pageview tracking → Product and event store: records pageview (evidence: `src/app/api/pv/route.ts`)
- Click tracking → Product and event store: records click (evidence: `src/app/ir/[id]/route.ts`)
- Instagram content kit → Product and event store: selects products
- Instagram content kit → Social card image: provides card URL
- Social card image → Product and event store: loads product (evidence: `src/app/api/card/[id]/route.tsx`)
- Google Shopping feed → Product and event store: reads active products (evidence: `src/app/feed/google.xml/route.ts`)
- Google Shopping feed → Google Merchant Center: publishes feed
- Sitemap index → Product and event store: counts active products (evidence: `src/app/sitemap.xml/route.ts`)
- Sitemap index → Page sitemap: lists page sitemap
