# chifie/sokodigital_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/chifie/sokodigital_frontend
- Repository: https://github.com/chifie/sokodigital_frontend

## Overview

SokoDigital is a Tanzania-focused buyer-and-seller marketplace. Buyers discover products, inspect listings, maintain a cart or wishlist, check out, and track orders; sellers onboard and manage listings and storefronts, while administrators moderate and review marketplace activity. The React app routes these experiences through page components, with shared state, mock catalog data, and optional Supabase services. README documents the broader feature set; some page and backend internals were not sampled, so those connections are shown only where the README or indexed references support them.

Main entry points: [`src/App.tsx`](https://github.com/chifie/sokodigital_frontend/blob/main/src/App.tsx) (Route application), [`src/components/product/ProductCard.tsx`](https://github.com/chifie/sokodigital_frontend/blob/main/src/components/product/ProductCard.tsx) (Product cards), [`src/pages/ProductDetailPage.tsx`](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/ProductDetailPage.tsx) (Product details), [`src/lib/cart-context.tsx`](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/cart-context.tsx) (Cart state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and discovery"]
  node_app["Route application<br/>[App.tsx]"]
  node_landing["Home and deals<br/>[Landing.tsx]"]
  node_catalog["Browse catalog"]
  node_product["Product details"]
  node_categories["Categories and shops<br/>[CategoriesPage.tsx]"]
  node_deals["Promotions<br/>[DealsPage.tsx]"]
  node_productcard["Product cards<br/>[ProductCard.tsx]"]
  node_catalogdata["Mock catalog data<br/>[constants.ts]"]
end

subgraph group_commerce["Buyer commerce"]
  node_cart["Cart state<br/>[cart-context.tsx]"]
  node_cartpage["Cart and checkout<br/>[CartPage.tsx]"]
  node_checkout["Checkout<br/>[CheckoutPage.tsx]"]
  node_orders["Order tracking"]
  node_wishlist["Wishlist"]
end

subgraph group_accounts["Accounts and operations"]
  node_auth["Authentication<br/>[auth.tsx]"]
  node_authpage["Login and signup<br/>[AuthPage.tsx]"]
  node_dashboard["Buyer dashboard<br/>[DashboardPage.tsx]"]
  node_seller["Seller management"]
  node_sellerlistings["Seller listings"]
  node_sellerform["Listing editor"]
  node_store["Seller storefront<br/>[StorePage.tsx]"]
  node_messaging["Buyer messaging<br/>[MessagesPage.tsx]"]
  node_admin["Admin dashboard"]
end

subgraph group_services["Shared services"]
  node_ai["AI assistant<br/>[AIWidget.tsx]"]
  node_aichat["AI chat page<br/>[AIChatPage.tsx]"]
  node_aifunction["AI edge function<br/>[index.ts]"]
  node_aigateway["AI gateway<br/>[ai-gateway.ts]"]
  node_supabase["Supabase client<br/>[client.ts]"]
  node_newsletter["Newsletter signup<br/>[Footer.tsx]"]
  node_newsletterfn["Newsletter function<br/>[index.ts]"]
  node_language["Language support<br/>[i18n.tsx]"]
  node_theme["Theme support<br/>[use-theme.tsx]"]
end

node_visitor(("Buyer or seller"))

node_visitor -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_product
node_app -->|"routes to"| node_categories
node_app -->|"routes to"| node_deals
node_app -->|"routes to"| node_cartpage
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_orders
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_seller
node_app -->|"routes to"| node_sellerlistings
node_app -->|"routes to"| node_sellerform
node_app -->|"routes to"| node_store
node_app -->|"routes to"| node_messaging
node_app -->|"routes to"| node_admin
node_app -->|"routes to"| node_aichat
node_landing -->|"renders"| node_productcard
node_catalog -->|"renders"| node_productcard
node_product -->|"renders"| node_productcard
node_landing -->|"reads"| node_catalogdata
node_catalog -->|"reads"| node_catalogdata
node_product -->|"reads"| node_catalogdata
node_productcard -->|"updates"| node_cart
node_product -->|"updates"| node_cart
node_cartpage -->|"uses state"| node_cart
node_checkout -->|"uses state"| node_cart
node_checkout -.->|"creates order"| node_orders
node_productcard -.->|"supports saving"| node_wishlist
node_authpage -->|"authenticates"| node_auth
node_auth -->|"reads roles"| node_supabase
node_dashboard -.->|"uses identity"| node_auth
node_seller -.->|"manages listings"| node_sellerlistings
node_sellerlistings -.->|"edits listings"| node_sellerform
node_seller -.->|"publishes storefront"| node_store
node_ai -->|"uses client"| node_supabase
node_aichat -->|"requests answers"| node_aifunction
node_ai -.->|"requests answers"| node_aifunction
node_aifunction -->|"delegates"| node_aigateway
node_newsletter -->|"submits signup"| node_newsletterfn
node_newsletter -->|"uses client"| node_supabase
node_language -->|"localizes interface"| node_visitor
node_theme -->|"sets appearance"| node_visitor

click node_app "https://github.com/chifie/sokodigital_frontend/blob/main/src/App.tsx"
click node_landing "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/Landing.tsx"
click node_catalog "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/MarketplacePage.tsx"
click node_product "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/ProductDetailPage.tsx"
click node_categories "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CategoriesPage.tsx"
click node_deals "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/DealsPage.tsx"
click node_productcard "https://github.com/chifie/sokodigital_frontend/blob/main/src/components/product/ProductCard.tsx"
click node_catalogdata "https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/constants.ts"
click node_cart "https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/cart-context.tsx"
click node_cartpage "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CartPage.tsx"
click node_checkout "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CheckoutPage.tsx"
click node_orders "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/OrderConfirmationPage.tsx"
click node_wishlist "https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/wishlist-context.tsx"
click node_auth "https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/auth.tsx"
click node_authpage "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AuthPage.tsx"
click node_dashboard "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/DashboardPage.tsx"
click node_seller "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerOnboardingPage.tsx"
click node_sellerlistings "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerListingsPage.tsx"
click node_sellerform "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerProductFormPage.tsx"
click node_store "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/StorePage.tsx"
click node_messaging "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/MessagesPage.tsx"
click node_admin "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AdminDashboardPage.tsx"
click node_ai "https://github.com/chifie/sokodigital_frontend/blob/main/src/components/site/AIWidget.tsx"
click node_aichat "https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AIChatPage.tsx"
click node_aifunction "https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/soko-ai/index.ts"
click node_aigateway "https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/_shared/ai-gateway.ts"
click node_supabase "https://github.com/chifie/sokodigital_frontend/blob/main/src/integrations/supabase/client.ts"
click node_newsletter "https://github.com/chifie/sokodigital_frontend/blob/main/src/components/layout/Footer.tsx"
click node_newsletterfn "https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/newsletter-subscribe/index.ts"
click node_language "https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/i18n.tsx"
click node_theme "https://github.com/chifie/sokodigital_frontend/blob/main/src/hooks/use-theme.tsx"

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_app,node_landing,node_catalog,node_product,node_categories,node_deals,node_productcard,node_catalogdata toneBlue
class node_cart,node_cartpage,node_checkout,node_orders,node_wishlist toneAmber
class node_auth,node_authpage,node_dashboard,node_seller,node_sellerlistings,node_sellerform,node_store,node_messaging,node_admin toneMint
class node_ai,node_aichat,node_aifunction,node_aigateway,node_supabase,node_newsletter,node_newsletterfn,node_language,node_theme toneRose
class node_visitor toneIndigo
```

## Components

### App and discovery

- [Route application](https://github.com/chifie/sokodigital_frontend/blob/main/src/App.tsx): `src/App.tsx`
- [Home and deals](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/Landing.tsx): `src/pages/Landing.tsx`
- [Browse catalog](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/MarketplacePage.tsx): `src/pages/MarketplacePage.tsx`
- [Product details](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/ProductDetailPage.tsx): `src/pages/ProductDetailPage.tsx`
- [Categories and shops](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CategoriesPage.tsx): `src/pages/CategoriesPage.tsx`
- [Promotions](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/DealsPage.tsx): `src/pages/DealsPage.tsx`
- [Product cards](https://github.com/chifie/sokodigital_frontend/blob/main/src/components/product/ProductCard.tsx): `src/components/product/ProductCard.tsx`
- [Mock catalog data](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/constants.ts): `src/lib/constants.ts`

### Buyer commerce

- [Cart state](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/cart-context.tsx): `src/lib/cart-context.tsx`
- [Cart and checkout](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CartPage.tsx): `src/pages/CartPage.tsx`
- [Checkout](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/CheckoutPage.tsx): `src/pages/CheckoutPage.tsx`
- [Order tracking](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/OrderConfirmationPage.tsx): `src/pages/OrderConfirmationPage.tsx`
- [Wishlist](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/wishlist-context.tsx): `src/lib/wishlist-context.tsx`

### Accounts and operations

- [Authentication](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/auth.tsx): `src/lib/auth.tsx`
- [Login and signup](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AuthPage.tsx): `src/pages/AuthPage.tsx`
- [Buyer dashboard](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Seller management](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerOnboardingPage.tsx): `src/pages/SellerOnboardingPage.tsx`
- [Seller listings](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerListingsPage.tsx): `src/pages/SellerListingsPage.tsx`
- [Listing editor](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/SellerProductFormPage.tsx): `src/pages/SellerProductFormPage.tsx`
- [Seller storefront](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/StorePage.tsx): `src/pages/StorePage.tsx`
- [Buyer messaging](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/MessagesPage.tsx): `src/pages/MessagesPage.tsx`
- [Admin dashboard](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AdminDashboardPage.tsx): `src/pages/AdminDashboardPage.tsx`

### Shared services

- [AI assistant](https://github.com/chifie/sokodigital_frontend/blob/main/src/components/site/AIWidget.tsx): `src/components/site/AIWidget.tsx`
- [AI chat page](https://github.com/chifie/sokodigital_frontend/blob/main/src/pages/AIChatPage.tsx): `src/pages/AIChatPage.tsx`
- [AI edge function](https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/soko-ai/index.ts): `supabase/functions/soko-ai/index.ts`
- [AI gateway](https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/_shared/ai-gateway.ts): `supabase/functions/_shared/ai-gateway.ts`
- [Supabase client](https://github.com/chifie/sokodigital_frontend/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Newsletter signup](https://github.com/chifie/sokodigital_frontend/blob/main/src/components/layout/Footer.tsx): `src/components/layout/Footer.tsx`
- [Newsletter function](https://github.com/chifie/sokodigital_frontend/blob/main/supabase/functions/newsletter-subscribe/index.ts): `supabase/functions/newsletter-subscribe/index.ts`
- [Language support](https://github.com/chifie/sokodigital_frontend/blob/main/src/lib/i18n.tsx): `src/lib/i18n.tsx`
- [Theme support](https://github.com/chifie/sokodigital_frontend/blob/main/src/hooks/use-theme.tsx): `src/hooks/use-theme.tsx`

### Other components

- **Buyer or seller**

## Connections

- Buyer or seller → Route application: opens (evidence: `src/App.tsx`)
- Route application → Home and deals: routes to (evidence: `src/App.tsx`)
- Route application → Browse catalog: routes to (evidence: `src/App.tsx`)
- Route application → Product details: routes to (evidence: `src/App.tsx`)
- Route application → Categories and shops: routes to (evidence: `src/App.tsx`)
- Route application → Promotions: routes to (evidence: `README.md`)
- Route application → Cart and checkout: routes to (evidence: `README.md`)
- Route application → Checkout: routes to (evidence: `README.md`)
- Route application → Order tracking: routes to (evidence: `README.md`)
- Route application → Login and signup: routes to (evidence: `README.md`)
- Route application → Buyer dashboard: routes to (evidence: `README.md`)
- Route application → Seller management: routes to (evidence: `src/App.tsx`)
- Route application → Seller listings: routes to (evidence: `README.md`)
- Route application → Listing editor: routes to (evidence: `README.md`)
- Route application → Seller storefront: routes to (evidence: `README.md`)
- Route application → Buyer messaging: routes to (evidence: `README.md`)
- Route application → Admin dashboard: routes to (evidence: `src/App.tsx`)
- Route application → AI chat page: routes to (evidence: `README.md`)
- Home and deals → Product cards: renders (evidence: `src/pages/Landing.tsx`)
- Browse catalog → Product cards: renders (evidence: `src/pages/MarketplacePage.tsx`)
- Product details → Product cards: renders (evidence: `src/pages/ProductDetailPage.tsx`)
- Home and deals → Mock catalog data: reads (evidence: `src/pages/Landing.tsx`)
- Browse catalog → Mock catalog data: reads (evidence: `src/pages/MarketplacePage.tsx`)
- Product details → Mock catalog data: reads (evidence: `src/pages/ProductDetailPage.tsx`)
- Product cards → Cart state: updates (evidence: `src/components/product/ProductCard.tsx`)
- Product details → Cart state: updates (evidence: `src/pages/ProductDetailPage.tsx`)
- Cart and checkout → Cart state: uses state (evidence: `README.md`)
- Checkout → Cart state: uses state (evidence: `README.md`)
- Checkout → Order tracking: creates order
- Product cards → Wishlist: supports saving
- Login and signup → Authentication: authenticates (evidence: `src/pages/AuthPage.tsx`)
- Authentication → Supabase client: reads roles (evidence: `src/lib/auth.tsx`)
- Buyer dashboard → Authentication: uses identity
- Seller management → Seller listings: manages listings
- Seller listings → Listing editor: edits listings
- Seller management → Seller storefront: publishes storefront
- AI assistant → Supabase client: uses client (evidence: `src/components/site/AIWidget.tsx`)
- AI chat page → AI edge function: requests answers (evidence: `README.md`)
- AI assistant → AI edge function: requests answers
- AI edge function → AI gateway: delegates (evidence: `supabase/functions/soko-ai/index.ts`)
- Newsletter signup → Newsletter function: submits signup (evidence: `README.md`)
- Newsletter signup → Supabase client: uses client (evidence: `src/components/layout/Footer.tsx`)
- Language support → Buyer or seller: localizes interface (evidence: `README.md`)
- Theme support → Buyer or seller: sets appearance (evidence: `README.md`)
