Getting Started

This guide covers installation, project structure, configuration, and basic usage of MindGames.


Prerequisites

Before you begin, ensure you have the following installed:

RequirementVersionCheck Command
Node.js18.0 or highernode --version
npm9.0 or highernpm --version
GitAny recent versiongit --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

FilePurpose
problem-generator.tsCore algorithm for generating math chains with operation mix logic
GameContext.tsxGlobal state: worksheet, answers, session, configuration
ChainDisplay.tsxVisual rendering of problem chains with input handling
OperationMixSlider.tsxUI for adjusting operation percentages
types/index.tsTypeScript interfaces for Problem, Chain, Worksheet, Config

Available Scripts

CommandDescription
npm run devStart development server with hot reload
npm run buildBuild for production
npm run startStart production server
npm run lintRun ESLint checks
npm testRun Jest test suite
npm run test:watchRun tests in watch mode
npm run test:coverageGenerate 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

  1. Configure Settings - Adjust operation mix, chain length, and time limit in the sidebar
  2. Generate Worksheet - Click "Generate" to create a new set of problem chains
  3. Start Session - Click "Start" to begin timed practice (optional)
  4. Solve Problems - Enter answers in the input fields
  5. Submit Answers - Press Tab or Enter to submit and move to the next problem
  6. Review Results - See your score and accuracy when complete

Keyboard Shortcuts

KeyAction
TabSubmit current answer and move to next
EnterSubmit current answer and move to next
0-9Enter 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

Next Steps