# aliqutib/mill-game architecture

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

- Interactive diagram: https://gitdiagram.com/aliqutib/mill-game
- Repository: https://github.com/aliqutib/mill-game

## Overview

The Mill is a Nine Men Morris app supporting local pass-and-play and online room matches, with accounts, profiles, history, search and social features. The main online path runs from the frontend lobby into room APIs, through room management and match-result recording; live moves and match events use Socket.IO on the backend. Account, profile, discovery and friend workflows form additional branches. Backend relationships are grounded in sampled calls and imports; frontend and unsampled feature links are limited to README capabilities and indexed references.

Main entry points: [`backend/src/server.js`](https://github.com/aliqutib/mill-game/blob/main/backend/src/server.js) (HTTP API), [`frontend/src/routes`](https://github.com/aliqutib/mill-game/tree/main/frontend/src/routes) (App routes), [`backend/src/models/User.js`](https://github.com/aliqutib/mill-game/blob/main/backend/src/models/User.js) (User records), [`backend/src/models/Profile.js`](https://github.com/aliqutib/mill-game/blob/main/backend/src/models/Profile.js) (Profile records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend experience"]
  node_frontend["App routes"]
  node_lobby["Room lobby<br/>[index.tsx]"]
  node_offline["Pass-and-play<br/>[index.tsx]"]
  node_online["Online match UI<br/>[index.tsx]"]
  node_frontend_social["Friends and search"]
  node_history["Stats and history"]
end

subgraph group_identity["Identity and profiles"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_controller["Account controller<br/>[authController.js]"]
  node_auth_service["Auth service<br/>[authService.js]"]
  node_auth_middleware["Token guard<br/>[auth.js]"]
  node_user_controller["Registration<br/>[userController.js]"]
  node_user_service["User service<br/>[userService.js]"]
end

subgraph group_social["Social and discovery"]
  node_profile_routes["Profile routes<br/>[profile.js]"]
  node_profile_controller["Profile and friends"]
  node_search_controller["Search controller"]
  node_search_service["Search service<br/>[searchService.js]"]
end

subgraph group_matches["Match services"]
  node_backend["HTTP API<br/>[server.js]"]
  node_room_routes["Room routes<br/>[room.js]"]
  node_room_controller["Room and results<br/>[roomController.js]"]
  node_room_service["Room service<br/>[roomService.js]"]
  node_realtime["Socket events<br/>[server.js]"]
end

subgraph group_persistence["Data layer"]
  node_user_model[("User records<br/>[User.js]")]
  node_profile_model[("Profile records<br/>[Profile.js]")]
  node_room_model[("Room records<br/>[Room.js]")]
end

node_player(("Player"))
node_mongo[("MongoDB")]

node_player -.->|"uses"| node_frontend
node_frontend -.->|"routes to"| node_lobby
node_frontend -.->|"routes to"| node_offline
node_frontend -.->|"routes to"| node_online
node_frontend -.->|"routes to"| node_frontend_social
node_frontend -.->|"routes to"| node_history
node_lobby -.->|"requests rooms"| node_backend
node_online -.->|"exchanges moves"| node_realtime
node_online -.->|"submits results"| node_backend
node_frontend_social -.->|"requests social data"| node_backend
node_history -.->|"requests records"| node_backend
node_backend -->|"mounts"| node_auth_routes
node_backend -->|"mounts"| node_profile_routes
node_backend -->|"mounts"| node_room_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"queries"| node_user_model
node_user_controller -->|"calls"| node_user_service
node_user_service -->|"queries"| node_user_model
node_profile_routes -->|"guards"| node_auth_middleware
node_profile_routes -->|"dispatches"| node_profile_controller
node_profile_controller -->|"reads and updates"| node_user_model
node_profile_controller -->|"reads and updates"| node_profile_model
node_search_controller -->|"calls"| node_search_service
node_search_service -->|"searches"| node_user_model
node_search_service -->|"finds profiles"| node_profile_model
node_room_routes -->|"guards"| node_auth_middleware
node_room_routes -->|"dispatches"| node_room_controller
node_room_controller -->|"calls"| node_room_service
node_room_service -->|"manages rooms"| node_room_model
node_room_service -->|"records results"| node_profile_model
node_backend -->|"connects"| node_mongo
node_backend -->|"registers events"| node_realtime
node_user_model -.->|"persists"| node_mongo
node_profile_model -.->|"persists"| node_mongo
node_room_model -.->|"persists"| node_mongo

click node_frontend "https://github.com/aliqutib/mill-game/tree/main/frontend/src/routes"
click node_lobby "https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/lobby/index.tsx"
click node_offline "https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/game/index.tsx"
click node_online "https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/online-game/index.tsx"
click node_frontend_social "https://github.com/aliqutib/mill-game/tree/main/frontend/src/app/features/social"
click node_history "https://github.com/aliqutib/mill-game/tree/main/frontend/src/app/features/history"
click node_backend "https://github.com/aliqutib/mill-game/blob/main/backend/src/server.js"
click node_auth_routes "https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/auth.js"
click node_auth_controller "https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/authController.js"
click node_auth_service "https://github.com/aliqutib/mill-game/blob/main/backend/src/services/authService.js"
click node_auth_middleware "https://github.com/aliqutib/mill-game/blob/main/backend/src/middleware/auth.js"
click node_user_controller "https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/userController.js"
click node_user_service "https://github.com/aliqutib/mill-game/blob/main/backend/src/services/userService.js"
click node_profile_routes "https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/profile.js"
click node_profile_controller "https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/profileController.js"
click node_search_controller "https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/searchController.js"
click node_search_service "https://github.com/aliqutib/mill-game/blob/main/backend/src/services/searchService.js"
click node_room_routes "https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/room.js"
click node_room_controller "https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/roomController.js"
click node_room_service "https://github.com/aliqutib/mill-game/blob/main/backend/src/services/roomService.js"
click node_realtime "https://github.com/aliqutib/mill-game/blob/main/backend/src/server.js"
click node_user_model "https://github.com/aliqutib/mill-game/blob/main/backend/src/models/User.js"
click node_profile_model "https://github.com/aliqutib/mill-game/blob/main/backend/src/models/Profile.js"
click node_room_model "https://github.com/aliqutib/mill-game/blob/main/backend/src/models/Room.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_frontend,node_lobby,node_offline,node_online,node_frontend_social,node_history toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_auth_middleware,node_user_controller,node_user_service,node_mongo toneAmber
class node_profile_routes,node_profile_controller,node_search_controller,node_search_service toneMint
class node_backend,node_room_routes,node_room_controller,node_room_service,node_realtime toneRose
class node_user_model,node_profile_model,node_room_model,node_player toneIndigo
```

## Components

### Frontend experience

- [App routes](https://github.com/aliqutib/mill-game/tree/main/frontend/src/routes): `frontend/src/routes`
- [Room lobby](https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/lobby/index.tsx): `frontend/src/app/features/lobby/index.tsx`
- [Pass-and-play](https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/game/index.tsx): `frontend/src/app/features/game/index.tsx`
- [Online match UI](https://github.com/aliqutib/mill-game/blob/main/frontend/src/app/features/online-game/index.tsx): `frontend/src/app/features/online-game/index.tsx`
- [Friends and search](https://github.com/aliqutib/mill-game/tree/main/frontend/src/app/features/social): `frontend/src/app/features/social`
- [Stats and history](https://github.com/aliqutib/mill-game/tree/main/frontend/src/app/features/history): `frontend/src/app/features/history`

### Identity and profiles

- [Auth routes](https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/auth.js): `backend/src/routes/api/auth.js`
- [Account controller](https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Auth service](https://github.com/aliqutib/mill-game/blob/main/backend/src/services/authService.js): `backend/src/services/authService.js`
- [Token guard](https://github.com/aliqutib/mill-game/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Registration](https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/userController.js): `backend/src/controllers/userController.js`
- [User service](https://github.com/aliqutib/mill-game/blob/main/backend/src/services/userService.js): `backend/src/services/userService.js`

### Social and discovery

- [Profile routes](https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/profile.js): `backend/src/routes/api/profile.js`
- [Profile and friends](https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/profileController.js): `backend/src/controllers/profileController.js`
- [Search controller](https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/searchController.js): `backend/src/controllers/searchController.js`
- [Search service](https://github.com/aliqutib/mill-game/blob/main/backend/src/services/searchService.js): `backend/src/services/searchService.js`

### Match services

- [HTTP API](https://github.com/aliqutib/mill-game/blob/main/backend/src/server.js): `backend/src/server.js`
- [Room routes](https://github.com/aliqutib/mill-game/blob/main/backend/src/routes/api/room.js): `backend/src/routes/api/room.js`
- [Room and results](https://github.com/aliqutib/mill-game/blob/main/backend/src/controllers/roomController.js): `backend/src/controllers/roomController.js`
- [Room service](https://github.com/aliqutib/mill-game/blob/main/backend/src/services/roomService.js): `backend/src/services/roomService.js`
- [Socket events](https://github.com/aliqutib/mill-game/blob/main/backend/src/server.js): `backend/src/server.js`

### Data layer

- [User records](https://github.com/aliqutib/mill-game/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Profile records](https://github.com/aliqutib/mill-game/blob/main/backend/src/models/Profile.js): `backend/src/models/Profile.js`
- [Room records](https://github.com/aliqutib/mill-game/blob/main/backend/src/models/Room.js): `backend/src/models/Room.js`

### Other components

- **Player**
- **MongoDB**

## Connections

- Player → App routes: uses
- App routes → Room lobby: routes to
- App routes → Pass-and-play: routes to
- App routes → Online match UI: routes to
- App routes → Friends and search: routes to
- App routes → Stats and history: routes to
- Room lobby → HTTP API: requests rooms
- Online match UI → Socket events: exchanges moves
- Online match UI → HTTP API: submits results
- Friends and search → HTTP API: requests social data
- Stats and history → HTTP API: requests records
- HTTP API → Auth routes: mounts (evidence: `backend/src/server.js`)
- HTTP API → Profile routes: mounts (evidence: `backend/src/server.js`)
- HTTP API → Room routes: mounts (evidence: `backend/src/server.js`)
- Auth routes → Account controller: dispatches (evidence: `backend/src/routes/api/auth.js`)
- Account controller → Auth service: calls (evidence: `backend/src/controllers/authController.js`)
- Auth service → User records: queries (evidence: `backend/src/services/authService.js`)
- Registration → User service: calls (evidence: `backend/src/controllers/userController.js`)
- User service → User records: queries (evidence: `backend/src/services/userService.js`)
- Profile routes → Token guard: guards (evidence: `backend/src/routes/api/profile.js`)
- Profile routes → Profile and friends: dispatches (evidence: `backend/src/routes/api/profile.js`)
- Profile and friends → User records: reads and updates (evidence: `backend/src/controllers/profileController.js`)
- Profile and friends → Profile records: reads and updates (evidence: `backend/src/controllers/profileController.js`)
- Search controller → Search service: calls (evidence: `backend/src/controllers/searchController.js`)
- Search service → User records: searches (evidence: `backend/src/services/searchService.js`)
- Search service → Profile records: finds profiles (evidence: `backend/src/services/searchService.js`)
- Room routes → Token guard: guards (evidence: `backend/src/routes/api/room.js`)
- Room routes → Room and results: dispatches (evidence: `backend/src/routes/api/room.js`)
- Room and results → Room service: calls (evidence: `backend/src/controllers/roomController.js`)
- Room service → Room records: manages rooms (evidence: `backend/src/services/roomService.js`)
- Room service → Profile records: records results (evidence: `backend/src/services/roomService.js`)
- HTTP API → MongoDB: connects (evidence: `backend/src/server.js`)
- HTTP API → Socket events: registers events (evidence: `backend/src/server.js`)
- User records → MongoDB: persists
- Profile records → MongoDB: persists
- Room records → MongoDB: persists
