# sorosave-protocol/frontend architecture

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

- Interactive diagram: https://gitdiagram.com/sorosave-protocol/frontend
- Repository: https://github.com/sorosave-protocol/frontend

## Overview

#### Purpose and Runtime
SoroSave is a Next.js 14 App Router frontend for a decentralized rotating-savings protocol on Stellar Soroban. It runs as a browser-rendered web client, styled with Tailwind, and connects users’ wallets and contract calls through Stellar SDK/Freighter APIs. The application root is `src/app/layout.tsx`; shared client providers are established in `src/app/providers.tsx`.

#### Route Entry Points
The landing experience is `src/app/page.tsx`. Group discovery is served by `src/app/groups/page.tsx`, with group-specific views resolved through the dynamic route `src/app/groups/[id]/page.tsx`. Group creation is a separate route at `src/app/groups/new/page.tsx`. These routes define the main navigation and state boundaries: browse groups, create a group, then inspect and contribute to a selected group.

#### Wallet and Blockchain Boundary
`src/lib/wallet.ts` encapsulates wallet-facing behavior, principally Freighter integration and account/signing concerns. `src/lib/sorosave.ts` is the Soroban contract boundary: it is expected to construct and submit/read contract interactions using `@stellar/stellar-sdk`, configured by public contract ID, RPC URL, and network passphrase environment variables. Browser UI should reach on-chain state through these library modules rather than embedding protocol calls in route components.

#### Group Lifecycle
Group creation is represented by `src/components/CreateGroupForm.tsx` and exposed through `src/app/groups/new/page.tsx`. The form collects group parameters and initiates the corresponding contract operation through the SoroSave integration layer. After contract confirmation, the created group becomes available to group-listing and detail flows.

#### Discovery and Group Detail
`src/app/groups/page.tsx` coordinates group retrieval and renders reusable summaries via `src/components/GroupCard.tsx`. `src/app/groups/[id]/page.tsx` is the per-group orchestration point, loading the identified group and composing its member, progress, and contribution surfaces. The route parameter is the key boundary between navigation state and contract-derived group state.

#### Contribution and Rotation State
`src/components/ContributeModal.tsx` provides the transaction-oriented contribution interaction. `src/components/RoundProgress.tsx` presents the current savings/rotation round status, while `src/components/MemberList.tsx` displays participating members. Together these components translate contract state into the group-level workflow: member roster, active round, user contribution, and progression toward payout/next round.

#### Shared UI and Deployment Assumptions
`src/components/Navbar.tsx` and `src/components/ConnectWallet.tsx` provide cross-route navigation and wallet-session entry. Global visual styling is rooted in `src/app/globals.css`. Deployment requires a reachable Soroban RPC endpoint and browser access to Freighter; the default documented target is Stellar testnet, with all chain settings exposed as `NEXT_PUBLIC_*` client-side variables.

