# mitchyugan/obscura-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/mitchyugan/obscura-frontend
- Repository: https://github.com/mitchyugan/obscura-frontend

## Overview

1. **Repository scope**
   This repo is the **Next.js 15 frontend for Obscura**, a Starknet dapp for shielded strkBTC payments. The on-chain shielded pool and ERC20 token are described in the README, but the file tree here is primarily the **UI + wallet orchestration layer**, not the Cairo contract source itself.

2. **Top-level app structure**
   The app uses the **Next.js App Router**. `app/layout.tsx` and `app/globals.css` provide the global shell and styling, while `app/page.tsx` is the public landing page. `app/app/page.tsx` is the main authenticated dapp surface where wallet actions and pool operations happen.

3. **Main user flows**
   The frontend centers on three flows: **connect a wallet**, **inspect balances/status**, and **execute pool actions** such as deposit, withdraw, transfer, and faucet/mint-related actions. These flows are coordinated through shared wallet state and then dispatched to Starknet contracts.

4. **Wallet and account orchestration**
   `store/wallet-context.tsx` is the primary client-side state boundary. It likely tracks the selected wallet type, connection status, account/address, contract instances, and transaction state. This is the central bridge between UI components and chain interactions.

5. **Connection layer**
   `components/frontend/connect-button.tsx`, `connect-modal.tsx`, and `privy-provider.tsx` implement the wallet onboarding experience. The README shows two wallet modes:
   - **Social login** via Privy/StarkZap, backed by server-side signing
   - **Browser wallets** via `get-starknet-core` / Starknet.js  
   This creates a split between extension-based signing in the browser and managed social-login accounts.

6. **Backend signing API**
   The only backend routes are under `app/api/wallet/`:
   - `app/api/wallet/sign/route.ts`
   - `app/api/wallet/starknet/route.ts`  
   These are the server-side trust boundary for social-login wallet operations. They exist to support signing/account-related Starknet actions without exposing private credentials to the browser.

7. **Contract interaction layer**
   `lib/contracts.ts` is the main chain integration module. It likely holds:
   - deployed contract addresses from env/config
   - ABIs / call selectors
   - helpers for creating contract instances and formatting Starknet calls  
   This module is the standard entry point from UI state into on-chain reads/writes.

8. **Transaction-oriented UI**
   `components/pool/` contains the action forms:
   - `deposit-form.tsx`
   - `withdraw-form.tsx`
   - `transfer-form.tsx`
   - `faucet-form.tsx`  
   These map directly to the pool’s contract operations and likely consume wallet context plus contract helpers. They are the main “write” surfaces of the app.

9. **Read/feedback surfaces**
   `components/frontend/balance-cards.tsx` presents user and pool balances, while `components/frontend/tx-status.tsx` provides transaction lifecycle feedback. Together they form the main read-only feedback loop from chain state back to the user.

10. **Shared UI primitives**
   `components/ui/` contains reusable presentation primitives (`button`, `card`, `dialog`, `input`, `label`, `badge`). These are generic building blocks used across wallet onboarding and pool forms, keeping domain logic out of the visual layer.

11. **Styling and app shell**
   The app uses **Tailwind-based component styling** with `components.json`, `globals.css`, and standard Next.js layout files. This indicates a client-heavy dapp UI with no separate design-system service or rendering backend.

12. **External dependencies that matter architecturally**
   The architecture depends on:
   - **Starknet Sepolia RPC** for chain reads/writes
   - **Privy** for social login identity
   - **AVNU paymaster** for gas sponsorship on social-login flows
   - **Browser wallets** for self-custodied signing  
   These are not just libraries; they define the key trust and execution boundaries of the app.

13. **End-to-end data flow**
   A typical transaction path is: user action in a pool form → wallet context resolves signer/account → contract helper builds Starknet call → either browser wallet signs locally or API route assists social-login signing → RPC sends transaction → tx status component reflects result → balance cards refresh on-chain state.

14. **Architectural takeaway**
   The repo is a **thin frontend over Starknet contracts**, with most complexity concentrated in wallet connection, signing mode selection, and transaction UX. There is no evident database, job queue, or server-side business logic beyond the wallet/signing API routes.

