# foyin/minesweeper2 architecture

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

- Interactive diagram: https://gitdiagram.com/foyin/minesweeper2
- Repository: https://github.com/foyin/minesweeper2

## Overview

Minesweeper2 is a browser Minesweeper game with optional Cognito accounts and a cloud leaderboard. A player enters through the React app, reaches the game from the home page, and plays rounds with difficulty, timer, win/loss, and scoring behavior. The game fetches and updates leaderboard entries through a configured HTTP endpoint; signed-in users can register, confirm, sign in, and sign out. The excerpts show frontend calls and Cognito operations; the README documents API Gateway and DynamoDB, but the backend flow itself is not shown.

Main entry points: [`src/App.tsx`](https://github.com/foyin/minesweeper2/blob/main/src/App.tsx) (Routes), [`src/authService.ts`](https://github.com/foyin/minesweeper2/blob/main/src/authService.ts) (Cognito operations), [`src/homePage.tsx`](https://github.com/foyin/minesweeper2/blob/main/src/homePage.tsx) (Home page), [`src/Minesweeper/minsweeper.tsx`](https://github.com/foyin/minesweeper2/blob/main/src/Minesweeper/minsweeper.tsx) (Leaderboard requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and game"]
  node_entry["React entry<br/>[main.tsx]"]
  node_router["Routes<br/>[App.tsx]"]
  node_home["Home page<br/>[homePage.tsx]"]
  node_game["Minesweeper game<br/>[minsweeper.tsx]"]
end

subgraph group_identity["Account access"]
  node_login["Login and signup<br/>[loginPage.tsx]"]
  node_confirm["Account confirmation"]
  node_auth["Cognito operations<br/>[authService.ts]"]
end

subgraph group_scores["Leaderboard"]
  node_scoretype["Score contract<br/>[winnerInterface.ts]"]
  node_leaderboard["Leaderboard requests<br/>[minsweeper.tsx]"]
end

subgraph group_cloud["Cloud services"]
  node_api{{"API Gateway endpoint"}}
  node_dynamo[("DynamoDB")]
  node_cognito{{"Amazon Cognito"}}
end

node_player(("Player"))

node_player -->|"opens app"| node_entry
node_entry -->|"renders"| node_router
node_router -->|"routes"| node_home
node_router -->|"routes"| node_login
node_router -->|"routes"| node_confirm
node_home -->|"renders"| node_game
node_player -->|"plays"| node_game
node_login -->|"calls"| node_auth
node_confirm -->|"calls"| node_auth
node_home -->|"signs out through"| node_auth
node_auth -->|"sends auth commands"| node_cognito
node_game -->|"manages scores"| node_leaderboard
node_leaderboard -->|"gets and updates"| node_api
node_leaderboard -->|"uses score type"| node_scoretype
node_api -.->|"persists scores"| node_dynamo

click node_entry "https://github.com/foyin/minesweeper2/blob/main/src/main.tsx"
click node_router "https://github.com/foyin/minesweeper2/blob/main/src/App.tsx"
click node_home "https://github.com/foyin/minesweeper2/blob/main/src/homePage.tsx"
click node_game "https://github.com/foyin/minesweeper2/blob/main/src/Minesweeper/minsweeper.tsx"
click node_scoretype "https://github.com/foyin/minesweeper2/blob/main/src/winnerInterface.ts"
click node_login "https://github.com/foyin/minesweeper2/blob/main/src/loginPage.tsx"
click node_confirm "https://github.com/foyin/minesweeper2/blob/main/src/confirmUserPage.tsx"
click node_auth "https://github.com/foyin/minesweeper2/blob/main/src/authService.ts"
click node_leaderboard "https://github.com/foyin/minesweeper2/blob/main/src/Minesweeper/minsweeper.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_router,node_home,node_game toneBlue
class node_login,node_confirm,node_auth toneAmber
class node_scoretype,node_leaderboard toneMint
class node_api,node_dynamo,node_cognito toneRose
class node_player toneIndigo
```

## Components

### App and game

- [React entry](https://github.com/foyin/minesweeper2/blob/main/src/main.tsx): `src/main.tsx`
- [Routes](https://github.com/foyin/minesweeper2/blob/main/src/App.tsx): `src/App.tsx`
- [Home page](https://github.com/foyin/minesweeper2/blob/main/src/homePage.tsx): `src/homePage.tsx`
- [Minesweeper game](https://github.com/foyin/minesweeper2/blob/main/src/Minesweeper/minsweeper.tsx): `src/Minesweeper/minsweeper.tsx`

### Account access

- [Login and signup](https://github.com/foyin/minesweeper2/blob/main/src/loginPage.tsx): `src/loginPage.tsx`
- [Account confirmation](https://github.com/foyin/minesweeper2/blob/main/src/confirmUserPage.tsx): `src/confirmUserPage.tsx`
- [Cognito operations](https://github.com/foyin/minesweeper2/blob/main/src/authService.ts): `src/authService.ts`

### Leaderboard

- [Score contract](https://github.com/foyin/minesweeper2/blob/main/src/winnerInterface.ts): `src/winnerInterface.ts`
- [Leaderboard requests](https://github.com/foyin/minesweeper2/blob/main/src/Minesweeper/minsweeper.tsx): `src/Minesweeper/minsweeper.tsx`

### Cloud services

- **API Gateway endpoint**
- **DynamoDB**
- **Amazon Cognito**

### Other components

- **Player**

## Connections

- Player → React entry: opens app (evidence: `src/main.tsx`)
- React entry → Routes: renders (evidence: `src/main.tsx`)
- Routes → Home page: routes (evidence: `src/App.tsx`)
- Routes → Login and signup: routes (evidence: `src/App.tsx`)
- Routes → Account confirmation: routes (evidence: `src/App.tsx`)
- Home page → Minesweeper game: renders (evidence: `src/homePage.tsx`)
- Player → Minesweeper game: plays (evidence: `README.md`)
- Login and signup → Cognito operations: calls (evidence: `src/loginPage.tsx`)
- Account confirmation → Cognito operations: calls (evidence: `src/confirmUserPage.tsx`)
- Home page → Cognito operations: signs out through (evidence: `src/homePage.tsx`)
- Cognito operations → Amazon Cognito: sends auth commands (evidence: `src/authService.ts`)
- Minesweeper game → Leaderboard requests: manages scores (evidence: `src/Minesweeper/minsweeper.tsx`)
- Leaderboard requests → API Gateway endpoint: gets and updates (evidence: `src/Minesweeper/minsweeper.tsx`)
- Leaderboard requests → Score contract: uses score type (evidence: `src/Minesweeper/minsweeper.tsx`)
- API Gateway endpoint → DynamoDB: persists scores
