# bhattaraidipesh060-gif/puzzle-world architecture

> Architecture diagram of the GitHub repository bhattaraidipesh060-gif/puzzle-world, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhattaraidipesh060-gif/puzzle-world
- Repository: https://github.com/bhattaraidipesh060-gif/puzzle-world

## Overview

PuzzleWorld is an offline-first Android escape-room game with a web portal and Node/SQLite sync backend. Players solve themed-room puzzles locally, then sync progress; account, daily-challenge, leaderboard, and badge features extend that loop. The README documents the broader game and portal capabilities, while sampled code confirms selected sync, auth, progress, and challenge flows. Several Android screens and web modules were not sampled, so their internal wiring is left unasserted.

Main entry points: [`backend/server.js`](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/server.js) (API Server), [`backend/database.js`](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/database.js) (SQLite Database), [`backend/public/app.js`](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/public/app.js) (Web Portal), [`app/src/main/java/com/jeiu/puzzleworld/MainActivity.kt`](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/MainActivity.kt) (Puzzle Gameplay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android Game"]
  node_home["Game Home<br/>[HomeActivity.kt]"]
  node_gameplay["Puzzle Gameplay<br/>[MainActivity.kt]"]
  node_puzzle_engines["Puzzle Mechanics"]
  node_daily_screen["Daily Challenge"]
  node_local_storage[("Local Progress<br/>[LocalStorage.kt]")]
  node_world_repo["World Repository<br/>[WorldRepository.kt]"]
  node_http_service["HTTP Sync"]
end

subgraph group_backend["Backend API"]
  node_backend_server["API Server<br/>[server.js]"]
  node_auth_routes["Authentication<br/>[auth.js]"]
  node_auth_security["Token Security<br/>[security.js]"]
  node_auth_middleware["Auth Middleware<br/>[auth.js]"]
  node_rooms_routes["Room Catalogue<br/>[rooms.js]"]
  node_progress_routes["Progress Sync<br/>[progress.js]"]
  node_challenge_routes["Daily Challenge<br/>[challenges.js]"]
  node_stats_routes["Player Stats<br/>[stats.js]"]
  node_profile_routes["Profile Badges<br/>[profile.js]"]
  node_badges["Badge Evaluation<br/>[badges.js]"]
end

subgraph group_data["Persistent Data"]
  node_db[("SQLite Database<br/>[database.js]")]
end

subgraph group_portal["Web Portal"]
  node_web_portal["Web Portal<br/>[app.js]"]
  node_web_auth["Web Authentication<br/>[auth.js]"]
  node_web_games["Portal Mini-Games"]
end

node_player(("Player"))
node_visitor(("Portal Visitor"))

node_player -->|"plays"| node_home
node_home -.->|"enters"| node_gameplay
node_gameplay -.->|"uses mechanics"| node_puzzle_engines
node_gameplay -.->|"saves progress"| node_local_storage
node_home -.->|"opens challenge"| node_daily_screen
node_gameplay -.->|"loads world"| node_world_repo
node_world_repo -->|"delegates sync"| node_http_service
node_http_service -->|"HTTP requests"| node_backend_server
node_backend_server -->|"routes auth"| node_auth_routes
node_backend_server -->|"routes rooms"| node_rooms_routes
node_backend_server -->|"routes progress"| node_progress_routes
node_backend_server -->|"routes challenges"| node_challenge_routes
node_backend_server -->|"routes stats"| node_stats_routes
node_backend_server -->|"routes profile"| node_profile_routes
node_auth_routes -->|"uses security"| node_auth_security
node_auth_middleware -->|"verifies tokens"| node_auth_security
node_auth_routes -->|"reads and writes"| node_db
node_rooms_routes -->|"reads catalogue"| node_db
node_progress_routes -->|"reads and writes"| node_db
node_challenge_routes -->|"reads and writes"| node_db
node_stats_routes -->|"reads stats"| node_db
node_profile_routes -->|"evaluates badges"| node_badges
node_profile_routes -->|"reads profile"| node_db
node_backend_server -->|"serves static files"| node_web_portal
node_visitor -->|"visits"| node_web_portal
node_web_portal -.->|"uses login"| node_web_auth
node_web_portal -.->|"offers games"| node_web_games
node_web_portal -.->|"uses API"| node_backend_server

click node_home "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/HomeActivity.kt"
click node_gameplay "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/MainActivity.kt"
click node_puzzle_engines "https://github.com/bhattaraidipesh060-gif/puzzle-world/tree/main/app/src/main/java/com/jeiu/puzzleworld"
click node_daily_screen "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/DailyChallengeActivity.kt"
click node_local_storage "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/LocalStorage.kt"
click node_world_repo "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/WorldRepository.kt"
click node_http_service "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/HttpWorldService.kt"
click node_backend_server "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/server.js"
click node_auth_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/auth.js"
click node_auth_security "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/lib/security.js"
click node_auth_middleware "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/middleware/auth.js"
click node_rooms_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/rooms.js"
click node_progress_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/progress.js"
click node_challenge_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/challenges.js"
click node_stats_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/stats.js"
click node_profile_routes "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/profile.js"
click node_badges "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/badges.js"
click node_db "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/database.js"
click node_web_portal "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/public/app.js"
click node_web_auth "https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/public/auth.js"
click node_web_games "https://github.com/bhattaraidipesh060-gif/puzzle-world/tree/main/backend/public/games"

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_home,node_gameplay,node_puzzle_engines,node_daily_screen,node_local_storage,node_world_repo,node_http_service toneBlue
class node_backend_server,node_auth_routes,node_auth_security,node_auth_middleware,node_rooms_routes,node_progress_routes,node_challenge_routes,node_stats_routes,node_profile_routes,node_badges toneAmber
class node_db toneMint
class node_web_portal,node_web_auth,node_web_games toneRose
class node_player,node_visitor toneIndigo
```

## Components

### Android Game

- [Game Home](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/HomeActivity.kt): `app/src/main/java/com/jeiu/puzzleworld/HomeActivity.kt`
- [Puzzle Gameplay](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/MainActivity.kt): `app/src/main/java/com/jeiu/puzzleworld/MainActivity.kt`
- [Puzzle Mechanics](https://github.com/bhattaraidipesh060-gif/puzzle-world/tree/main/app/src/main/java/com/jeiu/puzzleworld): `app/src/main/java/com/jeiu/puzzleworld`
- [Daily Challenge](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/DailyChallengeActivity.kt): `app/src/main/java/com/jeiu/puzzleworld/DailyChallengeActivity.kt`
- [Local Progress](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/LocalStorage.kt): `app/src/main/java/com/jeiu/puzzleworld/LocalStorage.kt`
- [World Repository](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/WorldRepository.kt): `app/src/main/java/com/jeiu/puzzleworld/WorldRepository.kt`
- [HTTP Sync](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/app/src/main/java/com/jeiu/puzzleworld/HttpWorldService.kt): `app/src/main/java/com/jeiu/puzzleworld/HttpWorldService.kt`

### Backend API

- [API Server](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Token Security](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/lib/security.js): `backend/lib/security.js`
- [Auth Middleware](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Room Catalogue](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/rooms.js): `backend/routes/rooms.js`
- [Progress Sync](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/progress.js): `backend/routes/progress.js`
- [Daily Challenge](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/challenges.js): `backend/routes/challenges.js`
- [Player Stats](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/stats.js): `backend/routes/stats.js`
- [Profile Badges](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/routes/profile.js): `backend/routes/profile.js`
- [Badge Evaluation](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/badges.js): `backend/badges.js`

### Persistent Data

- [SQLite Database](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/database.js): `backend/database.js`

### Web Portal

- [Web Portal](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/public/app.js): `backend/public/app.js`
- [Web Authentication](https://github.com/bhattaraidipesh060-gif/puzzle-world/blob/main/backend/public/auth.js): `backend/public/auth.js`
- [Portal Mini-Games](https://github.com/bhattaraidipesh060-gif/puzzle-world/tree/main/backend/public/games): `backend/public/games`

### Other components

- **Player**
- **Portal Visitor**

## Connections

- Player → Game Home: plays (evidence: `README.md`)
- Game Home → Puzzle Gameplay: enters
- Puzzle Gameplay → Puzzle Mechanics: uses mechanics
- Puzzle Gameplay → Local Progress: saves progress
- Game Home → Daily Challenge: opens challenge
- Puzzle Gameplay → World Repository: loads world
- World Repository → HTTP Sync: delegates sync (evidence: `app/src/main/java/com/jeiu/puzzleworld/HttpWorldService.kt`)
- HTTP Sync → API Server: HTTP requests (evidence: `README.md`)
- API Server → Authentication: routes auth (evidence: `backend/server.js`)
- API Server → Room Catalogue: routes rooms (evidence: `backend/server.js`)
- API Server → Progress Sync: routes progress (evidence: `backend/server.js`)
- API Server → Daily Challenge: routes challenges (evidence: `backend/server.js`)
- API Server → Player Stats: routes stats (evidence: `backend/server.js`)
- API Server → Profile Badges: routes profile (evidence: `backend/server.js`)
- Authentication → Token Security: uses security (evidence: `backend/routes/auth.js`)
- Auth Middleware → Token Security: verifies tokens (evidence: `backend/middleware/auth.js`)
- Authentication → SQLite Database: reads and writes (evidence: `backend/routes/auth.js`)
- Room Catalogue → SQLite Database: reads catalogue (evidence: `backend/routes/rooms.js`)
- Progress Sync → SQLite Database: reads and writes (evidence: `backend/routes/progress.js`)
- Daily Challenge → SQLite Database: reads and writes (evidence: `backend/routes/challenges.js`)
- Player Stats → SQLite Database: reads stats (evidence: `backend/routes/stats.js`)
- Profile Badges → Badge Evaluation: evaluates badges (evidence: `backend/routes/profile.js`)
- Profile Badges → SQLite Database: reads profile (evidence: `backend/routes/profile.js`)
- API Server → Web Portal: serves static files (evidence: `backend/server.js`)
- Portal Visitor → Web Portal: visits (evidence: `README.md`)
- Web Portal → Web Authentication: uses login
- Web Portal → Portal Mini-Games: offers games (evidence: `README.md`)
- Web Portal → API Server: uses API