Main entry points: [`app/app/page.tsx`](https://github.com/mitchyugan/obscura-frontend/blob/main/app/app/page.tsx) (Dapp page), [`store/wallet-context.tsx`](https://github.com/mitchyugan/obscura-frontend/blob/main/store/wallet-context.tsx) (Wallet state), [`lib/contracts.ts`](https://github.com/mitchyugan/obscura-frontend/blob/main/lib/contracts.ts) (Contracts), [`components/ui`](https://github.com/mitchyugan/obscura-frontend/tree/main/components/ui) (UI kit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App shell"]
  node_node_app_layout["Layout<br/>[layout.tsx]"]
  node_node_app_home["Landing<br/>public page<br/>[page.tsx]"]
  node_node_app_dapp["Dapp page<br/>authenticated page<br/>[page.tsx]"]
  node_node_app_styles["Globals<br/>css base<br/>[globals.css]"]
end

subgraph group_group_wallet["Wallet layer"]
  node_node_wallet_context[("Wallet state<br/>client store<br/>[wallet-context.tsx]")]
  node_node_connect_button["Connect btn<br/>ui trigger<br/>[connect-button.tsx]"]
  node_node_connect_modal["Connect modal<br/>wallet chooser<br/>[connect-modal.tsx]"]
  node_node_privy_provider["Privy provider<br/>auth bridge<br/>[privy-provider.tsx]"]
end

subgraph group_group_pool["Pool actions"]
  node_node_pool_deposit["Deposit<br/>pool form<br/>[deposit-form.tsx]"]
  node_node_pool_withdraw["Withdraw<br/>pool form<br/>[withdraw-form.tsx]"]
  node_node_pool_transfer["Transfer<br/>pool form<br/>[transfer-form.tsx]"]
  node_node_pool_faucet["Faucet<br/>pool form<br/>[faucet-form.tsx]"]
end

subgraph group_group_shared["Shared UI"]
  node_node_contracts["Contracts<br/>chain helper<br/>[contracts.ts]"]
  node_node_balance_cards["Balances<br/>status cards<br/>[balance-cards.tsx]"]
  node_node_tx_status["Tx status<br/>feedback panel<br/>[tx-status.tsx]"]
  node_node_ui_primitives["UI kit<br/>components"]
end

subgraph group_group_api["Backend API"]
  node_node_api_sign["Sign API<br/>server route<br/>[route.ts]"]
  node_node_api_starknet["Starknet API<br/>server route<br/>[route.ts]"]
end

node_node_app_layout -->|"wraps"| node_node_privy_provider
node_node_app_layout -->|"loads"| node_node_app_styles
node_node_app_home -->|"uses"| node_node_connect_button
node_node_app_dapp -->|"consumes"| node_node_wallet_context
node_node_app_dapp -->|"shows"| node_node_balance_cards
node_node_app_dapp -->|"shows"| node_node_tx_status
node_node_app_dapp -->|"hosts"| node_node_pool_deposit
node_node_app_dapp -->|"hosts"| node_node_pool_withdraw
node_node_app_dapp -->|"hosts"| node_node_pool_transfer
node_node_app_dapp -->|"hosts"| node_node_pool_faucet
node_node_connect_button -->|"opens"| node_node_connect_modal
node_node_connect_modal -->|"updates"| node_node_wallet_context
node_node_privy_provider -->|"authenticates"| node_node_api_sign
node_node_privy_provider -->|"authenticates"| node_node_api_starknet
node_node_wallet_context -->|"drives"| node_node_contracts
node_node_wallet_context -->|"routes"| node_node_api_sign
node_node_wallet_context -->|"routes"| node_node_api_starknet
node_node_pool_deposit -->|"calls"| node_node_contracts
node_node_pool_withdraw -->|"calls"| node_node_contracts
node_node_pool_transfer -->|"calls"| node_node_contracts
node_node_pool_faucet -->|"calls"| node_node_contracts
node_node_balance_cards -->|"reads"| node_node_contracts
node_node_tx_status -->|"observes"| node_node_wallet_context
node_node_connect_button -->|"uses"| node_node_ui_primitives
node_node_pool_deposit -->|"uses"| node_node_ui_primitives
node_node_pool_withdraw -->|"uses"| node_node_ui_primitives
node_node_pool_transfer -->|"uses"| node_node_ui_primitives
node_node_pool_faucet -->|"uses"| node_node_ui_primitives

click node_node_app_layout "https://github.com/mitchyugan/obscura-frontend/blob/main/app/layout.tsx"
click node_node_app_home "https://github.com/mitchyugan/obscura-frontend/blob/main/app/page.tsx"
click node_node_app_dapp "https://github.com/mitchyugan/obscura-frontend/blob/main/app/app/page.tsx"
click node_node_app_styles "https://github.com/mitchyugan/obscura-frontend/blob/main/app/globals.css"
click node_node_wallet_context "https://github.com/mitchyugan/obscura-frontend/blob/main/store/wallet-context.tsx"
click node_node_connect_button "https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/connect-button.tsx"
click node_node_connect_modal "https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/connect-modal.tsx"
click node_node_privy_provider "https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/privy-provider.tsx"
click node_node_contracts "https://github.com/mitchyugan/obscura-frontend/blob/main/lib/contracts.ts"
click node_node_pool_deposit "https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/deposit-form.tsx"
click node_node_pool_withdraw "https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/withdraw-form.tsx"
click node_node_pool_transfer "https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/transfer-form.tsx"
click node_node_pool_faucet "https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/faucet-form.tsx"
click node_node_balance_cards "https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/balance-cards.tsx"
click node_node_tx_status "https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/tx-status.tsx"
click node_node_ui_primitives "https://github.com/mitchyugan/obscura-frontend/tree/main/components/ui"
click node_node_api_sign "https://github.com/mitchyugan/obscura-frontend/blob/main/app/api/wallet/sign/route.ts"
click node_node_api_starknet "https://github.com/mitchyugan/obscura-frontend/blob/main/app/api/wallet/starknet/route.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_node_app_layout,node_node_app_home,node_node_app_dapp,node_node_app_styles toneBlue
class node_node_wallet_context,node_node_connect_button,node_node_connect_modal,node_node_privy_provider toneAmber
class node_node_pool_deposit,node_node_pool_withdraw,node_node_pool_transfer,node_node_pool_faucet toneMint
class node_node_contracts,node_node_balance_cards,node_node_tx_status,node_node_ui_primitives toneRose
class node_node_api_sign,node_node_api_starknet toneIndigo
```

## Components

### App shell

Next.js routes, layout, and global styling for the dapp.

- [Layout](https://github.com/mitchyugan/obscura-frontend/blob/main/app/layout.tsx): next layout · Global app shell and providers entry. · `app/layout.tsx`
- [Landing](https://github.com/mitchyugan/obscura-frontend/blob/main/app/page.tsx): public page · Public entry page for the frontend. · `app/page.tsx`
- [Dapp page](https://github.com/mitchyugan/obscura-frontend/blob/main/app/app/page.tsx): authenticated page · Main application surface for wallet and pool interactions. · `app/app/page.tsx`
- [Globals](https://github.com/mitchyugan/obscura-frontend/blob/main/app/globals.css): css base · Application-wide styling layer. · `app/globals.css`

### Wallet layer

Connection, identity, and signing orchestration.

- [Wallet state](https://github.com/mitchyugan/obscura-frontend/blob/main/store/wallet-context.tsx): client store · Central client state for account, connection, contracts, and tx flow. · `store/wallet-context.tsx`
- [Connect btn](https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/connect-button.tsx): ui trigger · Entry point for wallet connection. · `components/frontend/connect-button.tsx`
- [Connect modal](https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/connect-modal.tsx): wallet chooser · Wallet onboarding and mode selection UI. · `components/frontend/connect-modal.tsx`
- [Privy provider](https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/privy-provider.tsx): auth bridge · Social-login identity and wallet provider integration. · `components/frontend/privy-provider.tsx`

### Pool actions

User-facing transaction forms for shielded pool operations.

- [Deposit](https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/deposit-form.tsx): pool form · UI for depositing into the shielded pool. · `components/pool/deposit-form.tsx`
- [Withdraw](https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/withdraw-form.tsx): pool form · UI for withdrawing from the shielded pool. · `components/pool/withdraw-form.tsx`
- [Transfer](https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/transfer-form.tsx): pool form · UI for shielded transfer actions. · `components/pool/transfer-form.tsx`
- [Faucet](https://github.com/mitchyugan/obscura-frontend/blob/main/components/pool/faucet-form.tsx): pool form · UI for mint or faucet-related actions. · `components/pool/faucet-form.tsx`

### Shared UI

Reusable presentation primitives and chain helpers.

- [Contracts](https://github.com/mitchyugan/obscura-frontend/blob/main/lib/contracts.ts): chain helper · Starknet contract addresses, instances, and call helpers. · `lib/contracts.ts`
- [Balances](https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/balance-cards.tsx): status cards · Read-only balance and pool status display. · `components/frontend/balance-cards.tsx`
- [Tx status](https://github.com/mitchyugan/obscura-frontend/blob/main/components/frontend/tx-status.tsx): feedback panel · Transaction lifecycle and result feedback. · `components/frontend/tx-status.tsx`
- [UI kit](https://github.com/mitchyugan/obscura-frontend/tree/main/components/ui): components · Reusable visual primitives used across the app. · `components/ui`

### Backend API

Server-side signing endpoints for social-login wallet flows.

- [Sign API](https://github.com/mitchyugan/obscura-frontend/blob/main/app/api/wallet/sign/route.ts): server route · Server-side signing endpoint for wallet operations. · `app/api/wallet/sign/route.ts`
- [Starknet API](https://github.com/mitchyugan/obscura-frontend/blob/main/app/api/wallet/starknet/route.ts): server route · Backend route supporting social-login Starknet actions. · `app/api/wallet/starknet/route.ts`

## Connections

- Layout → Privy provider: wraps · The app shell includes the social-login provider boundary.
- Layout → Globals: loads · Global layout applies shared styles.
- Landing → Connect btn: uses · Public landing page exposes connection entry point.
- Dapp page → Wallet state: consumes · Authenticated surface reads shared wallet state.
- Dapp page → Balances: shows · Main surface displays balances and pool status.
- Dapp page → Tx status: shows · Main surface displays transaction feedback.
- Dapp page → Deposit: hosts · Main surface contains pool action forms.
- Dapp page → Withdraw: hosts · Main surface contains pool action forms.
- Dapp page → Transfer: hosts · Main surface contains pool action forms.
- Dapp page → Faucet: hosts · Main surface contains pool action forms.
- Connect btn → Connect modal: opens · Connection button launches wallet chooser modal.
- Connect modal → Wallet state: updates · Selected wallet mode and session state flow into shared store.
- Privy provider → Sign API: authenticates · Social-login flows rely on backend signing support.
- Privy provider → Starknet API: authenticates · Social-login Starknet actions are mediated by server routes.
- Wallet state → Contracts: drives · Wallet state resolves contract access and call execution.
- Wallet state → Sign API: routes · Managed-wallet flows delegate signing to the server boundary.
- Wallet state → Starknet API: routes · Managed-wallet flows delegate Starknet actions to the server boundary.
- Deposit → Contracts: calls · Deposit form submits Starknet contract actions.
- Withdraw → Contracts: calls · Withdraw form submits Starknet contract actions.
- Transfer → Contracts: calls · Transfer form submits Starknet contract actions.
- Faucet → Contracts: calls · Faucet form submits mint-related contract actions.
- Balances → Contracts: reads · Balance cards reflect on-chain state.
- Tx status → Wallet state: observes · Tx feedback tracks the shared transaction state.
- Connect btn → UI kit: uses · Connection UI is built from shared primitives.
- Deposit → UI kit: uses · Pool forms use shared inputs and controls.
- Withdraw → UI kit: uses · Pool forms use shared inputs and controls.
- Transfer → UI kit: uses · Pool forms use shared inputs and controls.
- Faucet → UI kit: uses · Pool forms use shared inputs and controls.
