Getting Started
This guide covers installation, project structure, configuration, and basic usage of MindGames.
Prerequisites
Before you begin, ensure you have the following installed:
| Requirement | Version | Check Command |
|---|---|---|
| Node.js | 18.0 or higher | node --version |
| npm | 9.0 or higher | npm --version |
| Git | Any recent version | git --version |
Installation
1. Clone the Repository
git clone https://github.com/zeroleaf/MindGames.git cd MindGames
2. Install Dependencies
npm install
3. Start Development Server
npm run dev
The application will be available at http://localhost:3000.
Project Structure
MindGames/ āāā src/ ā āāā app/ ā ā āāā layout.tsx # Root layout with providers ā ā āāā page.tsx # Main game page ā ā āāā globals.css # Global styles + Tailwind ā āāā components/ ā ā āāā ChainDisplay.tsx # Problem chain visualization ā ā āāā OperationMixSlider.tsx # Mix configuration UI ā ā āāā Timer.tsx # Countdown timer component ā āāā contexts/ ā ā āāā GameContext.tsx # Game state management ā ā āāā ThemeContext.tsx # Dark/light theme toggle ā āāā lib/ ā ā āāā problem-generator.ts # Core generation algorithm ā āāā types/ ā āāā index.ts # TypeScript definitions āāā __tests__/ # Test files āāā jest.config.js # Jest configuration āāā tailwind.config.ts # Tailwind configuration āāā package.json
Key Files Explained
| File | Purpose |
|---|---|
| problem-generator.ts | Core algorithm for generating math chains with operation mix logic |
| GameContext.tsx | Global state: worksheet, answers, session, configuration |
| ChainDisplay.tsx | Visual rendering of problem chains with input handling |
| OperationMixSlider.tsx | UI for adjusting operation percentages |
| types/index.ts | TypeScript interfaces for Problem, Chain, Worksheet, Config |
Available Scripts
| Command | Description |
|---|---|
| npm run dev | Start development server with hot reload |
| npm run build | Build for production |
| npm run start | Start production server |
| npm run lint | Run ESLint checks |
| npm test | Run Jest test suite |
| npm run test:watch | Run tests in watch mode |
| npm run test:coverage | Generate coverage report |
Configuration
Game Configuration
Default game settings are defined in src/types/index.ts:
export const DEFAULT_CONFIG: GameConfig = {
maxResult: 100, // Maximum result value
chainLength: 6, // Problems per chain
chainCount: 5, // Number of chains per worksheet
timeLimit: 0, // Seconds (0 = no time limit)
operationMix: {
add: 40, // 40% addition
subtract: 40, // 40% subtraction
multiply: 10, // 10% multiplication
divide: 10, // 10% division
},
allowNegativeResults: false,
};Tailwind Theme Colors
Custom colors are configured in tailwind.config.ts:
colors: {
primary: {
// Indigo color scale
500: '#6366f1',
600: '#4f46e5',
// ...
},
accent: {
// Violet color scale
500: '#8b5cf6',
600: '#7c3aed',
// ...
},
}Usage Guide
Basic Workflow
- Configure Settings - Adjust operation mix, chain length, and time limit in the sidebar
- Generate Worksheet - Click "Generate" to create a new set of problem chains
- Start Session - Click "Start" to begin timed practice (optional)
- Solve Problems - Enter answers in the input fields
- Submit Answers - Press Tab or Enter to submit and move to the next problem
- Review Results - See your score and accuracy when complete
Keyboard Shortcuts
| Key | Action |
|---|---|
| Tab | Submit current answer and move to next |
| Enter | Submit current answer and move to next |
| 0-9 | Enter numeric answer |
| - | Enter negative sign (if enabled) |
Profile Modes
Select your profile mode from the settings:
- Kid Mode: Encouraging messages, confetti celebrations, fun language
- Adult Mode: Clean interface, focus on metrics and accuracy