# stylenexy/rsvpay architecture

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

- Interactive diagram: https://gitdiagram.com/stylenexy/rsvpay
- Repository: https://github.com/stylenexy/rsvpay

## Overview

RSVPay combines a NEAR smart contract with a React site for creating wedding envelopes, giving gifts, preserving a per-envelope gift book, and later sending replies from locked shares. The principal journey runs from a guest gift through contract-held balances and recorded entries to a future reciprocal payment. The site also provides a guided story/demo and public verification of contract behavior. The README documents the contract’s money and transfer rules; sampled frontend excerpts show routing, holder gating, and the chain-client interface. Unsampled frontend links are omitted where their caller relationships cannot be established.

Main entry points: [`frontend/src/App.tsx`](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/App.tsx) (Web application), [`frontend/src/chain/near.ts`](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/near.ts) (NEAR client), [`contracts/src/lib.rs`](https://github.com/stylenexy/rsvpay/blob/master/contracts/src/lib.rs) (NEP-171 envelope), [`frontend/src/pages/Buku.tsx`](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Buku.tsx) (Gift book)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_site["Wedding site"]
  node_app["Web application<br/>[App.tsx]"]
  node_create["Create envelope<br/>[Buka.tsx]"]
  node_gift["Give gift<br/>[Beri.tsx]"]
  node_book["Gift book<br/>[Buku.tsx]"]
  node_historyui["History view<br/>[History.tsx]"]
  node_context["Account context<br/>[context.tsx]"]
end

subgraph group_chain["Chain access"]
  node_client["NEAR client<br/>[near.ts]"]
  node_mock["Mock client<br/>[mock.ts]"]
  node_holder["Holder proof<br/>[holder.ts]"]
  node_history["History verification<br/>[history.ts]"]
  node_storydata["Story runner<br/>[story.ts]"]
end

subgraph group_contract["Envelope contract"]
  node_contract["NEP-171 envelope<br/>[lib.rs]"]
end

subgraph group_story["Story and presentation"]
  node_guide["Guided tour<br/>[Guide.tsx]"]
  node_demo["Interactive story<br/>[Coba.tsx]"]
  node_hero["Wedding narrative"]
  node_localization["Language and copy<br/>[lang.ts]"]
end

node_visitor(("Guest or host"))
node_near{{"NEAR testnet"}}

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_gift
node_app -->|"routes to"| node_book
node_app -->|"routes to"| node_demo
node_app -->|"creates client"| node_client
node_app -->|"provides account"| node_context
node_create -.->|"uses chain"| node_client
node_gift -.->|"submits gift"| node_client
node_book -->|"proves holder"| node_holder
node_book -->|"shows history"| node_historyui
node_historyui -->|"reads records"| node_history
node_demo -->|"runs story"| node_storydata
node_client -->|"reads and writes"| node_near
node_client -->|"calls contract"| node_contract
node_mock -->|"implements interface"| node_client
node_holder -->|"checks ownership"| node_near
node_history -->|"verifies records"| node_near
node_contract -->|"runs on"| node_near
node_contract -->|"locks shares"| node_contract
node_guide -->|"guides visitor"| node_demo
node_hero -.->|"uses language"| node_localization

click node_app "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/App.tsx"
click node_create "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Buka.tsx"
click node_gift "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Beri.tsx"
click node_book "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Buku.tsx"
click node_historyui "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/components/History.tsx"
click node_client "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/near.ts"
click node_mock "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/mock.ts"
click node_holder "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/holder.ts"
click node_history "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/history.ts"
click node_storydata "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/story.ts"
click node_contract "https://github.com/stylenexy/rsvpay/blob/master/contracts/src/lib.rs"
click node_guide "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/components/Guide.tsx"
click node_demo "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Coba.tsx"
click node_hero "https://github.com/stylenexy/rsvpay/tree/master/frontend/src/hero"
click node_localization "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/lib/lang.ts"
click node_context "https://github.com/stylenexy/rsvpay/blob/master/frontend/src/context.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_create,node_gift,node_book,node_historyui,node_context toneBlue
class node_client,node_mock,node_holder,node_history,node_storydata toneAmber
class node_contract toneMint
class node_guide,node_demo,node_hero,node_localization toneRose
class node_visitor,node_near toneIndigo
```

## Components

### Wedding site

- [Web application](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Create envelope](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Buka.tsx): `frontend/src/pages/Buka.tsx`
- [Give gift](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Beri.tsx): `frontend/src/pages/Beri.tsx`
- [Gift book](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Buku.tsx): `frontend/src/pages/Buku.tsx`
- [History view](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/components/History.tsx): `frontend/src/components/History.tsx`
- [Account context](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/context.tsx): `frontend/src/context.tsx`

### Chain access

- [NEAR client](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/near.ts): `frontend/src/chain/near.ts`
- [Mock client](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/mock.ts): `frontend/src/chain/mock.ts`
- [Holder proof](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/holder.ts): `frontend/src/chain/holder.ts`
- [History verification](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/history.ts): `frontend/src/chain/history.ts`
- [Story runner](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/chain/story.ts): `frontend/src/chain/story.ts`

### Envelope contract

- [NEP-171 envelope](https://github.com/stylenexy/rsvpay/blob/master/contracts/src/lib.rs): `contracts/src/lib.rs`

### Story and presentation

- [Guided tour](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/components/Guide.tsx): `frontend/src/components/Guide.tsx`
- [Interactive story](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/pages/Coba.tsx): `frontend/src/pages/Coba.tsx`
- [Wedding narrative](https://github.com/stylenexy/rsvpay/tree/master/frontend/src/hero): `frontend/src/hero`
- [Language and copy](https://github.com/stylenexy/rsvpay/blob/master/frontend/src/lib/lang.ts): `frontend/src/lib/lang.ts`

### Other components

- **Guest or host**
- **NEAR testnet**

## Connections

- Guest or host → Web application: uses (evidence: `README.md`)
- Web application → Create envelope: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Give gift: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Gift book: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Interactive story: routes to (evidence: `frontend/src/App.tsx`)
- Web application → NEAR client: creates client (evidence: `frontend/src/App.tsx`)
- Web application → Account context: provides account (evidence: `frontend/src/App.tsx`)
- Create envelope → NEAR client: uses chain
- Give gift → NEAR client: submits gift
- Gift book → Holder proof: proves holder (evidence: `frontend/src/pages/Buku.tsx`)
- Gift book → History view: shows history (evidence: `frontend/src/pages/Buku.tsx`)
- History view → History verification: reads records (evidence: `frontend/src/components/History.tsx`)
- Interactive story → Story runner: runs story (evidence: `frontend/src/pages/Coba.tsx`)
- NEAR client → NEAR testnet: reads and writes (evidence: `README.md`)
- NEAR client → NEP-171 envelope: calls contract (evidence: `README.md`)
- Mock client → NEAR client: implements interface
- Holder proof → NEAR testnet: checks ownership (evidence: `README.md`)
- History verification → NEAR testnet: verifies records (evidence: `README.md`)
- NEP-171 envelope → NEAR testnet: runs on (evidence: `README.md`)
- NEP-171 envelope → NEP-171 envelope: locks shares (evidence: `README.md`)
- Guided tour → Interactive story: guides visitor (evidence: `frontend/src/components/Guide.tsx`)
- Wedding narrative → Language and copy: uses language (evidence: `frontend/src/lib/lang.ts`)
