Skip to content

V1 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 207 commits into
base: main
Choose a base branch
from
Draft

V1 #12

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
ea5496c
feat: add client-side maia analysis in alternate /analyze page
kevinjosethomas Jan 20, 2025
20c54d5
feat: added moves by rating graph and began ui changes
kevinjosethomas Jan 21, 2025
ca5b9c6
feat: added MoveMap, MoveRecommendations, color mappings, and Moves b…
kevinjosethomas Jan 21, 2025
dd1385f
fix: italian game variation
kevinjosethomas Jan 21, 2025
029696c
feat: add blundermeter, highlight, moves by rating legend, eval bars,…
kevinjosethomas Jan 22, 2025
33ab1df
feat: add configuration and export feature set
kevinjosethomas Jan 22, 2025
26d8576
feat: fix layout of board + eval bars, add check box to export pgn
kevinjosethomas Jan 22, 2025
cff9625
feat: add analysis game list to v2 analysis page
kevinjosethomas Jan 22, 2025
31bbc4a
feat: change path urls from /analyze to /analysis and port /analysis …
kevinjosethomas Jan 22, 2025
bf921af
feat: migrate from original -> legacy filenames, and refactor client …
kevinjosethomas Jan 22, 2025
b373209
fix: type build errors
kevinjosethomas Jan 24, 2025
9c82b2d
fix: render errors + add maia to tournament games + access errors
kevinjosethomas Jan 25, 2025
0055b52
feat: port to new endpoints + move towards adding modal before using …
kevinjosethomas Feb 4, 2025
61599b6
feat: codemod migration to nextjs 15
kevinjosethomas Feb 4, 2025
9f62316
fix: dev errors + outdated scss
kevinjosethomas Feb 4, 2025
470a64f
fix: scss + type errors
kevinjosethomas Feb 4, 2025
6361c68
fix: build errors
kevinjosethomas Feb 4, 2025
59074c9
fix: lint errors + remove unnecessary document page
kevinjosethomas Feb 5, 2025
26a2e40
Merge #5: Upgrade NextJS to Next 15
kevinjosethomas Feb 5, 2025
31af432
chore: move maia2 onnx models + add stateful maia hook
kevinjosethomas Feb 5, 2025
813bb43
feat: add download maia2 modal
kevinjosethomas Feb 5, 2025
2cb629b
feat: made modal responsive
kevinjosethomas Feb 5, 2025
4686b38
fix: lint errors
kevinjosethomas Feb 5, 2025
3ab6f28
fix: errors in analysis + orientation of stockfish eval
kevinjosethomas Feb 5, 2025
774b6fa
feat: added toasts and indicator for ONNX model loading
kevinjosethomas Feb 5, 2025
545ed7e
fix: moves by rating for tournament games
kevinjosethomas Feb 5, 2025
aa2d705
feat: add tree data structure
kevinjosethomas Feb 7, 2025
5eca66b
feat: add copies of components in client form
kevinjosethomas Feb 7, 2025
5fa3046
feat: create ClientBoardController and ClientGameBoard components
kevinjosethomas Feb 7, 2025
461bf2b
feat: create ClientGamePlayInterface and ClientMovesContainer components
kevinjosethomas Feb 7, 2025
f45eb51
feat: migrate useAnalysisController and GameControllerContext to useC…
kevinjosethomas Feb 7, 2025
cf42cff
feat: migrate stockfish engine and types
kevinjosethomas Feb 7, 2025
1c91d49
feat: create copy of analysis via /analysis/client pages
kevinjosethomas Feb 7, 2025
9d1ee18
feat: migrate Stockfish analysis to use async generator instead of ca…
kevinjosethomas Feb 7, 2025
a65e1af
fix: stockfish perspective bug + rendering errors
kevinjosethomas Feb 7, 2025
d46cf61
feat: add variations + free analysis
kevinjosethomas Feb 8, 2025
51d6274
fix: fix legacy analysis controller to work with stockfish streaming
kevinjosethomas Feb 8, 2025
daa12d5
fix: game selection and redirect criteria
kevinjosethomas Feb 8, 2025
fc64c78
fix: stockfish analysis for tournament games
kevinjosethomas Feb 8, 2025
1a29ad5
fix: allow client-side stockfish eval for tournament game variations
kevinjosethomas Feb 8, 2025
6ae40c1
fix: build errors
kevinjosethomas Feb 8, 2025
4b0700f
chore: remove ClientGameplayInterface
kevinjosethomas Feb 8, 2025
da6b88c
chore: redirect all new free analysis to /analysis endpoint
kevinjosethomas Feb 8, 2025
7071623
fix: orientation bug
kevinjosethomas Feb 8, 2025
f4a12ff
Merge #6: Migrate from array to tree data structure for game state st…
kevinjosethomas Feb 8, 2025
97aa205
feat: start initial redesign of analysis page
kevinjosethomas Feb 9, 2025
c63fd3f
feat: moved moves by rating graph to highlight component + added move…
kevinjosethomas Feb 9, 2025
85afbb4
feat: repalced + removed eval bars from game board
kevinjosethomas Feb 9, 2025
b9ca13e
feat: swapped axes of movce map
kevinjosethomas Feb 9, 2025
0c491cf
feat: fix moves by rating graph + add vertical blunder meter
kevinjosethomas Feb 9, 2025
9baa2bf
feat: universal san mapping type + improve blunder meter
kevinjosethomas Feb 9, 2025
b50e9fc
feat: add game info to analysis
kevinjosethomas Feb 10, 2025
ef165e4
feat: add dropdown configure + export options under game board
kevinjosethomas Feb 10, 2025
0ba7dd9
fix: stockfish eval orientation + blunder meter in tournament games
kevinjosethomas Feb 10, 2025
8191748
fix: stockfish relative eval + move map + highlight eval precision
kevinjosethomas Feb 10, 2025
82979b0
chore: port to npm + remove Dockerfile
kevinjosethomas Feb 10, 2025
b3a72cf
fix: restrict ci/cd to node 18
kevinjosethomas Feb 10, 2025
61a74bd
fix: blunder meter + movemap + game selection bug
kevinjosethomas Feb 10, 2025
2572884
feat: add hover/click options to blunder meter and move recommendatio…
kevinjosethomas Feb 10, 2025
a104349
fix: typos and lint errors
kevinjosethomas Feb 10, 2025
794cc69
feat: add move list variations
kevinjosethomas Feb 11, 2025
6d40330
feat: upgrade move list variation ui
kevinjosethomas Feb 11, 2025
79b6873
feat: complete new move list variation handling
kevinjosethomas Feb 11, 2025
c646c63
fix: analysis spacing
ashtonanderson Feb 11, 2025
9a4c675
fix: analysis font sizes
ashtonanderson Feb 11, 2025
cf0378e
feat: blunder meter move selection
ashtonanderson Feb 11, 2025
a9c4072
fix: show corrent move number in move list, especially when starting …
kevinjosethomas Feb 12, 2025
6c48f78
fix: moves container alignment + fen & pgn export + added toasts to c…
kevinjosethomas Feb 12, 2025
8719034
feat: add local storage parameter to store legacy preference
kevinjosethomas Feb 12, 2025
26ae33d
feat: add notice to legacy analysis to redirect to new analysis + fix…
kevinjosethomas Feb 12, 2025
3d83585
feat: make new analysis page responsive + improve leaderboard page de…
kevinjosethomas Feb 13, 2025
f8c5bc8
fix: maia board mirroring bug
kevinjosethomas Feb 13, 2025
a81626d
feat: change color san mapping to base off stockfish eval instead
kevinjosethomas Feb 15, 2025
1f3232b
feat: implement traffic light colour scheme!
kevinjosethomas Feb 16, 2025
259f782
feat: add tooltip to move list + remove move recommendations component
kevinjosethomas Feb 16, 2025
331057a
feat: improve move map + blunder meter
kevinjosethomas Feb 16, 2025
22091e9
feat: add blunder indicators to move list
kevinjosethomas Feb 16, 2025
921d9a4
feat: add horizontal blunder meter for mobile
kevinjosethomas Mar 6, 2025
d7739fc
feat: add horizontal moves container for mobile devices
kevinjosethomas Mar 8, 2025
4c4cbe6
feat: store selected maia model in local storage cache
kevinjosethomas Mar 8, 2025
1737252
feat: add sound effects to analysis and play game board
kevinjosethomas Mar 8, 2025
a704ac3
chore: remove AnalysisMoves
kevinjosethomas Mar 8, 2025
7feac8c
feat: add cpToWinrate method
kevinjosethomas Mar 8, 2025
ff450a6
feat: add y-axis legend/labels to moves by rating component
kevinjosethomas Mar 8, 2025
8b0547d
feat: correctly set selected game list screen and default to top play…
kevinjosethomas Mar 8, 2025
8a7ebf6
chore: reduce to top 4 moves instead of 6
kevinjosethomas Mar 8, 2025
adb0821
feat: swap axes of movemap
kevinjosethomas Mar 8, 2025
0cd1054
feat: add currentMaiaModel selector to GameInfo component
kevinjosethomas Mar 9, 2025
4ff558d
feat: rearrange and resize components for mobile analysis page
kevinjosethomas Mar 9, 2025
b64b3e4
feat: add Analysis Game List component to mobile devices + fix termin…
kevinjosethomas Mar 9, 2025
2f25086
feat: made moves by rating graph and MoveMap graph response on mobile…
kevinjosethomas Mar 9, 2025
5d6cd47
feat: add back moves list container to mobile play page
kevinjosethomas Mar 9, 2025
1fa395c
feat: port to use winrate loss instead of centipawn loss for move cat…
kevinjosethomas Mar 9, 2025
59c180b
chore: minor switch
kevinjosethomas Mar 9, 2025
2de7b68
feat: set colours based on winrate loss instead of cp loss
kevinjosethomas Mar 9, 2025
c7c872e
feat: correctly size Profile page
kevinjosethomas Mar 9, 2025
3dc8df3
feat: update footer w/ more information
kevinjosethomas Mar 9, 2025
5c9611e
feat: migrated landing about maia content to blog post
kevinjosethomas Mar 9, 2025
26491b8
feat: clean up landing
kevinjosethomas Mar 10, 2025
ef242ff
feat: add initial iteration of new landing page
kevinjosethomas Mar 10, 2025
07514c4
feat: clean up team + landing play component
kevinjosethomas Mar 10, 2025
52f0c3b
feat: improve PlaySection and AnalysisSection landing
kevinjosethomas Mar 10, 2025
9d92e3d
feat: clean up training section of landing page
kevinjosethomas Mar 11, 2025
a4e1737
feat: clean up landing page further
kevinjosethomas Mar 11, 2025
71dec85
feat: improve landing page sections
kevinjosethomas Mar 11, 2025
9f3dd51
feat: clean up chessboard animations + fix team page + clean up addit…
kevinjosethomas Mar 12, 2025
c2164a9
feat: clean up chessboards + improve responsiveness + improve landing…
kevinjosethomas Mar 12, 2025
a08d024
feat: make landing page more responsive + clean up code
kevinjosethomas Mar 12, 2025
4197ec2
feat: add pagination to game lists
kevinjosethomas Mar 18, 2025
c409b86
feat: add keyboard navigation to analysis
kevinjosethomas Mar 18, 2025
859f546
feat: add text heuristic description of game board
kevinjosethomas Mar 19, 2025
5018803
feat: added board description + exclam icon for surprising good moves
kevinjosethomas Mar 19, 2025
dd7b32f
feat: add fallback to opening book for initial analysis
kevinjosethomas May 14, 2025
28d963a
feat: add global stats component
kevinjosethomas May 14, 2025
e5aad4d
feat: clean up analysis hook + implement opening book value head
kevinjosethomas May 15, 2025
efcca23
fix: build & lint errors
kevinjosethomas May 15, 2025
cb49c9c
fix: add move sounds for maia moves
kevinjosethomas May 27, 2025
1de4c32
feat: add move sound effects to hand & brain games
kevinjosethomas May 28, 2025
7b73991
feat: add analyze game option post-game
kevinjosethomas May 28, 2025
45e670c
feat: clean up front page
kevinjosethomas May 29, 2025
eb58a6e
chore: fix landing chessboards
kevinjosethomas May 29, 2025
1a975a6
feat: implemented caching for analysisgamelist + profile page game list
kevinjosethomas May 29, 2025
942cae8
feat: add beta blurb to landing
kevinjosethomas May 29, 2025
c37b421
Adding a file for generating descriptions (v1)
BasedBerry Jun 9, 2025
3bad4a1
Update useDescriptionGenerator.ts
BasedBerry Jun 9, 2025
55d5896
fix: add error handling for invalid fen positions
kevinjosethomas Jun 10, 2025
ec26156
fix: bug in legacy analysis currentMaiaModel version
kevinjosethomas Jun 11, 2025
06d59bd
feat: migrate play page to use tree structure
kevinjosethomas Jun 14, 2025
8dadd0f
feat: migrate h&b to use tree structure
kevinjosethomas Jun 14, 2025
08120de
feat: migrate train page to use new train controller
kevinjosethomas Jun 14, 2025
688da4a
feat: migrate turing to use tree data structure
kevinjosethomas Jun 14, 2025
8ff2bcb
feat: consolidate components + clean up training page
kevinjosethomas Jun 14, 2025
5dee7d7
feat: clean up board controller
kevinjosethomas Jun 14, 2025
1e94e9e
feat: modularize + clean up
kevinjosethomas Jun 16, 2025
281c022
feat: condense move container components + condense controllers
kevinjosethomas Jun 16, 2025
fef0ddd
chore: remove legacy components
kevinjosethomas Jun 16, 2025
dae5d07
chore: refactor components + clean up types
kevinjosethomas Jun 16, 2025
20321b6
feat: clean up play controller adding new moves
kevinjosethomas Jun 17, 2025
a231a8b
feat: migrate turing to use tree datastructure + clean up type incons…
kevinjosethomas Jun 17, 2025
a32281d
feat: remove legacy analysis page featureset
kevinjosethomas Jun 17, 2025
d0c13e5
Update useDescriptionGenerator.ts
BasedBerry Jun 17, 2025
2c6ca3f
feat: cleanup analysis controllers + linter errors
kevinjosethomas Jun 17, 2025
45507d3
feat: clean up play page conventions
kevinjosethomas Jun 19, 2025
e16b396
feat: migrate train page to tree structure + handle all cases
kevinjosethomas Jun 19, 2025
80a0564
refactor: playcontroller use treecontroller
kevinjosethomas Jun 19, 2025
67c25e1
chore: fix build + lint errors
kevinjosethomas Jun 19, 2025
85fceab
feat: add first iteration of analysis in puzzle page
kevinjosethomas Jun 19, 2025
ff0d907
chore: clean up + modularize code
kevinjosethomas Jun 19, 2025
be75bee
fix: orientation bug + clean up code
kevinjosethomas Jun 19, 2025
f7f7a1e
feat: add download model modal blocker to train page
kevinjosethomas Jun 19, 2025
9914369
fix: build errors
kevinjosethomas Jun 19, 2025
983b5c4
docs: update feedback
kevinjosethomas Jun 19, 2025
49c4f3a
fix: remove redundant dependency
kevinjosethomas Jun 19, 2025
9d82879
Apply suggestions from cocdcdfde reviewf
kevinjosethomas Jun 19, 2025
b402f5d
fix: lint errors
kevinjosethomas Jun 19, 2025
27717b5
Merge pull request #9 from CSSLab/migrate-tree
kevinjosethomas Jun 19, 2025
15155d0
feat: incorporate new board description generator + fix lint errors
kevinjosethomas Jun 19, 2025
ec1c8b6
Merge pull request #8 from CSSLab/BasedBerry-descriptionUpdate
kevinjosethomas Jun 19, 2025
f0e10bc
feat: add custom game analysis modal
kevinjosethomas Jun 20, 2025
f458371
chore: add initial iteration of openings modal
kevinjosethomas Jun 23, 2025
b9a9fd8
fix: bugs with play mode
kevinjosethomas Jun 23, 2025
0159477
chore: update with moves container + variations
kevinjosethomas Jun 24, 2025
5f2e0f1
feat: add initial working iteration of working opening drilling
kevinjosethomas Jun 24, 2025
6672199
feat: enhance OpeningDrillSidebar with reset functionality and integr…
kevinjosethomas Jun 24, 2025
70c1d7a
feat: enhance OpeningSelectionModal with improved styling and integra…
kevinjosethomas Jun 24, 2025
4e966f9
feat: refactor OpeningDrillAnalysis to use parent hover functions and…
kevinjosethomas Jun 24, 2025
e6384a6
feat: overhaul opening book modal
kevinjosethomas Jun 24, 2025
da0e8f4
feat: enhance opening drill functionality with new drill performance …
kevinjosethomas Jun 24, 2025
959f29d
feat: allow repeated openings for increased number of drills
kevinjosethomas Jun 25, 2025
f02dc33
feat: improve movemap to show all moves + improve movetooltip across …
kevinjosethomas Jun 25, 2025
6828b76
feat: update layout styles across multiple pages for consistent horiz…
kevinjosethomas Jun 25, 2025
25ad9de
feat: improve drill ending functionality
kevinjosethomas Jun 25, 2025
798c407
fix: opening drill sidebar
kevinjosethomas Jun 25, 2025
989e4a5
feat: enhance modal components with improved styling, layout adjustme…
kevinjosethomas Jun 26, 2025
ea115f9
fix: bug with duplicate get_move requests
kevinjosethomas Jun 26, 2025
7887b0b
feat: add view summary option after drills are complete
kevinjosethomas Jun 26, 2025
4ddc76e
feat: add functionality to update completed drills with new moves and…
kevinjosethomas Jun 26, 2025
b91e34f
fix: allow maia to continue opening after finish
kevinjosethomas Jun 26, 2025
d0fee62
fix: overwrite drills after reset
kevinjosethomas Jun 26, 2025
292426e
feat: improve opening modal
kevinjosethomas Jun 26, 2025
f30e1a2
feat: add initial iteration of drill performance confirmation
kevinjosethomas Jun 28, 2025
651b1a2
refactor: remove play/pause functionality and clean up evaluation cha…
kevinjosethomas Jun 28, 2025
3f34a88
refactor: remove ThemeButton component and update theme handling to s…
kevinjosethomas Jun 28, 2025
3b7dc5e
feat: make opening selection modal responsive for mobile
kevinjosethomas Jun 28, 2025
e3a73af
refactor: migrate scss to tailwind css
kevinjosethomas Jun 28, 2025
7270dd9
fix: update PGN generation to include headers
kevinjosethomas Jun 28, 2025
e4953e8
refactor: update BlunderMeter calculations to cap at 100%
kevinjosethomas Jun 28, 2025
1350b7a
feat: enhance DrillPerformanceModal with move classification and key …
kevinjosethomas Jun 28, 2025
1de35d5
feat: add MoveQualityDistribution component and enhance FinalCompleti…
kevinjosethomas Jun 28, 2025
5b429d2
feat: add research papers section with detailed descriptions and link…
kevinjosethomas Jun 28, 2025
3994188
Merge pull request #11 from CSSLab/opening-page
kevinjosethomas Jun 29, 2025
c3a614e
docs: update readme + fix paper url
kevinjosethomas Jun 29, 2025
c01ef5d
docs: update readme
kevinjosethomas Jun 29, 2025
9e206f4
fix: readme
kevinjosethomas Jun 29, 2025
e562873
fix: search + slider state issue
kevinjosethomas Jun 30, 2025
3b91505
fix: stockfish promotion logic + blunder meter cases
kevinjosethomas Jun 30, 2025
50b3647
fix: issue with visiting previous puzzles
kevinjosethomas Jul 1, 2025
4f77fce
fix: allow navigating old puzzles
kevinjosethomas Jul 1, 2025
47150c6
fix: training log rating diff bug
kevinjosethomas Jul 1, 2025
3ba7dcb
feat: overhaul puzzle log
kevinjosethomas Jul 1, 2025
766d7fb
fix: issue with incorrect status
kevinjosethomas Jul 1, 2025
eb7ebf5
fix: make analysis components responsive
kevinjosethomas Jul 1, 2025
638239d
fix: leaderboard duplicate hover popup
kevinjosethomas Jul 2, 2025
0bc71a9
feat: change layout to make analysis page responsive
kevinjosethomas Jul 2, 2025
3cf141f
feat: implement new analysis layout for training + opening page
kevinjosethomas Jul 2, 2025
a8d8693
style: better handle responsiveness in opening selection modal
kevinjosethomas Jul 2, 2025
2c1fd26
fix: analysis disabled popup on train + opening page
kevinjosethomas Jul 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .dockerignore

