# revulakshman/coinflip_solana_wallet architecture

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

## Overview

This is a React/Solana Devnet coin-flip betting game. A player connects a wallet, chooses a side and bet, submits a bet transaction, sees a client-generated flip result, and can view game history and statistics. The sampled code shows transaction submission and simulated winnings; the flip is explicitly demo randomness, not verifiable randomness. UI primitives are grouped as a shared layer. Several listed UI modules and unsampled parts of CoinFlip were not inspected, so the graph omits unsupported details.

Main entry points: [`src/components/CoinFlip.tsx`](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/CoinFlip.tsx) (Coin flip game), [`src/App.tsx`](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/App.tsx) (App shell), [`src/contexts/WalletContextProvider.tsx`](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/contexts/WalletContextProvider.tsx) (Wallet context), [`src/utils/solana.ts`](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts) (Bet transaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_index["Game page<br/>[Index.tsx]"]
  node_coinflip["Coin flip game<br/>[CoinFlip.tsx]"]
  node_game_state[("Game state, history, stats<br/>[CoinFlip.tsx]")]
  node_not_found["Not-found page<br/>[NotFound.tsx]"]
end

subgraph group_solana["Wallet and Solana"]
  node_wallet_provider["Wallet context"]
  node_bet_tx["Bet transaction<br/>[solana.ts]"]
  node_flip_logic["Flip logic<br/>[solana.ts]"]
  node_winnings["Winnings transaction<br/>[solana.ts]"]
  node_rpc{{"Solana Devnet RPC"}}
  node_wallet_adapters{{"Phantom, Solflare"}}
end

subgraph group_shared["Shared UI"]
  node_ui["UI primitives"]
  node_toast_hook["Toast state<br/>[use-toast.ts]"]
  node_toaster["Toast renderer<br/>[toaster.tsx]"]
end

node_player(("Player"))

node_player -->|"opens"| node_app
node_app -->|"routes to"| node_index
node_app -->|"provides wallet"| node_wallet_provider
node_app -->|"renders"| node_toaster
node_app -->|"fallback route"| node_not_found
node_index -->|"renders"| node_coinflip
node_coinflip -->|"updates"| node_game_state
node_coinflip -->|"submits bet"| node_bet_tx
node_coinflip -->|"gets result"| node_flip_logic
node_coinflip -->|"requests payout"| node_winnings
node_coinflip -->|"renders with"| node_ui
node_coinflip -.->|"reads wallet"| node_wallet_provider
node_wallet_provider -->|"configures Devnet"| node_rpc
node_wallet_provider -->|"registers"| node_wallet_adapters
node_bet_tx -->|"sends transaction"| node_rpc
node_bet_tx -->|"requests signature"| node_wallet_adapters
node_winnings -->|"simulates payout"| node_rpc
node_toaster -->|"reads toast state"| node_toast_hook

click node_app "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/App.tsx"
click node_index "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/pages/Index.tsx"
click node_coinflip "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/CoinFlip.tsx"
click node_game_state "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/CoinFlip.tsx"
click node_wallet_provider "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/contexts/WalletContextProvider.tsx"
click node_bet_tx "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts"
click node_flip_logic "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts"
click node_winnings "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts"
click node_ui "https://github.com/revulakshman/coinflip_solana_wallet/tree/main/src/components/ui"
click node_toast_hook "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/hooks/use-toast.ts"
click node_toaster "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/ui/toaster.tsx"
click node_not_found "https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/pages/NotFound.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_index,node_coinflip,node_game_state,node_not_found toneBlue
class node_wallet_provider,node_bet_tx,node_flip_logic,node_winnings,node_rpc,node_wallet_adapters toneAmber
class node_ui,node_toast_hook,node_toaster toneMint
class node_player toneIndigo
```

## Components

### Game experience

- [App shell](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/App.tsx): `src/App.tsx`
- [Game page](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [Coin flip game](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/CoinFlip.tsx): `src/components/CoinFlip.tsx`
- [Game state, history, stats](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/CoinFlip.tsx): `src/components/CoinFlip.tsx`
- [Not-found page](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/pages/NotFound.tsx): `src/pages/NotFound.tsx`

### Wallet and Solana

- [Wallet context](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/contexts/WalletContextProvider.tsx): `src/contexts/WalletContextProvider.tsx`
- [Bet transaction](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts): `src/utils/solana.ts`
- [Flip logic](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts): `src/utils/solana.ts`
- [Winnings transaction](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/utils/solana.ts): `src/utils/solana.ts`
- **Solana Devnet RPC**
- **Phantom, Solflare**

### Shared UI

- [UI primitives](https://github.com/revulakshman/coinflip_solana_wallet/tree/main/src/components/ui): `src/components/ui`
- [Toast state](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/hooks/use-toast.ts): `src/hooks/use-toast.ts`
- [Toast renderer](https://github.com/revulakshman/coinflip_solana_wallet/blob/main/src/components/ui/toaster.tsx): `src/components/ui/toaster.tsx`

### Other components

- **Player**

## Connections

- Player → App shell: opens
- App shell → Game page: routes to (evidence: `src/App.tsx`)
- App shell → Wallet context: provides wallet (evidence: `src/App.tsx`)
- App shell → Toast renderer: renders (evidence: `src/App.tsx`)
- App shell → Not-found page: fallback route (evidence: `src/App.tsx`)
- Game page → Coin flip game: renders (evidence: `src/pages/Index.tsx`)
- Coin flip game → Game state, history, stats: updates (evidence: `src/components/CoinFlip.tsx`)
- Coin flip game → Bet transaction: submits bet (evidence: `src/components/CoinFlip.tsx`)
- Coin flip game → Flip logic: gets result (evidence: `src/components/CoinFlip.tsx`)
- Coin flip game → Winnings transaction: requests payout (evidence: `src/components/CoinFlip.tsx`)
- Coin flip game → UI primitives: renders with (evidence: `src/components/CoinFlip.tsx`)
- Coin flip game → Wallet context: reads wallet
- Wallet context → Solana Devnet RPC: configures Devnet (evidence: `src/contexts/WalletContextProvider.tsx`)
- Wallet context → Phantom, Solflare: registers (evidence: `src/contexts/WalletContextProvider.tsx`)
- Bet transaction → Solana Devnet RPC: sends transaction (evidence: `src/utils/solana.ts`)
- Bet transaction → Phantom, Solflare: requests signature (evidence: `src/utils/solana.ts`)
- Winnings transaction → Solana Devnet RPC: simulates payout (evidence: `src/utils/solana.ts`)
- Toast renderer → Toast state: reads toast state (evidence: `src/components/ui/toaster.tsx`)
