Skip to content

Commit c3a614e

Browse files
docs: update readme + fix paper url
1 parent 3994188 commit c3a614e

2 files changed

Lines changed: 83 additions & 139 deletions

File tree

README.md

Lines changed: 82 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,132 @@
1-
# maia platform
1+
<div align="center" style="margin-bottom: 3rem;">
2+
<img src="public/maia-no-bg.png" width="64" alt="Maia Chess Logo">
3+
<h1><a href="https://www.maiachess.com">Maia Chess</a></h1>
4+
<i>A human-like chess engine</i>
5+
</div>
26

3-
This is the code that powers the[ Maia Chess platform](https://www.maiachess.com).
4-
5-
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/).
7+
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.
68

7-
Initialize a new `next-app` with this project as a template by running
9+
Join our Discord server for discussions, questions, and to connect with the community:
10+
[Maia Chess Community on Discord](https://discord.gg/hHb6gqFpxZ)
811

9-
```bash
10-
npx create next-app --example https://github.com/datadeque/next-app
11-
# or
12-
yarn create next-app --example https://github.com/datadeque/next-app
13-
```
14-
15-
## Development Guide
16-
17-
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).
18-
19-
The recommended code editor is [`vscode`](https://code.visualstudio.com/) along with the following extensions (see `.vscode/extensions.json`):
20-
21-
- eslint (Linter)
22-
- prettier (Formatter)
23-
- mdx (Syntax Highlighting for Storybook)
12+
## Getting Started
2413

25-
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.
14+
Follow these instructions to set up the development environment on your local machine.
2615

27-
It also helps to know the following tools:
16+
### Prerequisites
2817

29-
- [`sass`](https://sass-lang.com/)
30-
- [`react contexts`](https://reactjs.org/docs/context.html)
31-
- [`react custom hooks`](https://reactjs.org/docs/hooks-custom.html)
18+
- Node.js (v17+ recommended)
19+
- npm (comes bundled with Node.js)
3220

33-
### Design
21+
### Installation
3422

35-
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`.
23+
1. Clone the repository to your local machine:
3624

37-
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.
25+
```bash
26+
git clone https://github.com/maia-chess/maia-platform-frontend.git
27+
cd maia-platform-frontend
28+
```
3829

39-
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.
30+
2. Install the project dependencies using npm:
31+
```bash
32+
npm install
33+
```
4034

41-
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.
35+
### Running the Development Server
4236

43-
### Getting Started
44-
45-
First, install the dependencies by running
37+
To start the local development server, run the following command. This will launch the application on `http://localhost:3000` with hot-reloading enabled.
4638

4739
```bash
48-
yarn
49-
# or
50-
yarn install
40+
npm run dev
5141
```
5242

53-
Then start the development server by running
43+
### Building for Production
44+
45+
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.
5446

5547
```bash
56-
yarn dev
48+
npm run build
5749
```
5850

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

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

63-
### Storybook
55+
This section provides guidelines for contributing to the platform's development.
6456
65-
To start storybook development server by running
57+
### Branching Strategy
6658
67-
```bash
68-
yarn storybook
69-
```
59+
The repository follows a simple branching model:
7060
71-
Open http://localhost:6006/ with your browser and see the result.
61+
- `main`: This branch is synced with the live deployment on Vercel. All code on this branch is considered production-ready.
62+
- **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.
7263
73-
### Linting & Testing
64+
### Conventional Commits
7465
75-
You can lint the entire project using the built-in `eslint` config by running
66+
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:
7667
77-
```bash
78-
yarn lint
79-
```
68+
`{type}: {description}`
8069
81-
This is the same command that runs during the lint step of the initial CI.
70+
Common types include:
8271
83-
You can run your test files by running
72+
- `feat`: A new feature
73+
- `fix`: A bug fix
74+
- `chore`: Changes to the build process or auxiliary tools
75+
- `style`: Code style changes (formatting, etc.)
76+
- `refactor`: A code change that neither fixes a bug nor adds a feature
77+
- `docs`: Documentation only changes
8478
85-
```bash
86-
yarn test
87-
```
79+
### Architectural Overview
8880
89-
This is the same command that runs during the test step of the initial CI.
81+
The platform is architected around a modular and scalable structure, leveraging modern React patterns.
9082
91-
## Development Practices
83+
#### File Structure
9284
93-
### Committing
85+
The `src/` directory contains all the core application code, organized as follows:
86+
87+
```
88+
src/
89+
├── api/ # Backend API client functions, organized by feature
90+
├── components/ # Reusable React components, structured by feature or domain
91+
├── contexts/ # React Context providers for global state management
92+
├── hooks/ # Custom React Hooks containing business logic and state
93+
├── pages/ # Next.js pages, defining the application's routes
94+
├── providers/ # Wrappers for context providers
95+
├── styles/ # Global styles and Tailwind CSS configuration
96+
├── types/ # TypeScript type definitions, organized by feature
97+
└── utils/ # Utility functions and helpers
98+
```
9499

95-
Conventional commits is a pretty simple convention, you can learm more about it [here](https://www.conventionalcommits.org/en/v1.0.0/).
100+
#### Core Concepts and Interactions
96101

97-
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.
102+
The application's logic is primarily driven by a combination of custom hooks, React contexts, and components, creating a clear separation of concerns.
98103

99-
### Testing
104+
- **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.
100105

101-
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.
106+
- **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.
102107

103-
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:
108+
- **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`.
104109

105-
```tsx
106-
import { render } from '@testing-library/react'
107-
import Button from 'components/button'
110+
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.
108111

109-
describe('Button', () => {
110-
it('renders', () => {
111-
render(<Button />)
112-
})
113-
})
114-
```
112+
#### Learning Resources
115113

116-
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.
114+
To better understand the patterns used in this codebase, we recommend reviewing the official documentation for these core React and Next.js features:
117115

118-
### File Structure
116+
- [React Hooks](https://react.dev/reference/react/hooks)
117+
- [React Context](https://react.dev/reference/react/createContext)
118+
- [Next.js App Router](https://nextjs.org/docs)
119119

120-
Below is the an example of a recommended file structure:
120+
### Client-Side Chess Engines
121121

122-
```
123-
src/
124-
pages/
125-
components/
126-
ComponentName/
127-
ComponentName.tsx
128-
index.tsx
129-
styles.scss # Modular Styles if needed
130-
index.tsx
131-
styles/
132-
contexts/
133-
hooks/
134-
utils/
135-
```
122+
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.
136123

137-
## Github Actions
138-
139-
This project is has the following pre-configuration, which tests, lints and builds all branches and PRs.
140-
141-
```yaml
142-
name: CI
143-
144-
on:
145-
push:
146-
pull_request:
147-
branches: ['**']
148-
149-
jobs:
150-
test:
151-
runs-on: ubuntu-latest
152-
steps:
153-
- uses: actions/checkout@v2
154-
- uses: actions/setup-node@v2
155-
- run: yarn
156-
- run: yarn test
157-
158-
lint:
159-
runs-on: ubuntu-latest
160-
steps:
161-
- uses: actions/checkout@v2
162-
- uses: actions/setup-node@v2
163-
- run: yarn
164-
- run: yarn lint
165-
166-
build:
167-
runs-on: ubuntu-latest
168-
strategy:
169-
matrix:
170-
node: ['12', '14', '16', '17']
171-
name: Node ${{ matrix.node }} Build
172-
steps:
173-
- uses: actions/checkout@v2
174-
- uses: actions/setup-node@v2
175-
with:
176-
node-version: ${{ matrix.node }}
177-
- run: yarn
178-
- run: yarn build
179-
```
124+
- **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.
180125

181-
## Learn More
126+
- **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.
182127

183-
To learn more about Next.js, take a look at the following resources:
128+
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.
184129

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

188-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
132+
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.

src/components/Home/AboutMaia.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const researchPapers = {
101101
{
102102
title:
103103
'Detecting Individual Decision‑Making Style: Exploring Behavioral Stylometry in Chess',
104-
link: 'https://www.cs.toronto.edu/~ashton/pubs/maia-personalized2021.pdf',
104+
link: 'https://www.cs.toronto.edu/~ashton/pubs/chessembed-neurips2021.pdf',
105105
description:
106106
'Shows that your chess style is as unique as a fingerprint, allowing the model to recognize you just by your move choices.',
107107
},

0 commit comments

Comments
 (0)