# shahilsingh546/paisaflow architecture

> Architecture diagram of the GitHub repository shahilsingh546/paisaflow, 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/shahilsingh546/paisaflow
- Repository: https://github.com/shahilsingh546/paisaflow

## Overview

Paisa Flow is a wallet monorepo with user and merchant web apps, a bank webhook service, and shared database, state, and UI packages. The user journey spans sign-in, wallet overview and transaction history, adding money, and peer-to-peer transfers; merchant sign-in is a separate workflow. The excerpts establish several page, authentication, and database relationships, but the webhook implementation and some transfer actions were not sampled, so their internal links are omitted.

Main entry points: [`apps/user-app/app/lib/auth.ts`](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/auth.ts) (User authentication), [`apps/user-app/app/(dashboard)/dashboard/page.tsx`](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/dashboard/page.tsx) (Wallet dashboard), [`packages/db/index.ts`](https://github.com/shahilsingh546/paisaflow/blob/main/packages/db/index.ts) (Prisma database), [`apps/user-app/app/(dashboard)/p2p/page.tsx`](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/p2p/page.tsx) (P2P transfer page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user["User wallet"]
  node_user_entry["Session redirect<br/>[page.tsx]"]
  node_user_auth["User authentication<br/>[auth.ts]"]
  node_dashboard["Wallet dashboard<br/>[page.tsx]"]
  node_balance_view["Balance display<br/>[BalanceCard.tsx]"]
  node_transactions_page["Transaction history<br/>[page.tsx]"]
  node_transaction_query["Transaction retrieval<br/>[getTransactions.ts]"]
  node_transaction_view["Transaction display"]
  node_transfer_page["Wallet funding page<br/>[page.tsx]"]
  node_funding_action["Onramp transaction"]
  node_p2p_page["P2P transfer page<br/>[page.tsx]"]
  node_send_form["Transfer form<br/>[SendCard.tsx]"]
  node_p2p_action["P2P transfer action<br/>[p2pTransfer.ts]"]
  node_p2p_history["P2P history view"]
  node_user_api["User profile API<br/>[route.ts]"]
end

subgraph group_merchant["Merchant portal"]
  node_merchant_auth["Merchant authentication<br/>[auth.ts]"]
  node_merchant_api["Merchant API<br/>[route.ts]"]
end

subgraph group_shared["Shared packages"]
  node_database[("Prisma database<br/>[index.ts]")]
  node_balance_state["Balance state<br/>[balance.ts]"]
  node_balance_hook["Balance hook<br/>[useBalance.ts]"]
  node_shared_appbar["Shared app bar<br/>[Appbar.tsx]"]
  node_shared_button["Shared button<br/>[button.tsx]"]
end

subgraph group_integrations["Payment integration"]
  node_webhook["Bank webhook handler<br/>[index.ts]"]
end

node_customer(("Wallet user"))
node_merchant_customer(("Merchant user"))

node_customer -->|"opens"| node_user_entry
node_user_entry -->|"checks session"| node_user_auth
node_user_auth -->|"reads/writes users"| node_database
node_dashboard -->|"checks session"| node_user_auth
node_dashboard -->|"reads balance"| node_database
node_dashboard -->|"loads transactions"| node_transaction_query
node_dashboard -->|"renders"| node_balance_view
node_dashboard -->|"renders"| node_transaction_view
node_transactions_page -->|"checks session"| node_user_auth
node_transactions_page -->|"loads transactions"| node_transaction_query
node_transactions_page -->|"renders"| node_transaction_view
node_p2p_page -->|"checks session"| node_user_auth
node_p2p_page -->|"reads transfers"| node_database
node_p2p_page -->|"renders"| node_send_form
node_p2p_page -->|"renders"| node_p2p_history
node_user_api -->|"checks session"| node_user_auth
node_merchant_customer -.->|"signs in"| node_merchant_auth
node_merchant_auth -->|"upserts merchant"| node_database
node_merchant_api -->|"creates merchant"| node_database
node_balance_hook -->|"reads state"| node_balance_state
node_shared_appbar -->|"uses"| node_shared_button

click node_user_entry "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/page.tsx"
click node_user_auth "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/auth.ts"
click node_dashboard "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/dashboard/page.tsx"
click node_balance_view "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/BalanceCard.tsx"
click node_transactions_page "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/transactions/page.tsx"
click node_transaction_query "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/getTransactions.ts"
click node_transaction_view "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/TransactionsCard.tsx"
click node_transfer_page "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/transfer/page.tsx"
click node_funding_action "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/actions/createOnrampTransaction.ts"
click node_p2p_page "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/p2p/page.tsx"
click node_send_form "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/SendCard.tsx"
click node_p2p_action "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/actions/p2pTransfer.ts"
click node_p2p_history "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/P2PTransactions.tsx"
click node_user_api "https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/api/user/route.ts"
click node_merchant_auth "https://github.com/shahilsingh546/paisaflow/blob/main/apps/merchant-app/lib/auth.ts"
click node_merchant_api "https://github.com/shahilsingh546/paisaflow/blob/main/apps/merchant-app/app/api/user/route.ts"
click node_webhook "https://github.com/shahilsingh546/paisaflow/blob/main/apps/bank_webhook_handler/src/index.ts"
click node_database "https://github.com/shahilsingh546/paisaflow/blob/main/packages/db/index.ts"
click node_balance_state "https://github.com/shahilsingh546/paisaflow/blob/main/packages/store/src/atoms/balance.ts"
click node_balance_hook "https://github.com/shahilsingh546/paisaflow/blob/main/packages/store/src/hooks/useBalance.ts"
click node_shared_appbar "https://github.com/shahilsingh546/paisaflow/blob/main/packages/ui/src/Appbar.tsx"
click node_shared_button "https://github.com/shahilsingh546/paisaflow/blob/main/packages/ui/src/button.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_user_entry,node_user_auth,node_dashboard,node_balance_view,node_transactions_page,node_transaction_query,node_transaction_view,node_transfer_page,node_funding_action,node_p2p_page,node_send_form,node_p2p_action,node_p2p_history,node_user_api,node_customer,node_merchant_customer toneBlue
class node_merchant_auth,node_merchant_api toneAmber
class node_database,node_balance_state,node_balance_hook,node_shared_appbar,node_shared_button toneMint
class node_webhook toneRose
```

## Components

### User wallet

- [Session redirect](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/page.tsx): `apps/user-app/app/page.tsx`
- [User authentication](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/auth.ts): `apps/user-app/app/lib/auth.ts`
- [Wallet dashboard](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/dashboard/page.tsx): `apps/user-app/app/(dashboard)/dashboard/page.tsx`
- [Balance display](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/BalanceCard.tsx): `apps/user-app/components/BalanceCard.tsx`
- [Transaction history](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/transactions/page.tsx): `apps/user-app/app/(dashboard)/transactions/page.tsx`
- [Transaction retrieval](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/getTransactions.ts): `apps/user-app/app/lib/getTransactions.ts`
- [Transaction display](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/TransactionsCard.tsx): `apps/user-app/components/TransactionsCard.tsx`
- [Wallet funding page](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/transfer/page.tsx): `apps/user-app/app/(dashboard)/transfer/page.tsx`
- [Onramp transaction](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/actions/createOnrampTransaction.ts): `apps/user-app/app/lib/actions/createOnrampTransaction.ts`
- [P2P transfer page](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/(dashboard)/p2p/page.tsx): `apps/user-app/app/(dashboard)/p2p/page.tsx`
- [Transfer form](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/SendCard.tsx): `apps/user-app/components/SendCard.tsx`
- [P2P transfer action](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/lib/actions/p2pTransfer.ts): `apps/user-app/app/lib/actions/p2pTransfer.ts`
- [P2P history view](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/components/P2PTransactions.tsx): `apps/user-app/components/P2PTransactions.tsx`
- [User profile API](https://github.com/shahilsingh546/paisaflow/blob/main/apps/user-app/app/api/user/route.ts): `apps/user-app/app/api/user/route.ts`

### Merchant portal

- [Merchant authentication](https://github.com/shahilsingh546/paisaflow/blob/main/apps/merchant-app/lib/auth.ts): `apps/merchant-app/lib/auth.ts`
- [Merchant API](https://github.com/shahilsingh546/paisaflow/blob/main/apps/merchant-app/app/api/user/route.ts): `apps/merchant-app/app/api/user/route.ts`

### Shared packages

- [Prisma database](https://github.com/shahilsingh546/paisaflow/blob/main/packages/db/index.ts): `packages/db/index.ts`
- [Balance state](https://github.com/shahilsingh546/paisaflow/blob/main/packages/store/src/atoms/balance.ts): `packages/store/src/atoms/balance.ts`
- [Balance hook](https://github.com/shahilsingh546/paisaflow/blob/main/packages/store/src/hooks/useBalance.ts): `packages/store/src/hooks/useBalance.ts`
- [Shared app bar](https://github.com/shahilsingh546/paisaflow/blob/main/packages/ui/src/Appbar.tsx): `packages/ui/src/Appbar.tsx`
- [Shared button](https://github.com/shahilsingh546/paisaflow/blob/main/packages/ui/src/button.tsx): `packages/ui/src/button.tsx`

### Payment integration

- [Bank webhook handler](https://github.com/shahilsingh546/paisaflow/blob/main/apps/bank_webhook_handler/src/index.ts): `apps/bank_webhook_handler/src/index.ts`

### Other components

- **Wallet user**
- **Merchant user**

## Connections

- Wallet user → Session redirect: opens (evidence: `apps/user-app/app/page.tsx`)
- Session redirect → User authentication: checks session (evidence: `apps/user-app/app/page.tsx`)
- User authentication → Prisma database: reads/writes users (evidence: `apps/user-app/app/lib/auth.ts`)
- Wallet dashboard → User authentication: checks session (evidence: `apps/user-app/app/(dashboard)/dashboard/page.tsx`)
- Wallet dashboard → Prisma database: reads balance (evidence: `apps/user-app/app/(dashboard)/dashboard/page.tsx`)
- Wallet dashboard → Transaction retrieval: loads transactions (evidence: `apps/user-app/app/(dashboard)/dashboard/page.tsx`)
- Wallet dashboard → Balance display: renders (evidence: `apps/user-app/app/(dashboard)/dashboard/page.tsx`)
- Wallet dashboard → Transaction display: renders (evidence: `apps/user-app/app/(dashboard)/dashboard/page.tsx`)
- Transaction history → User authentication: checks session (evidence: `apps/user-app/app/(dashboard)/transactions/page.tsx`)
- Transaction history → Transaction retrieval: loads transactions (evidence: `apps/user-app/app/(dashboard)/transactions/page.tsx`)
- Transaction history → Transaction display: renders (evidence: `apps/user-app/app/(dashboard)/transactions/page.tsx`)
- P2P transfer page → User authentication: checks session (evidence: `apps/user-app/app/(dashboard)/p2p/page.tsx`)
- P2P transfer page → Prisma database: reads transfers (evidence: `apps/user-app/app/(dashboard)/p2p/page.tsx`)
- P2P transfer page → Transfer form: renders (evidence: `apps/user-app/app/(dashboard)/p2p/page.tsx`)
- P2P transfer page → P2P history view: renders (evidence: `apps/user-app/app/(dashboard)/p2p/page.tsx`)
- User profile API → User authentication: checks session (evidence: `apps/user-app/app/api/user/route.ts`)
- Merchant user → Merchant authentication: signs in
- Merchant authentication → Prisma database: upserts merchant (evidence: `apps/merchant-app/lib/auth.ts`)
- Merchant API → Prisma database: creates merchant (evidence: `apps/merchant-app/app/api/user/route.ts`)
- Balance hook → Balance state: reads state (evidence: `packages/store/src/hooks/useBalance.ts`)
- Shared app bar → Shared button: uses (evidence: `packages/ui/src/Appbar.tsx`)
