# kiran-mondal/chaturanga architecture

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

- Interactive diagram: https://gitdiagram.com/kiran-mondal/chaturanga
- Repository: https://github.com/kiran-mondal/chaturanga

## Overview

Chaturanga is a browser-based revival of the ancient strategy board game. The principal workflow is a player choosing a mode, making moves on the Ashtapada board, and seeing the game update; the documented modes are play against adaptive AI and local pass-and-play. The client also renders the board in 3D and provides move feedback. Sampled server code adds Socket.IO moves, strategy endpoints, and database-backed learning/session APIs. The README describes a static client, so the relationship between that deployment description and these server modules is unclear; the sampled server does not mount routes.js.

Main entry points: [`script.js`](https://github.com/kiran-mondal/chaturanga/blob/main/script.js) (Game Client), [`server.js`](https://github.com/kiran-mondal/chaturanga/blob/main/server.js) (HTTP and Socket Server), [`routes.js`](https://github.com/kiran-mondal/chaturanga/blob/main/routes.js) (Game API Routes), [`db.js`](https://github.com/kiran-mondal/chaturanga/blob/main/db.js) (Database Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game Play"]
  node_client["Game Client<br/>[script.js]"]
  node_ai["Adaptive AI<br/>[script.js]"]
end

subgraph group_interface["Browser Experience"]
  node_board["3D Board<br/>[script.js]"]
  node_feedback["Audio Feedback<br/>[audio.js]"]
  node_navigation["Page Navigation<br/>[menubar.js]"]
  node_gamepages["Game and Info Pages<br/>[index.html]"]
end

subgraph group_server["Server Features"]
  node_serverapp["HTTP and Socket Server<br/>[server.js]"]
  node_routes["Game API Routes<br/>[routes.js]"]
end

subgraph group_data["Data and Learning"]
  node_dbclient["Database Client<br/>[db.js]"]
  node_database[("PostgreSQL")]
  node_learning[("AI Learning Memory<br/>[routes.js]")]
  node_sessions[("Game Sessions<br/>[routes.js]")]
  node_strategy[("Strategy Traps<br/>[server.js]")]
  node_verifier["Session Verifier<br/>[aiBot.js]"]
end

node_player(("Player"))

node_player -->|"plays"| node_client
node_client -->|"requests moves"| node_ai
node_client -->|"renders state"| node_board
node_client -->|"plays sounds"| node_feedback
node_navigation -->|"switches pages"| node_gamepages
node_client -.->|"sends moves"| node_serverapp
node_serverapp -.->|"broadcasts moves"| node_client
node_serverapp -->|"reads and writes"| node_database
node_routes -->|"queries"| node_dbclient
node_dbclient -->|"executes queries"| node_database
node_routes -->|"stores and reads"| node_learning
node_routes -->|"creates and counts"| node_sessions
node_serverapp -->|"stores and reads"| node_strategy
node_verifier -->|"loads session"| node_dbclient

click node_client "https://github.com/kiran-mondal/chaturanga/blob/main/script.js"
click node_ai "https://github.com/kiran-mondal/chaturanga/blob/main/script.js"
click node_board "https://github.com/kiran-mondal/chaturanga/blob/main/script.js"
click node_feedback "https://github.com/kiran-mondal/chaturanga/blob/main/audio.js"
click node_navigation "https://github.com/kiran-mondal/chaturanga/blob/main/components/menubar.js"
click node_gamepages "https://github.com/kiran-mondal/chaturanga/blob/main/index.html"
click node_serverapp "https://github.com/kiran-mondal/chaturanga/blob/main/server.js"
click node_routes "https://github.com/kiran-mondal/chaturanga/blob/main/routes.js"
click node_dbclient "https://github.com/kiran-mondal/chaturanga/blob/main/db.js"
click node_learning "https://github.com/kiran-mondal/chaturanga/blob/main/routes.js"
click node_sessions "https://github.com/kiran-mondal/chaturanga/blob/main/routes.js"
click node_strategy "https://github.com/kiran-mondal/chaturanga/blob/main/server.js"
click node_verifier "https://github.com/kiran-mondal/chaturanga/blob/main/aiBot.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_client,node_ai toneBlue
class node_board,node_feedback,node_navigation,node_gamepages toneAmber
class node_serverapp,node_routes toneMint
class node_dbclient,node_database,node_learning,node_sessions,node_strategy,node_verifier toneRose
class node_player toneIndigo
```

## Components

### Game Play

- [Game Client](https://github.com/kiran-mondal/chaturanga/blob/main/script.js): `script.js`
- [Adaptive AI](https://github.com/kiran-mondal/chaturanga/blob/main/script.js): `script.js`

### Browser Experience

- [3D Board](https://github.com/kiran-mondal/chaturanga/blob/main/script.js): `script.js`
- [Audio Feedback](https://github.com/kiran-mondal/chaturanga/blob/main/audio.js): `audio.js`
- [Page Navigation](https://github.com/kiran-mondal/chaturanga/blob/main/components/menubar.js): `components/menubar.js`
- [Game and Info Pages](https://github.com/kiran-mondal/chaturanga/blob/main/index.html): `index.html`

### Server Features

- [HTTP and Socket Server](https://github.com/kiran-mondal/chaturanga/blob/main/server.js): `server.js`
- [Game API Routes](https://github.com/kiran-mondal/chaturanga/blob/main/routes.js): `routes.js`

### Data and Learning

- [Database Client](https://github.com/kiran-mondal/chaturanga/blob/main/db.js): `db.js`
- **PostgreSQL**
- [AI Learning Memory](https://github.com/kiran-mondal/chaturanga/blob/main/routes.js): `routes.js`
- [Game Sessions](https://github.com/kiran-mondal/chaturanga/blob/main/routes.js): `routes.js`
- [Strategy Traps](https://github.com/kiran-mondal/chaturanga/blob/main/server.js): `server.js`
- [Session Verifier](https://github.com/kiran-mondal/chaturanga/blob/main/aiBot.js): `aiBot.js`

### Other components

- **Player**

## Connections

- Player → Game Client: plays
- Game Client → Adaptive AI: requests moves
- Game Client → 3D Board: renders state
- Game Client → Audio Feedback: plays sounds
- Page Navigation → Game and Info Pages: switches pages
- Game Client → HTTP and Socket Server: sends moves
- HTTP and Socket Server → Game Client: broadcasts moves
- HTTP and Socket Server → PostgreSQL: reads and writes
- Game API Routes → Database Client: queries
- Database Client → PostgreSQL: executes queries
- Game API Routes → AI Learning Memory: stores and reads
- Game API Routes → Game Sessions: creates and counts
- HTTP and Socket Server → Strategy Traps: stores and reads
- Session Verifier → Database Client: loads session
