# sahilprg/monad-payment-links architecture

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

- Interactive diagram: https://gitdiagram.com/sahilprg/monad-payment-links
- Repository: https://github.com/sahilprg/monad-payment-links

## Overview

Paperplane is a web app for sending money as a shareable, revocable link, with optional recipient addressing and a collection safety hold. The main workflow is email sign-in, sender deposit, link sharing, and recipient claim; senders can also inspect or cancel pending transfers, and the app funds new accounts with test tokens. The graph captures documented contract and gatekeeper behavior plus source-visible web calls. Solidity implementation files are absent from the supplied tree, so contract internals are represented at the documented boundary; unshown wiring is omitted.

Main entry points: [`web/src/components/SendDesk.tsx`](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SendDesk.tsx) (Send desk), [`contracts`](https://github.com/sahilprg/monad-payment-links/tree/main/contracts) (LinkEscrow), [`web/src/components/SentList.tsx`](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SentList.tsx) (Sent transfers), [`web/src/app/claim/page.tsx`](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/claim/page.tsx) (Claim screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_send_ui["Send desk<br/>[SendDesk.tsx]"]
  node_sent_list["Sent transfers<br/>[SentList.tsx]"]
  node_claim_ui["Claim screen<br/>[page.tsx]"]
  node_auth["Email sign-in<br/>[providers.tsx]"]
  node_presentation["App shell<br/>[Shell.tsx]"]
end

subgraph group_payments["Transfer lifecycle"]
  node_link_logic["Link and key logic<br/>[paymentLink.ts]"]
  node_chain_config["Chain configuration<br/>[config.ts]"]
  node_wallet["Embedded wallet<br/>[wallet.ts]"]
  node_rpc_transport["RPC transport<br/>[transport.ts]"]
end

subgraph group_services["Server services"]
  node_claim_api["Claim gatekeeper<br/>[route.ts]"]
  node_identity["Privy verification<br/>[privyServer.ts]"]
  node_relayer["Relayer<br/>[relayer.ts]"]
  node_fund_api["Account funding<br/>[route.ts]"]
  node_rpc_api["RPC proxy<br/>[route.ts]"]
  node_rpc_upstreams["Monad endpoints<br/>[upstreams.ts]"]
end

subgraph group_chain["Monad contracts"]
  node_escrow[("LinkEscrow")]
  node_test_usd[("MockUSD")]
end

node_sender(("Sender"))
node_recipient(("Recipient"))
node_privy_service["Privy"]
node_monad["Monad testnet"]
node_share["Messaging channel"]

node_sender -->|"uses"| node_send_ui
node_recipient -->|"opens link"| node_claim_ui
node_send_ui -->|"gets signer"| node_wallet
node_send_ui -->|"reads chain"| node_chain_config
node_send_ui -->|"checks balance"| node_test_usd
node_send_ui -->|"approves token"| node_test_usd
node_send_ui -->|"creates claim key"| node_link_logic
node_send_ui -->|"deposits funds"| node_escrow
node_send_ui -->|"shares link"| node_share
node_send_ui -->|"renders"| node_sent_list
node_sent_list -->|"reads transfer status"| node_chain_config
node_sent_list -->|"gets signer"| node_wallet
node_sent_list -->|"cancels transfer"| node_escrow
node_claim_ui -.->|"reads and signs link"| node_link_logic
node_claim_ui -.->|"requests gate signature"| node_claim_api
node_claim_ui -.->|"submits claim"| node_escrow
node_claim_api -->|"verifies account"| node_identity
node_identity -->|"verifies token"| node_privy_service
node_claim_api -.->|"requests claim relay"| node_relayer
node_relayer -.->|"submits claim"| node_escrow
node_fund_api -.->|"requests funding"| node_relayer
node_send_ui -->|"requests test funds"| node_fund_api
node_rpc_transport -->|"proxies browser calls"| node_rpc_api
node_rpc_api -.->|"selects endpoints"| node_rpc_upstreams
node_rpc_upstreams -.->|"connects to"| node_monad
node_presentation -->|"uses sign-in state"| node_auth
node_auth -->|"authenticates users"| node_privy_service
node_escrow -->|"holds and releases tokens"| node_test_usd
node_escrow -->|"pays on claim"| node_recipient
node_escrow -->|"refunds or cancels"| node_sender

click node_send_ui "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SendDesk.tsx"
click node_sent_list "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SentList.tsx"
click node_claim_ui "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/claim/page.tsx"
click node_auth "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/providers.tsx"
click node_presentation "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/Shell.tsx"
click node_link_logic "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/paymentLink.ts"
click node_chain_config "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/config.ts"
click node_wallet "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/wallet.ts"
click node_escrow "https://github.com/sahilprg/monad-payment-links/tree/main/contracts"
click node_test_usd "https://github.com/sahilprg/monad-payment-links/tree/main/contracts"
click node_claim_api "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/claim/route.ts"
click node_identity "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/privyServer.ts"
click node_relayer "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/relayer.ts"
click node_fund_api "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/fund/route.ts"
click node_rpc_api "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/rpc/route.ts"
click node_rpc_transport "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/transport.ts"
click node_rpc_upstreams "https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/upstreams.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_send_ui,node_sent_list,node_claim_ui,node_auth,node_presentation toneBlue
class node_link_logic,node_chain_config,node_wallet,node_rpc_transport toneAmber
class node_claim_api,node_identity,node_relayer,node_fund_api,node_rpc_api,node_rpc_upstreams toneMint
class node_escrow,node_test_usd toneRose
class node_sender,node_recipient,node_privy_service,node_monad,node_share toneIndigo
```

## Components

### Web experience

- [Send desk](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SendDesk.tsx): `web/src/components/SendDesk.tsx`
- [Sent transfers](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/SentList.tsx): `web/src/components/SentList.tsx`
- [Claim screen](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/claim/page.tsx): `web/src/app/claim/page.tsx`
- [Email sign-in](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/providers.tsx): `web/src/app/providers.tsx`
- [App shell](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/components/Shell.tsx): `web/src/components/Shell.tsx`

### Transfer lifecycle

- [Link and key logic](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/paymentLink.ts): `web/src/lib/paymentLink.ts`
- [Chain configuration](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/config.ts): `web/src/lib/config.ts`
- [Embedded wallet](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/wallet.ts): `web/src/lib/wallet.ts`
- [RPC transport](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/transport.ts): `web/src/lib/transport.ts`

### Server services

- [Claim gatekeeper](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/claim/route.ts): `web/src/app/api/claim/route.ts`
- [Privy verification](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/privyServer.ts): `web/src/lib/privyServer.ts`
- [Relayer](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/relayer.ts): `web/src/lib/relayer.ts`
- [Account funding](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/fund/route.ts): `web/src/app/api/fund/route.ts`
- [RPC proxy](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/app/api/rpc/route.ts): `web/src/app/api/rpc/route.ts`
- [Monad endpoints](https://github.com/sahilprg/monad-payment-links/blob/main/web/src/lib/upstreams.ts): `web/src/lib/upstreams.ts`

### Monad contracts

- [LinkEscrow](https://github.com/sahilprg/monad-payment-links/tree/main/contracts): `contracts`
- [MockUSD](https://github.com/sahilprg/monad-payment-links/tree/main/contracts): `contracts`

### Other components

- **Sender**
- **Recipient**
- **Privy**
- **Monad testnet**
- **Messaging channel**

## Connections

- Sender → Send desk: uses
- Recipient → Claim screen: opens link
- Send desk → Embedded wallet: gets signer (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → Chain configuration: reads chain (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → MockUSD: checks balance (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → MockUSD: approves token (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → Link and key logic: creates claim key (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → LinkEscrow: deposits funds (evidence: `web/src/components/SendDesk.tsx`)
- Send desk → Messaging channel: shares link
- Send desk → Sent transfers: renders (evidence: `web/src/components/SendDesk.tsx`)
- Sent transfers → Chain configuration: reads transfer status (evidence: `web/src/components/SentList.tsx`)
- Sent transfers → Embedded wallet: gets signer (evidence: `web/src/components/SentList.tsx`)
- Sent transfers → LinkEscrow: cancels transfer (evidence: `web/src/components/SentList.tsx`)
- Claim screen → Link and key logic: reads and signs link
- Claim screen → Claim gatekeeper: requests gate signature
- Claim screen → LinkEscrow: submits claim
- Claim gatekeeper → Privy verification: verifies account (evidence: `web/src/lib/privyServer.ts`)
- Privy verification → Privy: verifies token (evidence: `web/src/lib/privyServer.ts`)
- Claim gatekeeper → Relayer: requests claim relay
- Relayer → LinkEscrow: submits claim
- Account funding → Relayer: requests funding
- Send desk → Account funding: requests test funds (evidence: `web/src/components/SendDesk.tsx`)
- RPC transport → RPC proxy: proxies browser calls (evidence: `web/src/lib/transport.ts`)
- RPC proxy → Monad endpoints: selects endpoints
- Monad endpoints → Monad testnet: connects to
- App shell → Email sign-in: uses sign-in state (evidence: `web/src/components/Shell.tsx`)
- Email sign-in → Privy: authenticates users
- LinkEscrow → MockUSD: holds and releases tokens
- LinkEscrow → Recipient: pays on claim
- LinkEscrow → Sender: refunds or cancels
