# ndgiang02/xiangqi architecture

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

- Interactive diagram: https://gitdiagram.com/ndgiang02/xiangqi
- Repository: https://github.com/ndgiang02/xiangqi

## Overview

The tree describes a Flutter Xiangqi game with authentication, game modes, engine plugins, and settings. The likely user flow is to choose a mode, play through the game UI, and have moves represented and handled by game logic and data sources. The README is only a Flutter starter template, and the excerpts cover native launchers rather than Dart feature code, so most feature relationships below are dashed and unverified; no app-level calls were directly inspected.

Main entry points: [`lib/features/game/domain/repositories/game_repository.dart`](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/repositories/game_repository.dart) (Game repository), [`lib/features/game/data/repositories/game_repository_impl.dart`](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/repositories/game_repository_impl.dart) (Repository adapter), [`lib/features/game/presentation/page/game_page.dart`](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/game_page.dart) (Game screen), [`lib/features/game/presentation/cubit/game_cubit.dart`](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/cubit/game_cubit.dart) (Game state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game experience"]
  node_home["Mode selection<br/>[home_page.dart]"]
  node_game_ui["Game screen<br/>[game_page.dart]"]
  node_board["Board display<br/>[board_widget.dart]"]
  node_bluetooth_ui["Bluetooth screens"]
  node_game_state["Game state<br/>[game_cubit.dart]"]
  node_bt_state["Bluetooth state"]
end

subgraph group_logic["Game domain"]
  node_move["Move handling<br/>[make_move.dart]"]
  node_new_game["Start game"]
  node_sync["Match sync"]
  node_entities["Game model<br/>[board.dart]"]
  node_game_repo["Game repository"]
end

subgraph group_data["Data and services"]
  node_game_repo_impl["Repository adapter"]
  node_local_data["Local game data"]
  node_remote_data["Remote game data"]
  node_ai_data["AI engine source"]
  node_bluetooth_service["Bluetooth service"]
  node_auth_remote["Auth API source"]
  node_engine_interface["Engine interface"]
  node_engine_platforms["Platform engines<br/>[engine_darwin.dart]"]
end

subgraph group_app["App shell"]
  node_auth_ui["Login use case<br/>[login.dart]"]
  node_settings["Settings<br/>[setting_page.dart]"]
  node_router["App routing<br/>[app_router.dart]"]
  node_app_entry["Flutter app<br/>[main.dart]"]
end

node_player(("Player"))

node_player -.->|"chooses mode"| node_home
node_home -.->|"opens game"| node_game_ui
node_game_ui -.->|"dispatches actions"| node_game_state
node_game_ui -.->|"renders board"| node_board
node_game_state -.->|"starts match"| node_new_game
node_game_state -.->|"handles move"| node_move
node_move -.->|"requests update"| node_game_repo
node_new_game -.->|"requests setup"| node_game_repo
node_sync -.->|"requests sync"| node_game_repo
node_game_repo -.->|"implemented by"| node_game_repo_impl
node_game_repo_impl -.->|"uses local data"| node_local_data
node_game_repo_impl -.->|"uses remote data"| node_remote_data
node_game_repo_impl -.->|"uses engine"| node_ai_data
node_entities -.->|"models matches"| node_game_repo
node_player -.->|"joins local play"| node_bluetooth_ui
node_bluetooth_ui -.->|"dispatches actions"| node_bt_state
node_bt_state -.->|"uses service"| node_bluetooth_service
node_player -.->|"requests login"| node_auth_ui
node_auth_ui -.->|"requests authentication"| node_auth_remote
node_player -.->|"changes preferences"| node_settings
node_app_entry -.->|"starts navigation"| node_router
node_ai_data -.->|"uses interface"| node_engine_interface
node_engine_interface -.->|"implemented by"| node_engine_platforms

click node_home "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/home/home_page.dart"
click node_game_ui "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/game_page.dart"
click node_board "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/widget/board_widget.dart"
click node_bluetooth_ui "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/bluetooth/bluetooth_game_page.dart"
click node_game_state "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/cubit/game_cubit.dart"
click node_bt_state "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/cubit/bluetooth_game_cubit.dart"
click node_move "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/make_move.dart"
click node_new_game "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/start_new_game.dart"
click node_sync "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/sync_match_state.dart"
click node_entities "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/entities/board.dart"
click node_game_repo "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/repositories/game_repository.dart"
click node_game_repo_impl "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/repositories/game_repository_impl.dart"
click node_local_data "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/local_game_data_source.dart"
click node_remote_data "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/remote_game_data_source.dart"
click node_ai_data "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/ai_engie_data_source.dart"
click node_bluetooth_service "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/bluetooth/bluetooth_game_service.dart"
click node_auth_ui "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/auth/domain/usecases/login.dart"
click node_auth_remote "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/auth/data/datasources/auth_remote_data_source.dart"
click node_settings "https://github.com/ndgiang02/xiangqi/blob/master/lib/features/setting/presentation/page/setting_page.dart"
click node_router "https://github.com/ndgiang02/xiangqi/blob/master/lib/routes/app_router.dart"
click node_app_entry "https://github.com/ndgiang02/xiangqi/blob/master/lib/main.dart"
click node_engine_interface "https://github.com/ndgiang02/xiangqi/blob/master/plugins/engine_interface/lib/src/engine_interface.dart"
click node_engine_platforms "https://github.com/ndgiang02/xiangqi/blob/master/plugins/engine_darwin/lib/engine_darwin.dart"

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_game_ui,node_board,node_bluetooth_ui,node_game_state,node_bt_state toneBlue
class node_move,node_new_game,node_sync,node_entities,node_game_repo toneAmber
class node_game_repo_impl,node_local_data,node_remote_data,node_ai_data,node_bluetooth_service,node_auth_remote,node_engine_interface,node_engine_platforms toneMint
class node_auth_ui,node_settings,node_router,node_app_entry toneRose
class node_player toneIndigo
```

## Components

### Game experience

- [Mode selection](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/home/home_page.dart): `lib/features/game/presentation/page/home/home_page.dart`
- [Game screen](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/game_page.dart): `lib/features/game/presentation/page/game_page.dart`
- [Board display](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/widget/board_widget.dart): `lib/features/game/presentation/widget/board_widget.dart`
- [Bluetooth screens](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/page/bluetooth/bluetooth_game_page.dart): `lib/features/game/presentation/page/bluetooth/bluetooth_game_page.dart`
- [Game state](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/cubit/game_cubit.dart): `lib/features/game/presentation/cubit/game_cubit.dart`
- [Bluetooth state](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/presentation/cubit/bluetooth_game_cubit.dart): `lib/features/game/presentation/cubit/bluetooth_game_cubit.dart`

### Game domain

- [Move handling](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/make_move.dart): `lib/features/game/domain/usecases/make_move.dart`
- [Start game](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/start_new_game.dart): `lib/features/game/domain/usecases/start_new_game.dart`
- [Match sync](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/usecases/sync_match_state.dart): `lib/features/game/domain/usecases/sync_match_state.dart`
- [Game model](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/entities/board.dart): `lib/features/game/domain/entities/board.dart`
- [Game repository](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/domain/repositories/game_repository.dart): `lib/features/game/domain/repositories/game_repository.dart`

### Data and services

- [Repository adapter](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/repositories/game_repository_impl.dart): `lib/features/game/data/repositories/game_repository_impl.dart`
- [Local game data](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/local_game_data_source.dart): `lib/features/game/data/datasources/local_game_data_source.dart`
- [Remote game data](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/remote_game_data_source.dart): `lib/features/game/data/datasources/remote_game_data_source.dart`
- [AI engine source](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/datasources/ai_engie_data_source.dart): `lib/features/game/data/datasources/ai_engie_data_source.dart`
- [Bluetooth service](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/game/data/bluetooth/bluetooth_game_service.dart): `lib/features/game/data/bluetooth/bluetooth_game_service.dart`
- [Auth API source](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/auth/data/datasources/auth_remote_data_source.dart): `lib/features/auth/data/datasources/auth_remote_data_source.dart`
- [Engine interface](https://github.com/ndgiang02/xiangqi/blob/master/plugins/engine_interface/lib/src/engine_interface.dart): `plugins/engine_interface/lib/src/engine_interface.dart`
- [Platform engines](https://github.com/ndgiang02/xiangqi/blob/master/plugins/engine_darwin/lib/engine_darwin.dart): `plugins/engine_darwin/lib/engine_darwin.dart`

### App shell

- [Login use case](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/auth/domain/usecases/login.dart): `lib/features/auth/domain/usecases/login.dart`
- [Settings](https://github.com/ndgiang02/xiangqi/blob/master/lib/features/setting/presentation/page/setting_page.dart): `lib/features/setting/presentation/page/setting_page.dart`
- [App routing](https://github.com/ndgiang02/xiangqi/blob/master/lib/routes/app_router.dart): `lib/routes/app_router.dart`
- [Flutter app](https://github.com/ndgiang02/xiangqi/blob/master/lib/main.dart): `lib/main.dart`

### Other components

- **Player**

## Connections

- Player → Mode selection: chooses mode
- Mode selection → Game screen: opens game
- Game screen → Game state: dispatches actions
- Game screen → Board display: renders board
- Game state → Start game: starts match
- Game state → Move handling: handles move
- Move handling → Game repository: requests update
- Start game → Game repository: requests setup
- Match sync → Game repository: requests sync
- Game repository → Repository adapter: implemented by
- Repository adapter → Local game data: uses local data
- Repository adapter → Remote game data: uses remote data
- Repository adapter → AI engine source: uses engine
- Game model → Game repository: models matches
- Player → Bluetooth screens: joins local play
- Bluetooth screens → Bluetooth state: dispatches actions
- Bluetooth state → Bluetooth service: uses service
- Player → Login use case: requests login
- Login use case → Auth API source: requests authentication
- Player → Settings: changes preferences
- Flutter app → App routing: starts navigation
- AI engine source → Engine interface: uses interface
- Engine interface → Platform engines: implemented by
