# nandhan-ka/soham_game architecture

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

- Interactive diagram: https://gitdiagram.com/nandhan-ka/soham_game
- Repository: https://github.com/nandhan-ka/soham_game

## Overview

RPS Reward Server supports a classroom Rock-Paper-Scissors game: a student connects a wallet, wins five rounds, and signs an NFT mint; afterward, the browser requests a separate ETH reward from the instructor’s server. The server validates the address, enforces a per-wallet cooldown, checks its reward pool, and sends the payout; its status endpoint reports pool health. The source excerpts show the mint and reward-server implementation, but not the full game logic or contract source, so those capabilities and links rely on the README. The cooldown is a JSON-file store, not a database service.

Main entry points: [`server.js`](https://github.com/nandhan-ka/soham_game/blob/main/server.js) (POST /reward), [`app.js`](https://github.com/nandhan-ka/soham_game/blob/main/app.js) (Claim trophy), [`RockPaperScissorsNFT.sol`](https://github.com/nandhan-ka/soham_game/blob/main/RockPaperScissorsNFT.sol) (NFT contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser game"]
  node_game["Play five rounds<br/>[app.js]"]
  node_wallet["Wallet connection<br/>[app.js]"]
  node_claim["Claim trophy<br/>[app.js]"]
  node_reward_request["Reward request<br/>[app.js]"]
  node_confirmation["Reward confirmation<br/>[app.js]"]
end

subgraph group_chain["Blockchain"]
  node_contract["NFT contract"]
  node_sepolia(("Sepolia network"))
end

subgraph group_backend["Reward backend"]
  node_reward_endpoint["POST /reward<br/>[server.js]"]
  node_validation["Address validation<br/>[server.js]"]
  node_cooldown["Cooldown check<br/>[server.js]"]
  node_cooldown_store[("JSON cooldown store<br/>[server.js]")]
  node_pool_check["Pool balance check<br/>[server.js]"]
  node_sign_send["Sign and send reward<br/>[server.js]"]
  node_status_endpoint["GET /status<br/>[server.js]"]
end

node_student(("Student"))
node_rpc(("Infura RPC"))

node_student -->|"plays"| node_game
node_student -->|"connects"| node_wallet
node_wallet -->|"signs mint"| node_claim
node_game -->|"unlocks after wins"| node_claim
node_claim -->|"calls mintTrophy"| node_contract
node_contract -->|"mints NFT"| node_sepolia
node_claim -->|"requests reward"| node_reward_request
node_reward_request -->|"POST address"| node_reward_endpoint
node_reward_endpoint -->|"validates"| node_validation
node_reward_endpoint -->|"checks eligibility"| node_cooldown
node_cooldown -->|"reads and writes"| node_cooldown_store
node_reward_endpoint -->|"checks balance"| node_pool_check
node_reward_endpoint -->|"dispatches payout"| node_sign_send
node_pool_check -->|"reads balance"| node_rpc
node_sign_send -->|"sends ETH"| node_sepolia
node_reward_endpoint -->|"returns tx hash"| node_confirmation
node_student -->|"checks pool"| node_status_endpoint
node_status_endpoint -->|"reads balance"| node_rpc

click node_game "https://github.com/nandhan-ka/soham_game/blob/main/app.js"
click node_wallet "https://github.com/nandhan-ka/soham_game/blob/main/app.js"
click node_claim "https://github.com/nandhan-ka/soham_game/blob/main/app.js"
click node_contract "https://github.com/nandhan-ka/soham_game/blob/main/RockPaperScissorsNFT.sol"
click node_reward_request "https://github.com/nandhan-ka/soham_game/blob/main/app.js"
click node_reward_endpoint "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_validation "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_cooldown "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_cooldown_store "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_pool_check "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_sign_send "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_status_endpoint "https://github.com/nandhan-ka/soham_game/blob/main/server.js"
click node_confirmation "https://github.com/nandhan-ka/soham_game/blob/main/app.js"

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_game,node_wallet,node_claim,node_reward_request,node_confirmation toneBlue
class node_contract,node_sepolia toneAmber
class node_reward_endpoint,node_validation,node_cooldown,node_cooldown_store,node_pool_check,node_sign_send,node_status_endpoint toneMint
class node_student,node_rpc toneIndigo
```

## Components

### Browser game

- [Play five rounds](https://github.com/nandhan-ka/soham_game/blob/main/app.js): `app.js`
- [Wallet connection](https://github.com/nandhan-ka/soham_game/blob/main/app.js): `app.js`
- [Claim trophy](https://github.com/nandhan-ka/soham_game/blob/main/app.js): `app.js`
- [Reward request](https://github.com/nandhan-ka/soham_game/blob/main/app.js): `app.js`
- [Reward confirmation](https://github.com/nandhan-ka/soham_game/blob/main/app.js): `app.js`

### Blockchain

- [NFT contract](https://github.com/nandhan-ka/soham_game/blob/main/RockPaperScissorsNFT.sol): `RockPaperScissorsNFT.sol`
- **Sepolia network**

### Reward backend

- [POST /reward](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [Address validation](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [Cooldown check](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [JSON cooldown store](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [Pool balance check](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [Sign and send reward](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`
- [GET /status](https://github.com/nandhan-ka/soham_game/blob/main/server.js): `server.js`

### Other components

- **Student**
- **Infura RPC**

## Connections

- Student → Play five rounds: plays (evidence: `README.md`)
- Student → Wallet connection: connects (evidence: `README.md`)
- Wallet connection → Claim trophy: signs mint (evidence: `README.md`)
- Play five rounds → Claim trophy: unlocks after wins (evidence: `README.md`)
- Claim trophy → NFT contract: calls mintTrophy (evidence: `README.md`)
- NFT contract → Sepolia network: mints NFT (evidence: `README.md`)
- Claim trophy → Reward request: requests reward (evidence: `app.js`)
- Reward request → POST /reward: POST address (evidence: `README.md`)
- POST /reward → Address validation: validates (evidence: `server.js`)
- POST /reward → Cooldown check: checks eligibility (evidence: `server.js`)
- Cooldown check → JSON cooldown store: reads and writes (evidence: `server.js`)
- POST /reward → Pool balance check: checks balance (evidence: `server.js`)
- POST /reward → Sign and send reward: dispatches payout (evidence: `server.js`)
- Pool balance check → Infura RPC: reads balance (evidence: `server.js`)
- Sign and send reward → Sepolia network: sends ETH (evidence: `server.js`)
- POST /reward → Reward confirmation: returns tx hash (evidence: `README.md`)
- Student → GET /status: checks pool (evidence: `README.md`)
- GET /status → Infura RPC: reads balance (evidence: `server.js`)
