# sanketp27/offgridai architecture

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

- Interactive diagram: https://gitdiagram.com/sanketp27/offgridai
- Repository: https://github.com/sanketp27/offgridai

## Overview

OffgridAI’s checked-in runtime is primarily a Next.js commerce experience: shoppers search a catalog, choose products, and can receive fit guidance or stockout alternatives; associates assess and confirm returns; merchants generate insight briefs. Shared session state ties shopper activity to the merchant view. The README describes a broader AI rescue platform, but the supplied backend entry point is empty and the sampled frontend delegates operations to an API layer, so the graph shows that boundary rather than undocumented backend internals. Edges reflect visible calls and imports; backend capabilities are documented aspirations, not verified implementation here.

Main entry points: [`frontend/src/features/storefront/screens/StorefrontScreen.tsx`](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/storefront/screens/StorefrontScreen.tsx) (Storefront flow), [`frontend/src/features/insights/screens/MerchantScreen.tsx`](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/insights/screens/MerchantScreen.tsx) (Insight workspace), [`frontend/src/lib/api/index.ts`](https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/index.ts) (Commerce API methods), [`frontend/src/lib/api/client.ts`](https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/client.ts) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shopper["Shopper discovery"]
  node_storefront["Storefront flow"]
  node_search_ui["Search input"]
  node_results_ui["Discovery results"]
  node_featured["Featured products<br/>[FeaturedGrid.tsx]"]
end

subgraph group_signals["Rescue and signals"]
  node_fit_check["Fit guidance<br/>[FitCheckPanel.tsx]"]
  node_stockout["Stockout rescue"]
  node_merchant_view["Insight workspace<br/>[MerchantScreen.tsx]"]
  node_insight_card["Insight brief<br/>[InsightCard.tsx]"]
end

subgraph group_operations["Associate operations"]
  node_returns["Return assessment"]
end

