# tippi-fifestarr/sadcoin-email architecture

> Architecture diagram of the GitHub repository tippi-fifestarr/sadcoin-email, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tippi-fifestarr/sadcoin-email
- Repository: https://github.com/tippi-fifestarr/sadcoin-email

## Overview

This is a Next.js Web3 productivity game: a player connects a wallet, progresses through corporate-character and mini-game stages, turns their input into an editable AI-generated email, and sends it. The README also documents token purchases, staking/rewards, conversions, achievement NFTs, and multi-network support. The graph distinguishes the game orchestrator, email-generation and delivery services, and blockchain UI/integration. Some screen and contract implementation details were not sampled; unsourced subsystem links are omitted rather than inferred.

Main entry points: [`sad-email-frontend/src/main-game.tsx`](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/main-game.tsx) (Game flow), [`sad-email-frontend/src/hooks/useContracts.ts`](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/hooks/useContracts.ts) (Contract actions), [`sad-email-frontend/src/app/api/generate-email/route.ts`](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/api/generate-email/route.ts) (Generation API), [`sad-email-frontend/context/appkit.tsx`](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/context/appkit.tsx) (Wallet connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game experience"]
  node_entry["Game entry<br/>[page.tsx]"]
  node_orchestrator["Game flow<br/>[main-game.tsx]"]
  node_screens["Game screens"]
  node_character["Character content<br/>[gameData.ts]"]
  node_terminal["Terminal UI<br/>[CRTContainer.tsx]"]
  node_about["Game explanation<br/>[about-page.tsx]"]
end

subgraph group_email["Email workflow"]
  node_email_input["Email input"]
  node_writing["Email editing<br/>[WritingScreen.tsx]"]
  node_delivery["Email delivery API<br/>[route.ts]"]
end

subgraph group_ai["AI generation"]
  node_ai_api["Generation API<br/>[route.ts]"]
  node_bedrock["Bedrock provider<br/>[bedrock.ts]"]
  node_gemini["Gemini provider<br/>[gemini.ts]"]
  node_ai_service["AI model service"]
end

subgraph group_web3["Wallet and rewards"]
  node_nav["Navigation and wallet UI<br/>[NavBar.tsx]"]
  node_wallet_config["Wallet connection<br/>[appkit.tsx]"]
  node_contracts_hook["Contract actions<br/>[useContracts.ts]"]
  node_contract_config["Contract interfaces<br/>[contracts.ts]"]
  node_watercooler["Staking screen"]
  node_debug["Debug controls<br/>[DebugPanel.tsx]"]
  node_network["Network switcher"]
end

node_player(("Player"))
node_recipient(("Recipient inbox"))
node_wallet(("Wallet user"))
node_chain[("Blockchain networks")]

node_player -->|"opens game"| node_entry
node_entry -->|"renders"| node_orchestrator
node_orchestrator -->|"routes screens"| node_screens
node_orchestrator -->|"renders in"| node_terminal
node_orchestrator -->|"renders"| node_nav
node_orchestrator -->|"offers details"| node_about
node_orchestrator -.->|"uses character data"| node_character
node_orchestrator -.->|"collects input"| node_email_input
node_orchestrator -.->|"requests generation"| node_ai_api
node_orchestrator -.->|"presents draft"| node_writing
node_writing -.->|"submits email"| node_delivery
node_delivery -.->|"sends email"| node_recipient
node_ai_api -.->|"selects provider"| node_bedrock
node_ai_api -.->|"selects provider"| node_gemini
node_bedrock -.->|"generates text"| node_ai_service
node_gemini -.->|"generates text"| node_ai_service
node_wallet -->|"connects"| node_wallet_config
node_wallet_config -->|"configures networks"| node_chain
node_nav -.->|"initiates connection"| node_wallet_config
node_orchestrator -.->|"opens staking"| node_watercooler
node_watercooler -->|"calls staking actions"| node_contracts_hook
node_debug -->|"tests contract actions"| node_contracts_hook
node_debug -->|"renders switcher"| node_network
node_contracts_hook -.->|"uses interfaces"| node_contract_config
node_contracts_hook -.->|"reads and writes"| node_chain
node_network -.->|"switches network"| node_chain

click node_entry "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/page.tsx"
click node_orchestrator "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/main-game.tsx"
click node_screens "https://github.com/tippi-fifestarr/sadcoin-email/tree/main/sad-email-frontend/src/components/screens"
click node_character "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/data/gameData.ts"
click node_terminal "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/CRTContainer.tsx"
click node_nav "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/NavBar.tsx"
click node_about "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/about-page.tsx"
click node_email_input "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/EmailInputScreen.tsx"
click node_writing "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/WritingScreen.tsx"
click node_ai_api "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/api/generate-email/route.ts"
click node_bedrock "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/bedrock.ts"
click node_gemini "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/gemini.ts"
click node_delivery "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/api/send-email/route.ts"
click node_wallet_config "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/context/appkit.tsx"
click node_contracts_hook "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/hooks/useContracts.ts"
click node_contract_config "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/contracts.ts"
click node_watercooler "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/WaterCoolerScreen.tsx"
click node_debug "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/DebugPanel.tsx"
click node_network "https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/NetworkSwitcher.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_entry,node_orchestrator,node_screens,node_character,node_terminal,node_about,node_wallet toneBlue
class node_email_input,node_writing,node_delivery,node_chain toneAmber
class node_ai_api,node_bedrock,node_gemini,node_ai_service toneMint
class node_nav,node_wallet_config,node_contracts_hook,node_contract_config,node_watercooler,node_debug,node_network toneRose
class node_player,node_recipient toneIndigo
```

## Components

### Game experience

- [Game entry](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/page.tsx): `sad-email-frontend/src/app/page.tsx`
- [Game flow](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/main-game.tsx): `sad-email-frontend/src/main-game.tsx`
- [Game screens](https://github.com/tippi-fifestarr/sadcoin-email/tree/main/sad-email-frontend/src/components/screens): `sad-email-frontend/src/components/screens`
- [Character content](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/data/gameData.ts): `sad-email-frontend/src/data/gameData.ts`
- [Terminal UI](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/CRTContainer.tsx): `sad-email-frontend/src/components/CRTContainer.tsx`
- [Game explanation](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/about-page.tsx): `sad-email-frontend/src/about-page.tsx`

### Email workflow

- [Email input](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/EmailInputScreen.tsx): `sad-email-frontend/src/components/screens/EmailInputScreen.tsx`
- [Email editing](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/WritingScreen.tsx): `sad-email-frontend/src/components/screens/WritingScreen.tsx`
- [Email delivery API](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/api/send-email/route.ts): `sad-email-frontend/src/app/api/send-email/route.ts`

### AI generation

- [Generation API](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/app/api/generate-email/route.ts): `sad-email-frontend/src/app/api/generate-email/route.ts`
- [Bedrock provider](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/bedrock.ts): `sad-email-frontend/src/lib/bedrock.ts`
- [Gemini provider](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/gemini.ts): `sad-email-frontend/src/lib/gemini.ts`
- **AI model service**

### Wallet and rewards

- [Navigation and wallet UI](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/NavBar.tsx): `sad-email-frontend/src/components/NavBar.tsx`
- [Wallet connection](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/context/appkit.tsx): `sad-email-frontend/context/appkit.tsx`
- [Contract actions](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/hooks/useContracts.ts): `sad-email-frontend/src/hooks/useContracts.ts`
- [Contract interfaces](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/lib/contracts.ts): `sad-email-frontend/src/lib/contracts.ts`
- [Staking screen](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/screens/WaterCoolerScreen.tsx): `sad-email-frontend/src/components/screens/WaterCoolerScreen.tsx`
- [Debug controls](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/DebugPanel.tsx): `sad-email-frontend/src/components/DebugPanel.tsx`
- [Network switcher](https://github.com/tippi-fifestarr/sadcoin-email/blob/main/sad-email-frontend/src/components/NetworkSwitcher.tsx): `sad-email-frontend/src/components/NetworkSwitcher.tsx`

### Other components

- **Player**
- **Recipient inbox**
- **Wallet user**
- **Blockchain networks**

## Connections

- Player → Game entry: opens game (evidence: `sad-email-frontend/src/app/page.tsx`)
- Game entry → Game flow: renders (evidence: `sad-email-frontend/src/app/page.tsx`)
- Game flow → Game screens: routes screens (evidence: `sad-email-frontend/src/main-game.tsx`)
- Game flow → Terminal UI: renders in (evidence: `sad-email-frontend/src/main-game.tsx`)
- Game flow → Navigation and wallet UI: renders (evidence: `sad-email-frontend/src/main-game.tsx`)
- Game flow → Game explanation: offers details
- Game flow → Character content: uses character data
- Game flow → Email input: collects input
- Game flow → Generation API: requests generation
- Game flow → Email editing: presents draft
- Email editing → Email delivery API: submits email
- Email delivery API → Recipient inbox: sends email
- Generation API → Bedrock provider: selects provider
- Generation API → Gemini provider: selects provider
- Bedrock provider → AI model service: generates text
- Gemini provider → AI model service: generates text
- Wallet user → Wallet connection: connects (evidence: `sad-email-frontend/context/appkit.tsx`)
- Wallet connection → Blockchain networks: configures networks (evidence: `sad-email-frontend/context/appkit.tsx`)
- Navigation and wallet UI → Wallet connection: initiates connection
- Game flow → Staking screen: opens staking
- Staking screen → Contract actions: calls staking actions (evidence: `sad-email-frontend/src/components/screens/WaterCoolerScreen.tsx`)
- Debug controls → Contract actions: tests contract actions (evidence: `sad-email-frontend/src/components/DebugPanel.tsx`)
- Debug controls → Network switcher: renders switcher (evidence: `sad-email-frontend/src/components/DebugPanel.tsx`)
- Contract actions → Contract interfaces: uses interfaces
- Contract actions → Blockchain networks: reads and writes
- Network switcher → Blockchain networks: switches network
