# gcrndev/gami architecture

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

- Interactive diagram: https://gitdiagram.com/gcrndev/gami
- Repository: https://github.com/gcrndev/gami

## Overview

GÂMI is a commerce monorepo with independent storefront, affiliate, reviews, and messaging Workers plus Shopify utility packages. The main customer path is browsing and purchasing through the storefront; separate operational paths handle affiliate commissions and reviews. Reviews processes Shopify fulfillment events into review requests and delegates email delivery to messaging. This map preserves the documented finance, moderation, media, and commerce capabilities. Relationships are limited to the README and shown source/index references; unsampled internals are represented by their existing directories.

Main entry points: [`apps/affiliates/src/backend/worker.ts`](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/worker.ts) (Affiliate Worker), [`apps/reviews/src/worker.ts`](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/worker.ts) (Reviews Worker), [`apps/reviews/src/http/shopifyWebhook.ts`](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/http/shopifyWebhook.ts) (Fulfillment webhook handler), [`apps/affiliates/src/backend/admin/router.ts`](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/admin/router.ts) (Admin routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_storefront_worker["Storefront Worker<br/>[server.ts]"]
  node_store_ui["Storefront UI"]
  node_catalog_cart["Catalog and cart"]
  node_commerce_integrations["Commerce integrations"]
  node_storefront_events["Storefront workflows"]
end

subgraph group_affiliates["Affiliates"]
  node_affiliate_worker["Affiliate Worker<br/>[worker.ts]"]
  node_admin_router["Admin routes<br/>[router.ts]"]
  node_affiliate_portal["Creator portal"]
  node_commission_engine["Commission calculation<br/>[engine.ts]"]
  node_affiliate_shopify["Shopify order access<br/>[orderQuery.ts]"]
  node_affiliate_finance["Finance operations"]
  node_affiliate_store[("Affiliate data")]
end

subgraph group_reviews["Reviews"]
  node_reviews_worker["Reviews Worker<br/>[worker.ts]"]
  node_review_webhook["Fulfillment webhook handler<br/>[shopifyWebhook.ts]"]
  node_review_lifecycle["Request lifecycle<br/>[lifecycle.ts]"]
  node_review_features["Moderation, rewards, media"]
  node_review_store[("Review persistence")]
  node_messaging_client["Messaging client<br/>[client.ts]"]
end

subgraph group_messaging["Messaging"]
  node_messaging_worker["Messaging Worker<br/>[worker.ts]"]
  node_messaging_reviews["Review email routes<br/>[reviews.ts]"]
  node_email_templates["Email templates"]
  node_email_provider["Email provider<br/>[provider.ts]"]
end

subgraph group_shared["Shopify primitives"]
  node_shopify_admin_package["Shopify Admin primitives"]
  node_shopify_webhook_package["Webhook verification"]
end

node_shopper(("Shopper"))
node_affiliate_actor(("Affiliate admin or creator"))
node_review_customer(("Review customer"))
node_shopify_webhook(("Shopify webhook"))

node_shopper -->|"requests store"| node_storefront_worker
node_storefront_worker -->|"routes requests"| node_storefront_events
node_storefront_worker -.->|"renders pages"| node_store_ui
node_store_ui -.->|"presents products"| node_catalog_cart
node_catalog_cart -.->|"uses Shopify"| node_commerce_integrations
node_affiliate_actor -.->|"uses portal"| node_affiliate_worker
node_affiliate_worker -->|"routes admin"| node_admin_router
node_affiliate_worker -->|"routes creator"| node_affiliate_portal
node_admin_router -->|"reads and writes"| node_affiliate_store
node_admin_router -.->|"administers commissions"| node_commission_engine
node_admin_router -.->|"uses order data"| node_affiliate_shopify
node_affiliate_worker -->|"routes finance"| node_affiliate_finance
node_affiliate_worker -->|"uses API primitives"| node_shopify_admin_package
node_shopify_webhook -->|"sends event"| node_review_webhook
node_review_webhook -->|"verifies signature"| node_shopify_webhook_package
node_review_webhook -->|"creates request"| node_review_lifecycle
node_review_webhook -->|"records event"| node_review_store
node_reviews_worker -.->|"handles webhook"| node_review_webhook
node_reviews_worker -->|"dispatches requests"| node_review_lifecycle
node_reviews_worker -->|"handles review flows"| node_review_features
node_review_lifecycle -.->|"persists lifecycle"| node_review_store
node_review_lifecycle -.->|"requests email"| node_messaging_client
node_review_customer -.->|"submits review"| node_reviews_worker
node_messaging_client -->|"posts commands"| node_messaging_worker
node_messaging_worker -.->|"routes internal"| node_messaging_reviews
node_messaging_reviews -->|"renders email"| node_email_templates
node_messaging_reviews -.->|"sends email"| node_email_provider
node_messaging_reviews -->|"validates contract"| node_messaging_client
node_reviews_worker -->|"uses API primitives"| node_shopify_admin_package

click node_storefront_worker "https://github.com/gcrndev/gami/blob/main/apps/storefront/src/server.ts"
click node_store_ui "https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features"
click node_catalog_cart "https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features/product"
click node_commerce_integrations "https://github.com/gcrndev/gami/tree/main/apps/storefront/src/integrations/shopify"
click node_storefront_events "https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features"
click node_affiliate_worker "https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/worker.ts"
click node_admin_router "https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/admin/router.ts"
click node_affiliate_portal "https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/backend/portal"
click node_commission_engine "https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/domain/engine.ts"
click node_affiliate_shopify "https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/shopify/orderQuery.ts"
click node_affiliate_finance "https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/finance"
click node_affiliate_store "https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/backend/db"
click node_reviews_worker "https://github.com/gcrndev/gami/blob/main/apps/reviews/src/worker.ts"
click node_review_webhook "https://github.com/gcrndev/gami/blob/main/apps/reviews/src/http/shopifyWebhook.ts"
click node_review_lifecycle "https://github.com/gcrndev/gami/blob/main/apps/reviews/src/domain/requests/lifecycle.ts"
click node_review_features "https://github.com/gcrndev/gami/tree/main/apps/reviews/src/domain"
click node_review_store "https://github.com/gcrndev/gami/tree/main/apps/reviews/src/persistence"
click node_messaging_client "https://github.com/gcrndev/gami/blob/main/apps/reviews/src/integrations/messaging/client.ts"
click node_messaging_worker "https://github.com/gcrndev/gami/blob/main/apps/messaging/src/worker.ts"
click node_messaging_reviews "https://github.com/gcrndev/gami/blob/main/apps/messaging/src/http/reviews.ts"
click node_email_templates "https://github.com/gcrndev/gami/tree/main/apps/messaging/src/email/templates"
click node_email_provider "https://github.com/gcrndev/gami/blob/main/apps/messaging/src/email/provider.ts"
click node_shopify_admin_package "https://github.com/gcrndev/gami/tree/main/packages/shopify-admin/src"
click node_shopify_webhook_package "https://github.com/gcrndev/gami/tree/main/packages/shopify-webhooks/src"

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_storefront_worker,node_store_ui,node_catalog_cart,node_commerce_integrations,node_storefront_events,node_review_customer toneBlue
class node_affiliate_worker,node_admin_router,node_affiliate_portal,node_commission_engine,node_affiliate_shopify,node_affiliate_finance,node_affiliate_store toneAmber
class node_reviews_worker,node_review_webhook,node_review_lifecycle,node_review_features,node_review_store,node_messaging_client,node_shopify_webhook toneMint
class node_messaging_worker,node_messaging_reviews,node_email_templates,node_email_provider toneRose
class node_shopify_admin_package,node_shopify_webhook_package,node_shopper,node_affiliate_actor toneIndigo
```

## Components

### Storefront

- [Storefront Worker](https://github.com/gcrndev/gami/blob/main/apps/storefront/src/server.ts): `apps/storefront/src/server.ts`
- [Storefront UI](https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features): `apps/storefront/src/features`
- [Catalog and cart](https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features/product): `apps/storefront/src/features/product`
- [Commerce integrations](https://github.com/gcrndev/gami/tree/main/apps/storefront/src/integrations/shopify): `apps/storefront/src/integrations/shopify`
- [Storefront workflows](https://github.com/gcrndev/gami/tree/main/apps/storefront/src/features): `apps/storefront/src/features`

### Affiliates

- [Affiliate Worker](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/worker.ts): `apps/affiliates/src/backend/worker.ts`
- [Admin routes](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/admin/router.ts): `apps/affiliates/src/backend/admin/router.ts`
- [Creator portal](https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/backend/portal): `apps/affiliates/src/backend/portal`
- [Commission calculation](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/domain/engine.ts): `apps/affiliates/src/backend/domain/engine.ts`
- [Shopify order access](https://github.com/gcrndev/gami/blob/main/apps/affiliates/src/backend/shopify/orderQuery.ts): `apps/affiliates/src/backend/shopify/orderQuery.ts`
- [Finance operations](https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/finance): `apps/affiliates/src/finance`
- [Affiliate data](https://github.com/gcrndev/gami/tree/main/apps/affiliates/src/backend/db): `apps/affiliates/src/backend/db`

### Reviews

- [Reviews Worker](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/worker.ts): `apps/reviews/src/worker.ts`
- [Fulfillment webhook handler](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/http/shopifyWebhook.ts): `apps/reviews/src/http/shopifyWebhook.ts`
- [Request lifecycle](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/domain/requests/lifecycle.ts): `apps/reviews/src/domain/requests/lifecycle.ts`
- [Moderation, rewards, media](https://github.com/gcrndev/gami/tree/main/apps/reviews/src/domain): `apps/reviews/src/domain`
- [Review persistence](https://github.com/gcrndev/gami/tree/main/apps/reviews/src/persistence): `apps/reviews/src/persistence`
- [Messaging client](https://github.com/gcrndev/gami/blob/main/apps/reviews/src/integrations/messaging/client.ts): `apps/reviews/src/integrations/messaging/client.ts`

### Messaging

- [Messaging Worker](https://github.com/gcrndev/gami/blob/main/apps/messaging/src/worker.ts): `apps/messaging/src/worker.ts`
- [Review email routes](https://github.com/gcrndev/gami/blob/main/apps/messaging/src/http/reviews.ts): `apps/messaging/src/http/reviews.ts`
- [Email templates](https://github.com/gcrndev/gami/tree/main/apps/messaging/src/email/templates): `apps/messaging/src/email/templates`
- [Email provider](https://github.com/gcrndev/gami/blob/main/apps/messaging/src/email/provider.ts): `apps/messaging/src/email/provider.ts`

### Shopify primitives

- [Shopify Admin primitives](https://github.com/gcrndev/gami/tree/main/packages/shopify-admin/src): `packages/shopify-admin/src`
- [Webhook verification](https://github.com/gcrndev/gami/tree/main/packages/shopify-webhooks/src): `packages/shopify-webhooks/src`

### Other components

- **Shopper**
- **Affiliate admin or creator**
- **Review customer**
- **Shopify webhook**

## Connections

- Shopper → Storefront Worker: requests store (evidence: `README.md`)
- Storefront Worker → Storefront workflows: routes requests (evidence: `apps/storefront/src/server.ts`)
- Storefront Worker → Storefront UI: renders pages (evidence: `apps/storefront/src/server.ts`)
- Storefront UI → Catalog and cart: presents products
- Catalog and cart → Commerce integrations: uses Shopify
- Affiliate admin or creator → Affiliate Worker: uses portal
- Affiliate Worker → Admin routes: routes admin (evidence: `apps/affiliates/src/backend/worker.ts`)
- Affiliate Worker → Creator portal: routes creator (evidence: `apps/affiliates/src/backend/worker.ts`)
- Admin routes → Affiliate data: reads and writes (evidence: `apps/affiliates/src/backend/admin/router.ts`)
- Admin routes → Commission calculation: administers commissions
- Admin routes → Shopify order access: uses order data (evidence: `apps/affiliates/src/backend/admin/router.ts`)
- Affiliate Worker → Finance operations: routes finance (evidence: `apps/affiliates/src/backend/worker.ts`)
- Affiliate Worker → Shopify Admin primitives: uses API primitives
- Shopify webhook → Fulfillment webhook handler: sends event (evidence: `apps/reviews/src/http/shopifyWebhook.ts`)
- Fulfillment webhook handler → Webhook verification: verifies signature (evidence: `apps/reviews/src/http/shopifyWebhook.ts`)
- Fulfillment webhook handler → Request lifecycle: creates request (evidence: `apps/reviews/src/http/shopifyWebhook.ts`)
- Fulfillment webhook handler → Review persistence: records event (evidence: `apps/reviews/src/http/shopifyWebhook.ts`)
- Reviews Worker → Fulfillment webhook handler: handles webhook (evidence: `apps/reviews/src/worker.ts`)
- Reviews Worker → Request lifecycle: dispatches requests (evidence: `apps/reviews/src/worker.ts`)
- Reviews Worker → Moderation, rewards, media: handles review flows (evidence: `apps/reviews/src/worker.ts`)
- Request lifecycle → Review persistence: persists lifecycle (evidence: `apps/reviews/src/domain/requests/lifecycle.ts`)
- Request lifecycle → Messaging client: requests email (evidence: `apps/reviews/src/domain/requests/lifecycle.ts`)
- Review customer → Reviews Worker: submits review
- Messaging client → Messaging Worker: posts commands (evidence: `apps/reviews/src/integrations/messaging/client.ts`)
- Messaging Worker → Review email routes: routes internal
- Review email routes → Email templates: renders email (evidence: `apps/messaging/src/http/reviews.ts`)
- Review email routes → Email provider: sends email (evidence: `apps/messaging/src/http/reviews.ts`)
- Review email routes → Messaging client: validates contract (evidence: `apps/messaging/src/http/reviews.ts`)
- Reviews Worker → Shopify Admin primitives: uses API primitives (evidence: `apps/reviews/src/worker.ts`)