subgraph group_shared["Shared frontend services"]
  node_session["Session and cart"]
  node_cart_strip["Cart summary<br/>[CartStrip.tsx]"]
  node_api_methods["Commerce API methods<br/>[index.ts]"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_api_config["API configuration<br/>[api.ts]"]
  node_query_provider["Query cache<br/>[QueryProvider.tsx]"]
end

node_shopper_actor(("Shopper"))
node_merchant_actor(("Merchant"))
node_associate_actor(("Store associate"))
node_commerce_api{{"Commerce API"}}

node_shopper_actor -->|"uses"| node_storefront
node_storefront -->|"renders"| node_search_ui
node_storefront -->|"renders"| node_results_ui
node_storefront -->|"renders"| node_featured
node_storefront -->|"renders"| node_fit_check
node_storefront -->|"renders"| node_stockout
node_storefront -->|"searches catalog"| node_api_methods
node_storefront -->|"updates session"| node_session
node_storefront -->|"renders"| node_cart_strip
node_merchant_actor -->|"uses"| node_merchant_view
node_merchant_view -->|"requests insights"| node_api_methods
node_merchant_view -->|"reads activity"| node_session
node_merchant_view -->|"renders briefs"| node_insight_card
node_associate_actor -->|"uses"| node_returns
node_returns -->|"assesses and confirms"| node_api_methods
node_api_methods -->|"delegates requests"| node_api_client
node_api_client -->|"uses base URL"| node_api_config
node_api_client -->|"sends HTTP"| node_commerce_api
node_storefront -.->|"uses queries"| node_query_provider

click node_storefront "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/storefront/screens/StorefrontScreen.tsx"
click node_search_ui "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/discovery/components/DiscoverySearch.tsx"
click node_results_ui "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/discovery/components/DiscoveryResults.tsx"
click node_featured "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/storefront/components/FeaturedGrid.tsx"
click node_fit_check "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/fit-check/components/FitCheckPanel.tsx"
click node_stockout "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/rescue/components/StockoutRescuePanel.tsx"
click node_merchant_view "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/insights/screens/MerchantScreen.tsx"
click node_insight_card "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/insights/components/InsightCard.tsx"
click node_returns "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/returns/screens/AssociateScreen.tsx"
click node_session "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/session/SessionProvider.tsx"
click node_cart_strip "https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/session/components/CartStrip.tsx"
click node_api_methods "https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/index.ts"
click node_api_client "https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/client.ts"
click node_api_config "https://github.com/sanketp27/offgridai/blob/main/frontend/src/config/api.ts"
click node_query_provider "https://github.com/sanketp27/offgridai/blob/main/frontend/src/providers/QueryProvider.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_storefront,node_search_ui,node_results_ui,node_featured toneBlue
class node_fit_check,node_stockout,node_merchant_view,node_insight_card toneAmber
class node_returns,node_commerce_api toneMint
class node_session,node_cart_strip,node_api_methods,node_api_client,node_api_config,node_query_provider toneRose
class node_shopper_actor,node_merchant_actor,node_associate_actor toneIndigo
```

## Components

### Shopper discovery

- [Storefront flow](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/storefront/screens/StorefrontScreen.tsx): `frontend/src/features/storefront/screens/StorefrontScreen.tsx`
- [Search input](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/discovery/components/DiscoverySearch.tsx): `frontend/src/features/discovery/components/DiscoverySearch.tsx`
- [Discovery results](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/discovery/components/DiscoveryResults.tsx): `frontend/src/features/discovery/components/DiscoveryResults.tsx`
- [Featured products](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/storefront/components/FeaturedGrid.tsx): `frontend/src/features/storefront/components/FeaturedGrid.tsx`

### Rescue and signals

- [Fit guidance](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/fit-check/components/FitCheckPanel.tsx): `frontend/src/features/fit-check/components/FitCheckPanel.tsx`
- [Stockout rescue](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/rescue/components/StockoutRescuePanel.tsx): `frontend/src/features/rescue/components/StockoutRescuePanel.tsx`
- [Insight workspace](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/insights/screens/MerchantScreen.tsx): `frontend/src/features/insights/screens/MerchantScreen.tsx`
- [Insight brief](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/insights/components/InsightCard.tsx): `frontend/src/features/insights/components/InsightCard.tsx`

### Associate operations

- [Return assessment](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/returns/screens/AssociateScreen.tsx): `frontend/src/features/returns/screens/AssociateScreen.tsx`

### Shared frontend services

- [Session and cart](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/session/SessionProvider.tsx): `frontend/src/features/session/SessionProvider.tsx`
- [Cart summary](https://github.com/sanketp27/offgridai/blob/main/frontend/src/features/session/components/CartStrip.tsx): `frontend/src/features/session/components/CartStrip.tsx`
- [Commerce API methods](https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/index.ts): `frontend/src/lib/api/index.ts`
- [HTTP client](https://github.com/sanketp27/offgridai/blob/main/frontend/src/lib/api/client.ts): `frontend/src/lib/api/client.ts`
- [API configuration](https://github.com/sanketp27/offgridai/blob/main/frontend/src/config/api.ts): `frontend/src/config/api.ts`
- [Query cache](https://github.com/sanketp27/offgridai/blob/main/frontend/src/providers/QueryProvider.tsx): `frontend/src/providers/QueryProvider.tsx`

### Other components

- **Shopper**
- **Merchant**
- **Store associate**
- **Commerce API**

## Connections

- Shopper → Storefront flow: uses (evidence: `README.md`)
- Storefront flow → Search input: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Discovery results: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Featured products: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Fit guidance: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Stockout rescue: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Commerce API methods: searches catalog (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Session and cart: updates session (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Storefront flow → Cart summary: renders (evidence: `frontend/src/features/storefront/screens/StorefrontScreen.tsx`)
- Merchant → Insight workspace: uses (evidence: `README.md`)
- Insight workspace → Commerce API methods: requests insights (evidence: `frontend/src/features/insights/screens/MerchantScreen.tsx`)
- Insight workspace → Session and cart: reads activity (evidence: `frontend/src/features/insights/screens/MerchantScreen.tsx`)
- Insight workspace → Insight brief: renders briefs (evidence: `frontend/src/features/insights/screens/MerchantScreen.tsx`)
- Store associate → Return assessment: uses (evidence: `README.md`)
- Return assessment → Commerce API methods: assesses and confirms (evidence: `frontend/src/features/returns/screens/AssociateScreen.tsx`)
- Commerce API methods → HTTP client: delegates requests (evidence: `frontend/src/lib/api/client.ts`)
- HTTP client → API configuration: uses base URL (evidence: `frontend/src/lib/api/client.ts`)
- HTTP client → Commerce API: sends HTTP (evidence: `frontend/src/lib/api/client.ts`)
- Storefront flow → Query cache: uses queries