Main entry points: [`src/lib/sorosave.ts`](https://github.com/sorosave-protocol/frontend/blob/main/src/lib/sorosave.ts) (SoroSave contract client), [`src/app/groups/[id]/page.tsx`](https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/%5Bid%5D/page.tsx) (Group detail), [`src/app/layout.tsx`](https://github.com/sorosave-protocol/frontend/blob/main/src/app/layout.tsx) (Root layout), [`src/app/groups/page.tsx`](https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/page.tsx) (Group discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_layout["Root layout<br/>Next.js layout<br/>[layout.tsx]"]
  node_providers["Client providers<br/>React providers<br/>[providers.tsx]"]
  node_navbar["Navigation bar<br/>shared UI<br/>[Navbar.tsx]"]
  node_connect_wallet["Connect wallet<br/>wallet UI<br/>[ConnectWallet.tsx]"]
  node_styles["Global styles<br/>Tailwind CSS<br/>[globals.css]"]
end

subgraph group_routes["Routes"]
  node_landing["Landing page<br/>route<br/>[page.tsx]"]
  node_groups_index["Group discovery<br/>route<br/>[page.tsx]"]
  node_group_detail["Group detail<br/>dynamic route<br/>[page.tsx]"]
  node_new_group["Create group page<br/>route<br/>[page.tsx]"]
end

subgraph group_ui["Group UI"]
  node_group_card["Group card<br/>group summary UI<br/>[GroupCard.tsx]"]
  node_create_form["Create group form<br/>transaction UI"]
  node_member_list["Member list<br/>group state UI<br/>[MemberList.tsx]"]
  node_round_progress["Round progress<br/>rotation state UI<br/>[RoundProgress.tsx]"]
  node_contribute_modal["Contribution modal<br/>transaction UI"]
end

subgraph group_chain["Wallet &amp; chain"]
  node_wallet{{"Wallet adapter<br/>Freighter integration<br/>[wallet.ts]"}}
  node_sorosave{{"SoroSave contract client<br/>Soroban SDK boundary<br/>[sorosave.ts]"}}
  node_soroban[("Soroban contract<br/>Stellar network")]
end

node_layout -->|"establishes"| node_providers
node_layout -->|"renders"| node_navbar
node_layout -->|"loads"| node_styles
node_navbar -->|"includes"| node_connect_wallet
node_connect_wallet -->|"connects via"| node_wallet
node_landing -->|"navigates to"| node_groups_index
node_groups_index -->|"renders"| node_group_card
node_group_card -->|"opens selected group"| node_group_detail
node_groups_index -->|"retrieves groups"| node_sorosave
node_new_group -->|"hosts"| node_create_form
node_create_form -->|"creates group"| node_sorosave
node_group_detail -->|"renders roster"| node_member_list
node_group_detail -->|"renders round"| node_round_progress
node_group_detail -->|"opens contribution"| node_contribute_modal
node_group_detail -->|"loads group by ID"| node_sorosave
node_contribute_modal -->|"submits contribution"| node_sorosave
node_sorosave -->|"requests signing"| node_wallet
node_sorosave -->|"reads and submits"| node_soroban

click node_layout "https://github.com/sorosave-protocol/frontend/blob/main/src/app/layout.tsx"
click node_providers "https://github.com/sorosave-protocol/frontend/blob/main/src/app/providers.tsx"
click node_navbar "https://github.com/sorosave-protocol/frontend/blob/main/src/components/Navbar.tsx"
click node_connect_wallet "https://github.com/sorosave-protocol/frontend/blob/main/src/components/ConnectWallet.tsx"
click node_styles "https://github.com/sorosave-protocol/frontend/blob/main/src/app/globals.css"
click node_landing "https://github.com/sorosave-protocol/frontend/blob/main/src/app/page.tsx"
click node_groups_index "https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/page.tsx"
click node_group_detail "https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/%5Bid%5D/page.tsx"
click node_new_group "https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/new/page.tsx"
click node_group_card "https://github.com/sorosave-protocol/frontend/blob/main/src/components/GroupCard.tsx"
click node_create_form "https://github.com/sorosave-protocol/frontend/blob/main/src/components/CreateGroupForm.tsx"
click node_member_list "https://github.com/sorosave-protocol/frontend/blob/main/src/components/MemberList.tsx"
click node_round_progress "https://github.com/sorosave-protocol/frontend/blob/main/src/components/RoundProgress.tsx"
click node_contribute_modal "https://github.com/sorosave-protocol/frontend/blob/main/src/components/ContributeModal.tsx"
click node_wallet "https://github.com/sorosave-protocol/frontend/blob/main/src/lib/wallet.ts"
click node_sorosave "https://github.com/sorosave-protocol/frontend/blob/main/src/lib/sorosave.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_layout,node_providers,node_navbar,node_connect_wallet,node_styles toneBlue
class node_landing,node_groups_index,node_group_detail,node_new_group toneAmber
class node_group_card,node_create_form,node_member_list,node_round_progress,node_contribute_modal toneMint
class node_wallet,node_sorosave,node_soroban toneRose
```

## Components

### App shell

- [Root layout](https://github.com/sorosave-protocol/frontend/blob/main/src/app/layout.tsx): Next.js layout · Establishes the application shell. · `src/app/layout.tsx`
- [Client providers](https://github.com/sorosave-protocol/frontend/blob/main/src/app/providers.tsx): React providers · Shared browser-side provider boundary. · `src/app/providers.tsx`
- [Navigation bar](https://github.com/sorosave-protocol/frontend/blob/main/src/components/Navbar.tsx): shared UI · `src/components/Navbar.tsx`
- [Connect wallet](https://github.com/sorosave-protocol/frontend/blob/main/src/components/ConnectWallet.tsx): wallet UI · `src/components/ConnectWallet.tsx`
- [Global styles](https://github.com/sorosave-protocol/frontend/blob/main/src/app/globals.css): Tailwind CSS · `src/app/globals.css`

### Routes

- [Landing page](https://github.com/sorosave-protocol/frontend/blob/main/src/app/page.tsx): route · `src/app/page.tsx`
- [Group discovery](https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/page.tsx): route · Retrieves and lists savings groups. · `src/app/groups/page.tsx`
- [Group detail](https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/%5Bid%5D/page.tsx): dynamic route · Loads the group selected by its route ID. · `src/app/groups/[id]/page.tsx`
- [Create group page](https://github.com/sorosave-protocol/frontend/blob/main/src/app/groups/new/page.tsx): route · `src/app/groups/new/page.tsx`

### Group UI

- [Group card](https://github.com/sorosave-protocol/frontend/blob/main/src/components/GroupCard.tsx): group summary UI · `src/components/GroupCard.tsx`
- [Create group form](https://github.com/sorosave-protocol/frontend/blob/main/src/components/CreateGroupForm.tsx): transaction UI · Collects group parameters and starts creation. · `src/components/CreateGroupForm.tsx`
- [Member list](https://github.com/sorosave-protocol/frontend/blob/main/src/components/MemberList.tsx): group state UI · `src/components/MemberList.tsx`
- [Round progress](https://github.com/sorosave-protocol/frontend/blob/main/src/components/RoundProgress.tsx): rotation state UI · `src/components/RoundProgress.tsx`
- [Contribution modal](https://github.com/sorosave-protocol/frontend/blob/main/src/components/ContributeModal.tsx): transaction UI · `src/components/ContributeModal.tsx`

### Wallet & chain

- [Wallet adapter](https://github.com/sorosave-protocol/frontend/blob/main/src/lib/wallet.ts): Freighter integration · Encapsulates account access and transaction signing. · `src/lib/wallet.ts`
- [SoroSave contract client](https://github.com/sorosave-protocol/frontend/blob/main/src/lib/sorosave.ts): Soroban SDK boundary · Reads and submits contract interactions using public chain settings. · `src/lib/sorosave.ts`
- **Soroban contract**: Stellar network · Protocol state and transaction execution on the configured network.

## Connections

- Root layout → Client providers: establishes
- Root layout → Navigation bar: renders
- Root layout → Global styles: loads
- Navigation bar → Connect wallet: includes
- Connect wallet → Wallet adapter: connects via
- Landing page → Group discovery: navigates to
- Group discovery → Group card: renders
- Group card → Group detail: opens selected group
- Group discovery → SoroSave contract client: retrieves groups
- Create group page → Create group form: hosts
- Create group form → SoroSave contract client: creates group
- Group detail → Member list: renders roster
- Group detail → Round progress: renders round
- Group detail → Contribution modal: opens contribution
- Group detail → SoroSave contract client: loads group by ID
- Contribution modal → SoroSave contract client: submits contribution
- SoroSave contract client → Wallet adapter: requests signing
- SoroSave contract client → Soroban contract: reads and submits
