A modern web-based port of Brain Workshop, an N-Back training application for cognitive enhancement. Built with TypeScript and Solid.js, this version runs entirely in the browser.
- Dual N-Back: Match position and sound stimuli (default mode)
- Triple N-Back: Match position, color, and sound stimuli
- Position N-Back: Visual position matching only
- Audio N-Back: Audio sound matching only
- Combination N-Back Modes: Cross-modal matching with visual and auditory cues
- Arithmetic N-Back: Mathematical operations on n-back numbers
- Adaptive Level Adjustment: Automatically increases or decreases difficulty based on performance
- Multiple Profiles: Support for multiple user profiles with separate statistics
- Statistics Tracking: Comprehensive dashboard with progress graphs, session history, performance trends, and data export (CSV/TSV)
- Manual Mode: Customize session parameters for experimentation
- Jaeggi Mode: Emulates the protocol from the original research study
- Local Storage: All data saved in browser localStorage (no server required)
- Bun installed on your system
# Clone the repository
git clone <your-repo-url>
cd brainworkshop
# Install dependencies
bun install
# Start development server
bun run devThe application will be available at http://localhost:3000
# Build the application
bun run build
# Preview the production build
bun run preview- A: Position matches n-back position
- L: Sound matches n-back sound
- F: Color matches n-back color (Triple N-Back only)
- ESC: Pause/Quit current session
- Select a game mode from the title screen
- Press "Start Session" to begin
- Watch and listen to each stimulus
- Press the corresponding key when you recognize a match from N trials ago
- Complete the session to see your score and progress
- Score ≥ 80%: N-back level increases
- Score 50-79%: N-back level maintained
- Three scores < 50%: N-back level decreases
brainworkshop/
├── src/
│ ├── components/ # UI components
│ │ ├── TitleScreen.tsx
│ │ ├── GameBoard.tsx
│ │ ├── ResultScreen.tsx
│ │ ├── Settings.tsx
│ │ └── ProfileManager.tsx
│ ├── stores/ # Solid.js stores for state management
│ │ └── gameStore.ts
│ ├── types/ # TypeScript type definitions
│ │ └── index.ts
│ ├── utils/ # Utility functions
│ │ ├── gameEngine.ts # Core game logic and n-back algorithm
│ │ └── audioSystem.ts # Audio/speech synthesis
│ ├── App.tsx # Main application component
│ └── index.tsx # Application entry point
├── public/ # Static assets
├── index.html # HTML template
├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Project dependencies
- TypeScript: Type-safe development
- Solid.js: Reactive UI framework
- Vite: Fast development and build tool
- Web Speech API: Text-to-speech for audio cues
- Web Audio API: Sound effects and feedback
- LocalStorage API: Data persistence
The game generates random sequences with controlled match patterns:
- Standard mode: ~25% match probability per modality
- Jaeggi mode: Fixed 4 visual, 4 audio, 2 simultaneous matches
- Interference mode: Adds trick trials at n±1 positions
- Standard: Average of all modality scores
- Jaeggi: Minimum of position and sound scores
- Non-matches with no input are ignored (standard) or counted as correct (Jaeggi)
Tracks performance across sessions with a "three strikes" system for decreases:
- Maintains strike count between sessions
- Resets on level increase or decrease
- Considers configurable thresholds
Default configuration can be modified in src/types/index.ts:
export const DEFAULT_CONFIG: GameConfig = {
trialsPerSession: 20,
timePerTrial: 3000, // milliseconds
increaseThreshold: 80, // percentage
maintainThreshold: 50, // percentage
decreaseStrikes: 3,
// ... more options
};- Improve UI/UX of statistics dashboard
- Manual mode controls (adjust n-back, trials, speed)
- Variable N-Back mode
- Crab Back mode
- Multi-stimulus mode
- Responsive design for mobile devices
- Custom sound sets
- Background music between sessions
- Add the mode to the
GameModetype insrc/types/index.ts - Add configuration to
GAME_MODE_CONFIGS - Update
generateTrials()insrc/utils/gameEngine.tsto handle the new mode - Update
calculateSessionScore()if needed - Add UI controls in
GameBoard.tsxif new input methods are required
The application uses Solid.js stores for reactive state management:
gameStore: Current game state, session, trialsgameActions: Actions to modify the game state
All state changes trigger reactive updates in the UI.
The audio system uses the Web Speech API for text-to-speech:
- Speaks letters, numbers, NATO phonetic alphabet
- Plays beep sounds for feedback
- Can be enabled/disabled
This is a TypeScript + Solid.js port of the original Brain Workshop application.
The n-back task is based on research by Jaeggi et al. on working memory training.
MIT License - feel free to use and modify as needed.
Contributions are welcome! Please feel free to submit issues or pull requests.
- All data is stored in browser localStorage
- No server or backend required
- Works offline after initial load
- Compatible with modern browsers supporting Web Speech API