This file was deleted.

10 changes: 9 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-unused-vars": "off",
"@next/next/no-html-link-for-pages": "off",
"import/no-named-as-default": "off",
"@next/next/no-img-element": "off",
"@next/next/no-page-custom-font": "off",
"@next/next/no-duplicate-head": "off",
"@next/next/no-typos": "off",
"@next/next/no-before-interactive-script-outside-document": "off",
"@next/next/no-styled-jsx-in-document": "off",
"@next/next/no-head-import-in-document": "off",
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"typescript/no-var-requires": "off",
"@typescript-eslint/no-var-requires": "off",
},
},
],
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: yarn
- run: yarn lint
- run: npm i
- run: npm run lint

build:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18', '20']
node: ['18']
name: Node ${{ matrix.node }} Build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: yarn build
- run: npm i
- run: npm run build
37 changes: 0 additions & 37 deletions Dockerfile

This file was deleted.

227 changes: 88 additions & 139 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,188 +1,137 @@
# maia platform
<p align="center">
<p align="center">
<img width="150" src="public/maia-no-bg.png" alt="Logo">
</p>
<h1 align="center"><b>Maia Chess</b></h1>
<p align="center">
A human-like chess engine.
<br />
<a href="https://www.maiachess.com"><strong>maiachess.com »</strong></a>
<br />
<br />
</p>
</p>

