# jemish-jikadara/chessmaster-mern architecture

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

- Interactive diagram: https://gitdiagram.com/jemish-jikadara/chessmaster-mern
- Repository: https://github.com/jemish-jikadara/chessmaster-mern

## Overview

ChessMaster is a React chess app backed by an Express/MongoDB JSON API and Socket.IO multiplayer server. Players can register and manage profiles, play locally against a person or Stockfish, find online matches, manage friends, and review games and ratings. The graph follows the documented UI-to-service workflow and the sampled controller, hook, and server behavior; unsampled page and route details are represented only where the README or source index supports them.

Main entry points: [`Frontend/chess-master-react/src/api/axios.js`](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/api/axios.js) (HTTP Client), [`Backend/chess-master/src/controllers/settingsController.js`](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/settingsController.js) (Settings Service), [`Backend/chess-master/src/controllers/gameController.js`](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/gameController.js) (Game Controller), [`Backend/chess-master/server.js`](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/server.js) (Express & Socket Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_app["App Router<br/>[App.jsx]"]
  node_auth_ui["Auth Context<br/>[AuthContext.jsx]"]
  node_api_client["HTTP Client<br/>[axios.js]"]
  node_home["Home &amp; Matchmaking<br/>[Home.jsx]"]
  node_friends_ui["Friends<br/>[Friends.jsx]"]
  node_profile_ui["Profile &amp; Settings<br/>[Profile.jsx]"]
  node_leaderboard["Leaderboard<br/>[Leaderboard.jsx]"]
  node_replay["Game Replay<br/>[Replay.jsx]"]
end

subgraph group_play["Chess Play"]
  node_local_play["Local Play<br/>[Play.jsx]"]
  node_online_ui["Online Play<br/>[OnlinePlay.jsx]"]
  node_board["Chess Board<br/>[ChessBoard.jsx]"]
  node_local_hook["Local Game Hook<br/>[useChessGame.js]"]
  node_online_hook["Online Game Hook<br/>[useOnlineGame.js]"]
  node_chess_engine["Chess Engine<br/>[chessjs.js]"]
  node_socket_client["Socket Client<br/>[socket.js]"]
end

subgraph group_api["API Services"]
  node_server["Express &amp; Socket Server<br/>[server.js]"]
  node_auth_routes["Auth Routes<br/>[authRoutes.js]"]
  node_auth_controller["Auth Controller<br/>[authController.js]"]
  node_game_routes["Game Routes<br/>[gameRoutes.js]"]
  node_game_controller["Game Controller<br/>[gameController.js]"]
  node_friend_controller["Friend Service"]
  node_settings_controller["Settings Service"]
  node_rating_logic["Rating Updates<br/>[rating.js]"]
end

subgraph group_data["Persistence"]
  node_user_model[("User Records<br/>[User.js]")]
  node_friend_model[("Friend Records<br/>[Friend.js]")]
  node_game_model[("Game Records<br/>[Game.js]")]
  node_moves_model[("Move Records<br/>[GameMove.js]")]
  node_rating_model[("Ratings<br/>[Rating.js]")]
  node_stats_model[("Statistics<br/>[Statistic.js]")]
end

node_player(("Player"))

node_player -->|"uses"| node_app
node_app -->|"provides auth"| node_auth_ui
node_auth_ui -->|"sends requests"| node_api_client
node_home -->|"loads data"| node_api_client
node_friends_ui -.->|"uses API"| node_api_client
node_profile_ui -->|"loads profile"| node_api_client
node_leaderboard -.->|"loads games"| node_api_client
node_replay -.->|"loads replay"| node_api_client
node_local_play -->|"uses game hook"| node_local_hook
node_local_play -->|"renders board"| node_board
node_local_hook -->|"uses rules"| node_chess_engine
node_online_ui -->|"uses game hook"| node_online_hook
node_online_ui -->|"renders board"| node_board
node_online_hook -->|"uses rules"| node_chess_engine
node_online_hook -->|"gets socket"| node_socket_client
node_online_hook -->|"saves game"| node_api_client
node_api_client -.->|"HTTP API"| node_server
node_home -.->|"matchmaking socket"| node_server
node_socket_client -.->|"Socket.IO"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_game_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_game_routes -->|"dispatches"| node_game_controller
node_auth_controller -->|"reads and writes"| node_user_model
node_friend_controller -->|"searches users"| node_user_model
node_friend_controller -->|"manages friendships"| node_friend_model
node_game_controller -->|"stores games"| node_game_model
node_game_controller -->|"stores moves"| node_moves_model
node_game_controller -->|"updates ratings"| node_rating_logic
node_game_controller -->|"reads ratings"| node_rating_model
node_rating_logic -->|"updates ratings"| node_rating_model
node_rating_logic -->|"updates statistics"| node_stats_model
node_rating_logic -->|"updates user"| node_user_model
node_settings_controller -->|"updates settings"| node_user_model
node_settings_controller -->|"deletes relations"| node_friend_model
node_settings_controller -->|"deletes games"| node_game_model
node_settings_controller -->|"deletes moves"| node_moves_model
node_settings_controller -->|"deletes ratings"| node_rating_model
node_settings_controller -->|"deletes statistics"| node_stats_model

click node_app "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/App.jsx"
click node_auth_ui "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/context/AuthContext.jsx"
click node_api_client "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/api/axios.js"
click node_home "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Home.jsx"
click node_friends_ui "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Friends.jsx"
click node_profile_ui "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Profile.jsx"
click node_leaderboard "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Leaderboard.jsx"
click node_replay "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Replay.jsx"
click node_local_play "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Play.jsx"
click node_online_ui "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/OnlinePlay.jsx"
click node_board "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/components/ChessBoard.jsx"
click node_local_hook "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/hooks/useChessGame.js"
click node_online_hook "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/hooks/useOnlineGame.js"
click node_chess_engine "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/lib/chessjs.js"
click node_socket_client "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/lib/socket.js"
click node_server "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/server.js"
click node_auth_routes "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/routes/authRoutes.js"
click node_auth_controller "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/authController.js"
click node_game_routes "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/routes/gameRoutes.js"
click node_game_controller "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/gameController.js"
click node_friend_controller "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/friendController.js"
click node_settings_controller "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/settingsController.js"
click node_user_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/User.js"
click node_friend_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Friend.js"
click node_game_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Game.js"
click node_moves_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/GameMove.js"
click node_rating_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Rating.js"
click node_stats_model "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Statistic.js"
click node_rating_logic "https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/utils/rating.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_app,node_auth_ui,node_api_client,node_home,node_friends_ui,node_profile_ui,node_leaderboard,node_replay toneBlue
class node_local_play,node_online_ui,node_board,node_local_hook,node_online_hook,node_chess_engine,node_socket_client toneAmber
class node_server,node_auth_routes,node_auth_controller,node_game_routes,node_game_controller,node_friend_controller,node_settings_controller,node_rating_logic toneMint
class node_user_model,node_friend_model,node_game_model,node_moves_model,node_rating_model,node_stats_model toneRose
class node_player toneIndigo
```

## Components

### React Client

- [App Router](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/App.jsx): `Frontend/chess-master-react/src/App.jsx`
- [Auth Context](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/context/AuthContext.jsx): `Frontend/chess-master-react/src/context/AuthContext.jsx`
- [HTTP Client](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/api/axios.js): `Frontend/chess-master-react/src/api/axios.js`
- [Home & Matchmaking](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Home.jsx): `Frontend/chess-master-react/src/pages/Home.jsx`
- [Friends](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Friends.jsx): `Frontend/chess-master-react/src/pages/Friends.jsx`
- [Profile & Settings](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Profile.jsx): `Frontend/chess-master-react/src/pages/Profile.jsx`
- [Leaderboard](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Leaderboard.jsx): `Frontend/chess-master-react/src/pages/Leaderboard.jsx`
- [Game Replay](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Replay.jsx): `Frontend/chess-master-react/src/pages/Replay.jsx`

### Chess Play

- [Local Play](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/Play.jsx): `Frontend/chess-master-react/src/pages/Play.jsx`
- [Online Play](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/pages/OnlinePlay.jsx): `Frontend/chess-master-react/src/pages/OnlinePlay.jsx`
- [Chess Board](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/components/ChessBoard.jsx): `Frontend/chess-master-react/src/components/ChessBoard.jsx`
- [Local Game Hook](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/hooks/useChessGame.js): `Frontend/chess-master-react/src/hooks/useChessGame.js`
- [Online Game Hook](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/hooks/useOnlineGame.js): `Frontend/chess-master-react/src/hooks/useOnlineGame.js`
- [Chess Engine](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/lib/chessjs.js): `Frontend/chess-master-react/src/lib/chessjs.js`
- [Socket Client](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Frontend/chess-master-react/src/lib/socket.js): `Frontend/chess-master-react/src/lib/socket.js`

### API Services

- [Express & Socket Server](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/server.js): `Backend/chess-master/server.js`
- [Auth Routes](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/routes/authRoutes.js): `Backend/chess-master/src/routes/authRoutes.js`
- [Auth Controller](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/authController.js): `Backend/chess-master/src/controllers/authController.js`
- [Game Routes](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/routes/gameRoutes.js): `Backend/chess-master/src/routes/gameRoutes.js`
- [Game Controller](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/gameController.js): `Backend/chess-master/src/controllers/gameController.js`
- [Friend Service](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/friendController.js): `Backend/chess-master/src/controllers/friendController.js`
- [Settings Service](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/controllers/settingsController.js): `Backend/chess-master/src/controllers/settingsController.js`
- [Rating Updates](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/utils/rating.js): `Backend/chess-master/src/utils/rating.js`

### Persistence

- [User Records](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/User.js): `Backend/chess-master/src/models/User.js`
- [Friend Records](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Friend.js): `Backend/chess-master/src/models/Friend.js`
- [Game Records](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Game.js): `Backend/chess-master/src/models/Game.js`
- [Move Records](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/GameMove.js): `Backend/chess-master/src/models/GameMove.js`
- [Ratings](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Rating.js): `Backend/chess-master/src/models/Rating.js`
- [Statistics](https://github.com/jemish-jikadara/chessmaster-mern/blob/main/Backend/chess-master/src/models/Statistic.js): `Backend/chess-master/src/models/Statistic.js`

### Other components

- **Player**

## Connections

- Player → App Router: uses (evidence: `Frontend/chess-master-react/src/App.jsx`)
- App Router → Auth Context: provides auth (evidence: `Frontend/chess-master-react/src/App.jsx`)
- Auth Context → HTTP Client: sends requests (evidence: `Frontend/chess-master-react/src/context/AuthContext.jsx`)
- Home & Matchmaking → HTTP Client: loads data (evidence: `Frontend/chess-master-react/src/pages/Home.jsx`)
- Friends → HTTP Client: uses API (evidence: `README.md`)
- Profile & Settings → HTTP Client: loads profile (evidence: `Frontend/chess-master-react/src/pages/Profile.jsx`)
- Leaderboard → HTTP Client: loads games (evidence: `README.md`)
- Game Replay → HTTP Client: loads replay (evidence: `README.md`)
- Local Play → Local Game Hook: uses game hook (evidence: `Frontend/chess-master-react/src/pages/Play.jsx`)
- Local Play → Chess Board: renders board (evidence: `Frontend/chess-master-react/src/pages/Play.jsx`)
- Local Game Hook → Chess Engine: uses rules (evidence: `Frontend/chess-master-react/src/hooks/useChessGame.js`)
- Online Play → Online Game Hook: uses game hook (evidence: `Frontend/chess-master-react/src/pages/OnlinePlay.jsx`)
- Online Play → Chess Board: renders board (evidence: `Frontend/chess-master-react/src/pages/OnlinePlay.jsx`)
- Online Game Hook → Chess Engine: uses rules (evidence: `Frontend/chess-master-react/src/hooks/useOnlineGame.js`)
- Online Game Hook → Socket Client: gets socket (evidence: `Frontend/chess-master-react/src/hooks/useOnlineGame.js`)
- Online Game Hook → HTTP Client: saves game (evidence: `Frontend/chess-master-react/src/hooks/useOnlineGame.js`)
- HTTP Client → Express & Socket Server: HTTP API (evidence: `README.md`)
- Home & Matchmaking → Express & Socket Server: matchmaking socket (evidence: `README.md`)
- Socket Client → Express & Socket Server: Socket.IO (evidence: `README.md`)
- Express & Socket Server → Auth Routes: mounts routes (evidence: `Backend/chess-master/server.js`)
- Express & Socket Server → Game Routes: mounts routes (evidence: `Backend/chess-master/server.js`)
- Auth Routes → Auth Controller: dispatches (evidence: `Backend/chess-master/src/routes/authRoutes.js`)
- Game Routes → Game Controller: dispatches (evidence: `Backend/chess-master/src/routes/gameRoutes.js`)
- Auth Controller → User Records: reads and writes (evidence: `Backend/chess-master/src/controllers/authController.js`)
- Friend Service → User Records: searches users (evidence: `Backend/chess-master/src/controllers/friendController.js`)
- Friend Service → Friend Records: manages friendships (evidence: `Backend/chess-master/src/controllers/friendController.js`)
- Game Controller → Game Records: stores games (evidence: `Backend/chess-master/src/controllers/gameController.js`)
- Game Controller → Move Records: stores moves (evidence: `Backend/chess-master/src/controllers/gameController.js`)
- Game Controller → Rating Updates: updates ratings (evidence: `Backend/chess-master/src/controllers/gameController.js`)
- Game Controller → Ratings: reads ratings (evidence: `Backend/chess-master/src/controllers/gameController.js`)
- Rating Updates → Ratings: updates ratings (evidence: `Backend/chess-master/src/utils/rating.js`)
- Rating Updates → Statistics: updates statistics (evidence: `Backend/chess-master/src/utils/rating.js`)
- Rating Updates → User Records: updates user (evidence: `Backend/chess-master/src/utils/rating.js`)
- Settings Service → User Records: updates settings (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
- Settings Service → Friend Records: deletes relations (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
- Settings Service → Game Records: deletes games (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
- Settings Service → Move Records: deletes moves (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
- Settings Service → Ratings: deletes ratings (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
- Settings Service → Statistics: deletes statistics (evidence: `Backend/chess-master/src/controllers/settingsController.js`)
