A monorepo for benchmarking human cognitive abilities — featuring a mobile app, two backend server implementations, and an admin dashboard.
human-benchmark/
├── mobile/ # React Native + Expo mobile app
├── server/ # Backend API (NestJS + TypeORM)
├── server-express/ # Backend API (Express + raw pg) — lightweight rewrite
├── admin-dashboard/ # Admin dashboard (React + Vite)
└── docker-compose.yml # Postgres + Redis
- Mobile App: React Native, Expo, Expo Router, React Native Reanimated, NativeWind, TanStack Query (offline caching)
- Admin Dashboard: React, Vite, TailwindCSS, Chart.js
- Server (NestJS): NestJS, TypeORM, Passport JWT, Redis (cache-manager-redis-yet)
- Server (Express): Express, raw pg (node-postgres), Passport JWT, ioredis
- Database: PostgreSQL
- Caching: Redis
- Reaction Time Test: Measure your visual reflexes
- Memory Test: Test your ability to remember sequences
- Visual Memory Test: Remember patterns of tiles
- Typing Test: Check your typing speed and accuracy
- Chimp Test: Test your working memory with numbers
- User Accounts: Track your scores and progress
- Performance Analytics: Visual graphs to track progress over time
- Offline Support: Client-side caching for seamless experience
- User Management: Create, edit, delete user accounts and reset progress
- Statistics: Global game statistics, daily trends, and performance graphs
- Admin Controls: Toggle admin status, view per-game analytics
- Authentication: JWT-based auth with bcrypt password hashing (15h token expiry)
- Data Persistence: PostgreSQL with
usersandscorestables - Caching: Redis with 5-min session TTL and 2-min leaderboard cache
- API: 20 RESTful endpoints for auth, user management, scores, leaderboards, and admin
- Node.js 20+
- PostgreSQL
- Redis
- Bun (for mobile app and NestJS server)
docker-compose up # Start Postgres + Rediscd server-express
npm install
npm run dev # Development with --watch (http://localhost:3000)
npm start # Productioncd server
bun install
bun run start:dev # Development with watch (http://localhost:3000)
bun run build # Build for production
bun run start:prod # Run production build
bun run lint
bun run format
bun test # Unit + e2e testsBoth servers expose identical APIs on port 3000. Use one or the other.
bun install
npx expo start # Start Expo dev server
bun run android # Run on Android
bun run ios # Run on iOS simulator
bun test # Run testsUpdate
LOCALHOSTinmobile/constants/Config.tsto your machine's local IP when testing on a physical device.
cd admin-dashboard
npm install
npm run dev # Vite dev server (http://localhost:5173)
npm run build # Production build
npm run lint
npm test # VitestAll endpoints are prefixed with /api.
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /health |
— | Health check |
| POST | /login |
— | Log in, returns JWT |
| POST | /register |
— | Register new user, returns JWT |
| GET | /user/:username |
JWT | Get own profile |
| PUT | /user/:username |
JWT | Update email |
| PUT | /user/:username/password |
JWT | Change password |
| DELETE | /user/:username |
JWT | Delete account (requires password) |
| GET | /leaderboard/:gameId |
— | Top 10 leaderboard (cached 2 min) |
| GET | /scores/:username |
JWT | Last 50 scores |
| GET | /highscores/:username |
JWT | Best score per game |
| POST | /scores |
JWT | Submit a score |
| GET | /admin/stats |
Admin | Dashboard statistics |
| GET | /admin/users |
Admin | Paginated user list with search |
| GET | /admin/users/:id |
Admin | Single user details |
| POST | /admin/users |
Admin | Create user |
| PUT | /admin/users/:id |
Admin | Update user |
| DELETE | /admin/users/:id |
Admin | Delete user + scores |
| PUT | /admin/users/:id/admin |
Admin | Toggle admin status |
| DELETE | /admin/users/:id/progress |
Admin | Reset user scores |
NestJS (server/) |
Express (server-express/) |
|
|---|---|---|
| Framework | NestJS | Express |
| ORM / DB | TypeORM + raw SQL | raw pg (node-postgres) |
| Language | TypeScript | JavaScript |
| Build step | Required (nest build) |
None |
| Redis client | cache-manager-redis-yet | ioredis |
| Package manager | Bun | npm |
Configured in server/.env or server-express/.env:
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Server port |
JWT_SECRET |
— | Secret for signing JWTs |
DB_HOST |
localhost |
PostgreSQL host |
DB_PORT |
5432 |
PostgreSQL port |
DB_USERNAME |
— | PostgreSQL user |
DB_PASSWORD |
— | PostgreSQL password |
DB_NAME |
human_benchmark |
PostgreSQL database |
REDIS_HOST |
localhost |
Redis host |
REDIS_PORT |
6379 |
Redis port |
- NestJS server:
cd server && bun test(Bun test runner, unit + e2e) - Mobile app:
bun testfrom repo root (Bun + React Native Testing Library) - Admin dashboard:
cd admin-dashboard && npm test(Vitest + React Testing Library)