This is the code that powers the[ Maia Chess platform](https://www.maiachess.com).

It is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with the additions of [`typescript`](https://www.typescriptlang.org/), [`eslint`](https://eslint.org/), [`storybook`](https://storybook.js.org/), [`prettier`](https://prettier.io/), [`sass`](https://sass-lang.com/), [`testing-library`](https://testing-library.com/) ,and [`jest`](https://jestjs.io/).
This repository contains the source code for the [Maia Chess Platform](https://www.maiachess.com), a modern web application designed for chess training and analysis. It leverages the Maia chess engine, developed by the University of Toronto's Computational Social Science Lab, to provide human-like move predictions and insights. The platform is built with Next.js, TypeScript, and Tailwind CSS. Join our [Discord server](https://discord.gg/hHb6gqFpxZ) for discussions, questions, and to connect with the community.

Initialize a new `next-app` with this project as a template by running
## Getting Started

```bash
npx create next-app --example https://github.com/datadeque/next-app
# or
yarn create next-app --example https://github.com/datadeque/next-app
```

## Development Guide

This project uses [`yarn`](https://yarnpkg.com/) and is developed & maintained for [`node`](https://nodejs.org/en/) version 17+ (however CI will try builds using versions 12, 14, and 16 as well).

The recommended code editor is [`vscode`](https://code.visualstudio.com/) along with the following extensions (see `.vscode/extensions.json`):

- eslint (Linter)
- prettier (Formatter)
- mdx (Syntax Highlighting for Storybook)
Follow these instructions to set up the development environment on your local machine.

These extensions are highly recommended along with vscode because the project is pre-configured to format and fix ALL fixable issues on save. Furthermore, please open this project by running `code .` in the root directory from your terminal since there are known issues with environment variables when opening the project from gui.
### Prerequisites

It also helps to know the following tools:
- Node.js (v17+ recommended)
- npm (comes bundled with Node.js)

- [`sass`](https://sass-lang.com/)
- [`react contexts`](https://reactjs.org/docs/context.html)
- [`react custom hooks`](https://reactjs.org/docs/hooks-custom.html)
### Installation

### Design
1. Clone the repository to your local machine:

Each page of the platform can be found in `src/pages`. Inside, a wrapper component fetches the data from the api and renders the page itself when the data is received. An example of this is in the `train` page where `TrainPage` fetches the game, and renders `Train`.
```bash
git clone https://github.com/maia-chess/maia-platform-frontend.git
cd maia-platform-frontend
```

We'll refer the component rendered by the wrapper as the main component. Inside the main component a custom hook is used to isolate all the logic, and two variables `mobileLayout` and `desktopLayout` are initialized to represent the corresponding layouts.
2. Install the project dependencies using npm:
```bash
npm install
```

The `GameControllerContext` is used to simply pass data down, as any child component of the main component can easily consume the controller without passing it down multiple layers using props.
### Running the Development Server

Each main component typically contains a `GameBoard` component which renders the lichess chessboard UI, and a family of surrounding components that are either interactive or show information such as analysis.

### Getting Started

First, install the dependencies by running
To start the local development server, run the following command. This will launch the application on `http://localhost:3000` with hot-reloading enabled.

```bash
yarn
# or
yarn install
npm run dev
```

Then start the development server by running
### Building for Production

To create a production-ready build of the application, use the following command. This will compile and optimize the code, outputting the final assets to the `.next` directory.

```bash
yarn dev
npm run build
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can then start the production server with `npm run start`.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
## Development Guide

### Storybook
This section provides guidelines for contributing to the platform's development.

To start storybook development server by running
### Branching Strategy

```bash
yarn storybook
```
The repository follows a simple branching model:

Open http://localhost:6006/ with your browser and see the result.
- `main`: This branch is synced with the live deployment on Vercel. All code on this branch is considered production-ready.
- **Feature Branches**: All development work, including new features and bug fixes, should be done on separate feature branches. These branches are then merged into `main` via pull requests.

### Linting & Testing
### Conventional Commits

You can lint the entire project using the built-in `eslint` config by running
We use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for our commit messages. This standard creates a more readable and structured commit history. Each commit message should follow the format:

```bash
yarn lint
```
`{type}: {description}`

This is the same command that runs during the lint step of the initial CI.
Common types include:

You can run your test files by running
- `feat`: A new feature
- `fix`: A bug fix
- `chore`: Changes to the build process or auxiliary tools
- `style`: Code style changes (formatting, etc.)
- `refactor`: A code change that neither fixes a bug nor adds a feature
- `docs`: Documentation only changes

```bash
yarn test
```
### Architectural Overview

This is the same command that runs during the test step of the initial CI.
The platform is architected around a modular and scalable structure, leveraging modern React patterns.

## Development Practices
#### File Structure

### Committing
The `src/` directory contains all the core application code, organized as follows:

Conventional commits is a pretty simple convention, you can learm more about it [here](https://www.conventionalcommits.org/en/v1.0.0/).
```
src/
├── api/ # Backend API client functions, organized by feature
├── components/ # Reusable React components, structured by feature or domain
├── contexts/ # React Context providers for global state management
├── hooks/ # Custom React Hooks containing business logic and state
├── pages/ # Next.js pages, defining the application's routes
├── providers/ # Wrappers for context providers
├── styles/ # Global styles and Tailwind CSS configuration
├── types/ # TypeScript type definitions, organized by feature
└── utils/ # Utility functions and helpers
```

Basically commit messages follow the following format: `{action}: {description}`, where action is one of `feat`, `chore`, `fix`, `style`... and description is description of the change in present tense.
#### Core Concepts and Interactions

### Testing
The application's logic is primarily driven by a combination of custom hooks, React contexts, and components, creating a clear separation of concerns.

Every react component should atleast have one test, to see if it renders. Test files are to be placed in `__test__` and follow the same file structure as the project root.
- **Components (`src/components/`)**: These are the building blocks of the UI. They are designed to be "dumb" or presentational, receiving data and callbacks via props. Major features like `Analysis`, `Play`, `Openings`, and `Training` have their own dedicated component directories.

Suppose you built a new component under `src/components/button/button.tsx`, a test should be placed in `__tests__/components/button/button.test.tsx` with the following:
- **Hooks (`src/hooks/`)**: This is where the majority of the application's business logic resides. Each major feature has a corresponding "controller" hook (e.g., `usePlayController`, `useAnalysisController`). These hooks encapsulate state management, interactions with the chess engines, and API calls. They effectively act as state machines for their respective features.

```tsx
import { render } from '@testing-library/react'
import Button from 'components/button'
- **Contexts (`src/contexts/`)**: To avoid prop drilling, we use React Context to provide the state and methods from our controller hooks to the component tree. For example, `PlayControllerContext` will expose the state and functions from the `usePlayController` hook to any child component that needs it, such as the `GameBoard` or `PlayControls`.

describe('Button', () => {
it('renders', () => {
render(<Button />)
})
})
```
This architecture allows for a decoupled system where the UI (components) is a function of the state managed by the hooks, and the state is shared efficiently through contexts. For example, a page component under `src/pages` will initialize a controller hook. That hook's state is then provided to the component tree via a Context Provider. Child components can then consume that context to access state and dispatch actions without passing props down multiple levels.

This will ensure that future modifications by others won't severely break your component. Should you have a complex component that interacts with its props, you should add some more complex tests.
#### Learning Resources

### File Structure
To better understand the patterns used in this codebase, we recommend reviewing the official documentation for these core React and Next.js features:

Below is the an example of a recommended file structure:
- [React Hooks](https://react.dev/reference/react/hooks)
- [React Context](https://react.dev/reference/react/createContext)
- [Next.js App Router](https://nextjs.org/docs)

```
src/
pages/
components/
ComponentName/
ComponentName.tsx
index.tsx
styles.scss # Modular Styles if needed
index.tsx
styles/
contexts/
hooks/
utils/
```
### Client-Side Chess Engines

## Github Actions

This project is has the following pre-configuration, which tests, lints and builds all branches and PRs.

```yaml
name: CI

on:
push:
pull_request:
branches: ['**']

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: yarn
- run: yarn test

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: yarn
- run: yarn lint

build:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['12', '14', '16', '17']
name: Node ${{ matrix.node }} Build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: yarn build
```
A key feature of the platform is its ability to run both Stockfish and Maia directly in the user's browser. This is accomplished using WebAssembly and ONNX Runtime Web.

- **Stockfish (`src/hooks/useStockfishEngine/`)**: We use a WebAssembly (WASM) version of Stockfish for standard chess analysis. The `useStockfishEngine` hook provides a simple interface to interact with the engine, allowing for move evaluation streams. This provides the "objective" best moves in any given position.

## Learn More
- **Maia (`src/hooks/useMaiaEngine/`)**: The Maia engine is a neural network provided as an ONNX (Open Neural Network Exchange) model. We use the `onnxruntime-web` library to load and run Maia models on the client-side. The `useMaiaEngine` hook manages the download, initialization, and execution of the various Maia models (e.g., `maia_kdd_1100` to `maia_kdd_1900`). This engine provides the "human-like" move predictions that are central to the platform's mission.

To learn more about Next.js, take a look at the following resources:
These hooks are consumed by higher-level controller hooks (like `useAnalysisController`) to provide the dual-engine analysis that powers many of the platform's features.

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
## Deployment

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
The Maia Chess Platform is deployed on [Vercel](https://vercel.com/). The `main` branch is automatically built and deployed to the production URL. Pull requests also generate unique preview deployments, allowing for easy testing and review before merging.
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
3 changes: 0 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const withTM = require('next-transpile-modules')(['@react-chess/chessground'])
module.exports = withTM({
reactStrictMode: false,
output: 'standalone',
experimental: {
esmExternals: 'loose',
},
async rewrites() {
return [
{
Expand Down
Loading