# ammar0dh/travehub architecture

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

- Interactive diagram: https://gitdiagram.com/ammar0dh/travehub
- Repository: https://github.com/ammar0dh/travehub

## Overview

TraveHub is a bilingual travel discovery and affiliate-booking site for Gulf travelers. Visitors search travel options, explore destination and service guides, and follow tracked links to booking providers; the site also offers AI chat and itinerary planning. The map includes the documented affiliate conversion loop and consent-gated analytics. Source excerpts are partial, so uncertain wiring—such as which pages call the live-prices endpoint—is omitted.

Main entry points: [`index.html`](https://github.com/ammar0dh/travehub/blob/main/index.html) (Travel homepage), [`functions/go/[slug].js`](https://github.com/ammar0dh/travehub/blob/main/functions/go/%5Bslug%5D.js) (Affiliate redirect), [`functions/api/postback.js`](https://github.com/ammar0dh/travehub/blob/main/functions/api/postback.js) (Conversion postback), [`services.html`](https://github.com/ammar0dh/travehub/blob/main/services.html) (Travel services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Travel discovery"]
  node_home["Travel homepage<br/>[index.html]"]
  node_destinations["Destination guides<br/>[destinations.html]"]
  node_guides["City guides<br/>[guide-cairo.html]"]
  node_services["Travel services<br/>[services.html]"]
  node_service_registry["Service registry"]
  node_home_runtime["Site interactions<br/>[site.js]"]
  node_subpage_runtime["Guide interactions<br/>[pages.js]"]
end

subgraph group_planning["Trip planning"]
  node_ai_ui["AI assistant<br/>[ai.js]"]
  node_ai_api["AI chat API<br/>[ai-chat.js]"]
end

subgraph group_affiliate["Affiliate bookings"]
  node_affiliate_map["Affiliate map<br/>[affiliates.js]"]
  node_redirect["Affiliate redirect<br/>[&#91;slug&#93;.js]"]
  node_click_store[("Click records")]
  node_postback["Conversion postback<br/>[postback.js]"]
  node_conversion_store[("Conversion records")]
end

subgraph group_edge["Edge services"]
  node_flight_prices["Live flight prices<br/>[prices.js]"]
  node_consent["Consent and trackers<br/>[consent.js]"]
  node_middleware["Request middleware<br/>[_middleware.js]"]
end

node_traveler(("Traveler"))
node_anthropic{{"Anthropic API"}}
node_booking_provider{{"Booking providers"}}
node_affiliate_network{{"Affiliate networks"}}
node_analytics{{"Analytics trackers"}}

node_traveler -->|"opens"| node_home
node_traveler -->|"browses"| node_destinations
node_traveler -->|"reads"| node_guides
node_traveler -->|"browses"| node_services
node_home -->|"loads interactions"| node_home_runtime
node_services -->|"uses data"| node_service_registry
node_traveler -->|"asks"| node_ai_ui
node_ai_ui -->|"sends messages"| node_ai_api
node_ai_api -->|"requests responses"| node_anthropic
node_home -->|"uses affiliate links"| node_affiliate_map
node_traveler -->|"follows /go link"| node_redirect
node_redirect -->|"redirects to"| node_booking_provider
node_redirect -->|"logs click"| node_click_store
node_affiliate_network -->|"sends conversion"| node_postback
node_postback -->|"looks up click"| node_click_store
node_postback -->|"stores conversion"| node_conversion_store
node_home -->|"loads consent"| node_consent
node_consent -->|"loads after consent"| node_analytics
node_traveler -->|"requests pages"| node_middleware
node_middleware -->|"serves or redirects"| node_home

click node_home "https://github.com/ammar0dh/travehub/blob/main/index.html"
click node_destinations "https://github.com/ammar0dh/travehub/blob/main/destinations.html"
click node_guides "https://github.com/ammar0dh/travehub/blob/main/guide-cairo.html"
click node_services "https://github.com/ammar0dh/travehub/blob/main/services.html"
click node_service_registry "https://github.com/ammar0dh/travehub/blob/main/service-destinations.js"
click node_home_runtime "https://github.com/ammar0dh/travehub/blob/main/site.js"
click node_subpage_runtime "https://github.com/ammar0dh/travehub/blob/main/pages.js"
click node_ai_ui "https://github.com/ammar0dh/travehub/blob/main/ai.js"
click node_ai_api "https://github.com/ammar0dh/travehub/blob/main/functions/api/ai-chat.js"
click node_flight_prices "https://github.com/ammar0dh/travehub/blob/main/functions/api/prices.js"
click node_affiliate_map "https://github.com/ammar0dh/travehub/blob/main/affiliates.js"
click node_redirect "https://github.com/ammar0dh/travehub/blob/main/functions/go/%5Bslug%5D.js"
click node_click_store "https://github.com/ammar0dh/travehub/blob/main/supabase/migrations/20260925000000_create_clicks_and_conversions.sql"
click node_postback "https://github.com/ammar0dh/travehub/blob/main/functions/api/postback.js"
click node_conversion_store "https://github.com/ammar0dh/travehub/blob/main/supabase/migrations/20260925010000_add_conversion_order_id.sql"
click node_consent "https://github.com/ammar0dh/travehub/blob/main/consent.js"
click node_middleware "https://github.com/ammar0dh/travehub/blob/main/functions/_middleware.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_home,node_destinations,node_guides,node_services,node_service_registry,node_home_runtime,node_subpage_runtime toneBlue
class node_ai_ui,node_ai_api toneAmber
class node_affiliate_map,node_redirect,node_click_store,node_postback,node_conversion_store,node_anthropic toneMint
class node_flight_prices,node_consent,node_middleware toneRose
class node_traveler,node_booking_provider,node_affiliate_network,node_analytics toneIndigo
```

## Components

### Travel discovery

- [Travel homepage](https://github.com/ammar0dh/travehub/blob/main/index.html): `index.html`
- [Destination guides](https://github.com/ammar0dh/travehub/blob/main/destinations.html): `destinations.html`
- [City guides](https://github.com/ammar0dh/travehub/blob/main/guide-cairo.html): `guide-cairo.html`
- [Travel services](https://github.com/ammar0dh/travehub/blob/main/services.html): `services.html`
- [Service registry](https://github.com/ammar0dh/travehub/blob/main/service-destinations.js): `service-destinations.js`
- [Site interactions](https://github.com/ammar0dh/travehub/blob/main/site.js): `site.js`
- [Guide interactions](https://github.com/ammar0dh/travehub/blob/main/pages.js): `pages.js`

### Trip planning

- [AI assistant](https://github.com/ammar0dh/travehub/blob/main/ai.js): `ai.js`
- [AI chat API](https://github.com/ammar0dh/travehub/blob/main/functions/api/ai-chat.js): `functions/api/ai-chat.js`

### Affiliate bookings

- [Affiliate map](https://github.com/ammar0dh/travehub/blob/main/affiliates.js): `affiliates.js`
- [Affiliate redirect](https://github.com/ammar0dh/travehub/blob/main/functions/go/%5Bslug%5D.js): `functions/go/[slug].js`
- [Click records](https://github.com/ammar0dh/travehub/blob/main/supabase/migrations/20260925000000_create_clicks_and_conversions.sql): `supabase/migrations/20260925000000_create_clicks_and_conversions.sql`
- [Conversion postback](https://github.com/ammar0dh/travehub/blob/main/functions/api/postback.js): `functions/api/postback.js`
- [Conversion records](https://github.com/ammar0dh/travehub/blob/main/supabase/migrations/20260925010000_add_conversion_order_id.sql): `supabase/migrations/20260925010000_add_conversion_order_id.sql`

### Edge services

- [Live flight prices](https://github.com/ammar0dh/travehub/blob/main/functions/api/prices.js): `functions/api/prices.js`
- [Consent and trackers](https://github.com/ammar0dh/travehub/blob/main/consent.js): `consent.js`
- [Request middleware](https://github.com/ammar0dh/travehub/blob/main/functions/_middleware.js): `functions/_middleware.js`

### Other components

- **Traveler**
- **Anthropic API**
- **Booking providers**
- **Affiliate networks**
- **Analytics trackers**

## Connections

- Traveler → Travel homepage: opens
- Traveler → Destination guides: browses
- Traveler → City guides: reads
- Traveler → Travel services: browses
- Travel homepage → Site interactions: loads interactions
- Travel services → Service registry: uses data
- Traveler → AI assistant: asks
- AI assistant → AI chat API: sends messages
- AI chat API → Anthropic API: requests responses
- Travel homepage → Affiliate map: uses affiliate links
- Traveler → Affiliate redirect: follows /go link
- Affiliate redirect → Booking providers: redirects to
- Affiliate redirect → Click records: logs click
- Affiliate networks → Conversion postback: sends conversion
- Conversion postback → Click records: looks up click
- Conversion postback → Conversion records: stores conversion
- Travel homepage → Consent and trackers: loads consent
- Consent and trackers → Analytics trackers: loads after consent
- Traveler → Request middleware: requests pages
- Request middleware → Travel homepage: serves or redirects
