# bakshi2101/cardwise architecture

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

- Interactive diagram: https://gitdiagram.com/bakshi2101/cardwise
- Repository: https://github.com/bakshi2101/cardwise

## Overview

Cardwise is a Next.js credit-card discovery and rewards-planning product. Users can browse cards or search merchants/categories, then build a wallet and spending profile to compare rewards, get card recommendations, or optimize their existing card mix. Recommendation and optimization flows collect spending and preferences before presenting results; card details include wallet actions. The supplied excerpts and source index support the main module relationships, but several page implementations and integrations were not sampled, so the graph avoids claiming their internal behavior.

Main entry points: [`lib/wallet.ts`](https://github.com/bakshi2101/cardwise/blob/main/lib/wallet.ts) (Wallet and preferences), [`lib/supabase.ts`](https://github.com/bakshi2101/cardwise/blob/main/lib/supabase.ts) (Supabase client), [`lib/recommend.ts`](https://github.com/bakshi2101/cardwise/blob/main/lib/recommend.ts) (Reward calculations), [`app/recommend/results/RecommendResultsClient.tsx`](https://github.com/bakshi2101/cardwise/blob/main/app/recommend/results/RecommendResultsClient.tsx) (Recommendation results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Card Discovery"]
  node_home["Home<br/>[page.tsx]"]
  node_cardbrowser["Card browser"]
  node_carddetail["Card details<br/>[page.tsx]"]
  node_merchantsearch["Merchant search<br/>[MerchantSearch.tsx]"]
  node_categorygrid["Category browsing<br/>[CategoryGrid.tsx]"]
  node_categoryrecommend["Category rewards"]
end

subgraph group_planning["Recommendation Planning"]
  node_preferences["Recommendation preferences"]
  node_spendingstep["Spending input"]
  node_recommendresults["Recommendation results"]
  node_cardresult["Card result display<br/>[CardResult.tsx]"]
end

subgraph group_optimization["Wallet Optimization"]
  node_walletpage["Wallet<br/>[WalletClient.tsx]"]
  node_spendingprofile["Spending profile"]
  node_optspending["Optimization spending"]
  node_addcards["Add wallet cards<br/>[AddCardsClient.tsx]"]
  node_optimize["Optimization analysis<br/>[OptimizeClient.tsx]"]
end

subgraph group_shared["Shared Services"]
  node_recommendlogic["Reward calculations<br/>[recommend.ts]"]
  node_walletstate["Wallet and preferences<br/>[wallet.ts]"]
  node_bonuslogic["Welcome bonuses<br/>[welcomeBonus.ts]"]
  node_databaseclient["Supabase client<br/>[supabase.ts]"]
end

node_user(("Card shopper"))
node_supabase[("Supabase data")]

node_user -->|"opens"| node_home
node_user -->|"browses"| node_cardbrowser
node_user -->|"searches"| node_merchantsearch
node_cardbrowser -->|"reads cards"| node_databaseclient
node_carddetail -->|"loads details"| node_databaseclient
node_carddetail -->|"adds card"| node_walletstate
node_carddetail -->|"loads bonus"| node_bonuslogic
node_merchantsearch -->|"finds rewards"| node_recommendlogic
node_merchantsearch -->|"searches merchants"| node_databaseclient
node_categorygrid -->|"loads categories"| node_databaseclient
node_categoryrecommend -->|"reads wallet"| node_walletstate
node_categoryrecommend -->|"renders results"| node_cardresult
node_preferences -->|"saves preferences"| node_walletstate
node_spendingstep -->|"saves profile"| node_walletstate
node_recommendresults -->|"calculates rewards"| node_recommendlogic
node_recommendresults -->|"reads profile"| node_walletstate
node_recommendresults -->|"adds bonuses"| node_bonuslogic
node_recommendresults -->|"loads card data"| node_databaseclient
node_walletpage -->|"manages wallet"| node_walletstate
node_walletpage -->|"scores rewards"| node_recommendlogic
node_walletpage -->|"renders profile"| node_spendingprofile
node_spendingprofile -->|"loads categories"| node_databaseclient
node_optspending -->|"reads profile"| node_walletstate
node_optspending -->|"renders input"| node_spendingprofile
node_addcards -->|"updates wallet"| node_walletstate
node_optimize -->|"reads profile"| node_walletstate
node_optimize -->|"computes strategy"| node_recommendlogic
node_databaseclient -->|"queries"| node_supabase
node_recommendlogic -->|"loads reward data"| node_databaseclient

click node_home "https://github.com/bakshi2101/cardwise/blob/main/app/page.tsx"
click node_cardbrowser "https://github.com/bakshi2101/cardwise/blob/main/app/cards/CardBrowserClient.tsx"
click node_carddetail "https://github.com/bakshi2101/cardwise/blob/main/app/cards/%5Bid%5D/page.tsx"
click node_merchantsearch "https://github.com/bakshi2101/cardwise/blob/main/components/MerchantSearch.tsx"
click node_categorygrid "https://github.com/bakshi2101/cardwise/blob/main/components/CategoryGrid.tsx"
click node_categoryrecommend "https://github.com/bakshi2101/cardwise/blob/main/app/recommend/%5Bslug%5D/RecommendClient.tsx"
click node_preferences "https://github.com/bakshi2101/cardwise/blob/main/app/recommend/preferences/PreferencesClient.tsx"
click node_spendingstep "https://github.com/bakshi2101/cardwise/blob/main/components/SpendingStepClient.tsx"
click node_recommendresults "https://github.com/bakshi2101/cardwise/blob/main/app/recommend/results/RecommendResultsClient.tsx"
click node_cardresult "https://github.com/bakshi2101/cardwise/blob/main/components/CardResult.tsx"
click node_walletpage "https://github.com/bakshi2101/cardwise/blob/main/app/wallet/WalletClient.tsx"
click node_spendingprofile "https://github.com/bakshi2101/cardwise/blob/main/components/SpendingProfile.tsx"
click node_optspending "https://github.com/bakshi2101/cardwise/blob/main/components/SpendingStepClient.tsx"
click node_addcards "https://github.com/bakshi2101/cardwise/blob/main/app/optimize/add-cards/AddCardsClient.tsx"
click node_optimize "https://github.com/bakshi2101/cardwise/blob/main/app/optimize/OptimizeClient.tsx"
click node_recommendlogic "https://github.com/bakshi2101/cardwise/blob/main/lib/recommend.ts"
click node_walletstate "https://github.com/bakshi2101/cardwise/blob/main/lib/wallet.ts"
click node_bonuslogic "https://github.com/bakshi2101/cardwise/blob/main/lib/welcomeBonus.ts"
click node_databaseclient "https://github.com/bakshi2101/cardwise/blob/main/lib/supabase.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_cardbrowser,node_carddetail,node_merchantsearch,node_categorygrid,node_categoryrecommend toneBlue
class node_preferences,node_spendingstep,node_recommendresults,node_cardresult,node_supabase toneAmber
class node_walletpage,node_spendingprofile,node_optspending,node_addcards,node_optimize toneMint
class node_recommendlogic,node_walletstate,node_bonuslogic,node_databaseclient toneRose
class node_user toneIndigo
```

## Components

### Card Discovery

- [Home](https://github.com/bakshi2101/cardwise/blob/main/app/page.tsx): `app/page.tsx`
- [Card browser](https://github.com/bakshi2101/cardwise/blob/main/app/cards/CardBrowserClient.tsx): `app/cards/CardBrowserClient.tsx`
- [Card details](https://github.com/bakshi2101/cardwise/blob/main/app/cards/%5Bid%5D/page.tsx): `app/cards/[id]/page.tsx`
- [Merchant search](https://github.com/bakshi2101/cardwise/blob/main/components/MerchantSearch.tsx): `components/MerchantSearch.tsx`
- [Category browsing](https://github.com/bakshi2101/cardwise/blob/main/components/CategoryGrid.tsx): `components/CategoryGrid.tsx`
- [Category rewards](https://github.com/bakshi2101/cardwise/blob/main/app/recommend/%5Bslug%5D/RecommendClient.tsx): `app/recommend/[slug]/RecommendClient.tsx`

### Recommendation Planning

- [Recommendation preferences](https://github.com/bakshi2101/cardwise/blob/main/app/recommend/preferences/PreferencesClient.tsx): `app/recommend/preferences/PreferencesClient.tsx`
- [Spending input](https://github.com/bakshi2101/cardwise/blob/main/components/SpendingStepClient.tsx): `components/SpendingStepClient.tsx`
- [Recommendation results](https://github.com/bakshi2101/cardwise/blob/main/app/recommend/results/RecommendResultsClient.tsx): `app/recommend/results/RecommendResultsClient.tsx`
- [Card result display](https://github.com/bakshi2101/cardwise/blob/main/components/CardResult.tsx): `components/CardResult.tsx`

### Wallet Optimization

- [Wallet](https://github.com/bakshi2101/cardwise/blob/main/app/wallet/WalletClient.tsx): `app/wallet/WalletClient.tsx`
- [Spending profile](https://github.com/bakshi2101/cardwise/blob/main/components/SpendingProfile.tsx): `components/SpendingProfile.tsx`
- [Optimization spending](https://github.com/bakshi2101/cardwise/blob/main/components/SpendingStepClient.tsx): `components/SpendingStepClient.tsx`
- [Add wallet cards](https://github.com/bakshi2101/cardwise/blob/main/app/optimize/add-cards/AddCardsClient.tsx): `app/optimize/add-cards/AddCardsClient.tsx`
- [Optimization analysis](https://github.com/bakshi2101/cardwise/blob/main/app/optimize/OptimizeClient.tsx): `app/optimize/OptimizeClient.tsx`

### Shared Services

- [Reward calculations](https://github.com/bakshi2101/cardwise/blob/main/lib/recommend.ts): `lib/recommend.ts`
- [Wallet and preferences](https://github.com/bakshi2101/cardwise/blob/main/lib/wallet.ts): `lib/wallet.ts`
- [Welcome bonuses](https://github.com/bakshi2101/cardwise/blob/main/lib/welcomeBonus.ts): `lib/welcomeBonus.ts`
- [Supabase client](https://github.com/bakshi2101/cardwise/blob/main/lib/supabase.ts): `lib/supabase.ts`

### Other components

- **Card shopper**
- **Supabase data**

## Connections

- Card shopper → Home: opens
- Card shopper → Card browser: browses
- Card shopper → Merchant search: searches
- Card browser → Supabase client: reads cards (evidence: `app/cards/CardBrowserClient.tsx`)
- Card details → Supabase client: loads details (evidence: `app/cards/[id]/page.tsx`)
- Card details → Wallet and preferences: adds card (evidence: `app/cards/[id]/page.tsx`)
- Card details → Welcome bonuses: loads bonus (evidence: `app/cards/[id]/page.tsx`)
- Merchant search → Reward calculations: finds rewards (evidence: `components/MerchantSearch.tsx`)
- Merchant search → Supabase client: searches merchants (evidence: `components/MerchantSearch.tsx`)
- Category browsing → Supabase client: loads categories (evidence: `components/CategoryGrid.tsx`)
- Category rewards → Wallet and preferences: reads wallet (evidence: `app/recommend/[slug]/RecommendClient.tsx`)
- Category rewards → Card result display: renders results (evidence: `app/recommend/[slug]/RecommendClient.tsx`)
- Recommendation preferences → Wallet and preferences: saves preferences (evidence: `app/recommend/preferences/PreferencesClient.tsx`)
- Spending input → Wallet and preferences: saves profile (evidence: `components/SpendingStepClient.tsx`)
- Recommendation results → Reward calculations: calculates rewards (evidence: `app/recommend/results/RecommendResultsClient.tsx`)
- Recommendation results → Wallet and preferences: reads profile (evidence: `app/recommend/results/RecommendResultsClient.tsx`)
- Recommendation results → Welcome bonuses: adds bonuses (evidence: `app/recommend/results/RecommendResultsClient.tsx`)
- Recommendation results → Supabase client: loads card data (evidence: `app/recommend/results/RecommendResultsClient.tsx`)
- Wallet → Wallet and preferences: manages wallet (evidence: `app/wallet/WalletClient.tsx`)
- Wallet → Reward calculations: scores rewards (evidence: `app/wallet/WalletClient.tsx`)
- Wallet → Spending profile: renders profile (evidence: `app/wallet/WalletClient.tsx`)
- Spending profile → Supabase client: loads categories (evidence: `components/SpendingProfile.tsx`)
- Optimization spending → Wallet and preferences: reads profile (evidence: `components/SpendingStepClient.tsx`)
- Optimization spending → Spending profile: renders input (evidence: `components/SpendingStepClient.tsx`)
- Add wallet cards → Wallet and preferences: updates wallet (evidence: `app/optimize/add-cards/AddCardsClient.tsx`)
- Optimization analysis → Wallet and preferences: reads profile (evidence: `app/optimize/OptimizeClient.tsx`)
- Optimization analysis → Reward calculations: computes strategy (evidence: `app/optimize/OptimizeClient.tsx`)
- Supabase client → Supabase data: queries (evidence: `lib/supabase.ts`)
- Reward calculations → Supabase client: loads reward data (evidence: `lib/recommend.ts`)
