Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Human Benchmark

A monorepo for benchmarking human cognitive abilities — featuring a mobile app, two backend server implementations, and an admin dashboard.

Project Structure

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

Tech Stack

  • 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

Features

Mobile App

  • 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

Admin Dashboard

  • 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

Server

  • Authentication: JWT-based auth with bcrypt password hashing (15h token expiry)
  • Data Persistence: PostgreSQL with users and scores tables
  • Caching: Redis with 5-min session TTL and 2-min leaderboard cache
  • API: 20 RESTful endpoints for auth, user management, scores, leaderboards, and admin

Getting Started

Prerequisites

  • Node.js 20+
  • PostgreSQL
  • Redis
  • Bun (for mobile app and NestJS server)

Infrastructure

docker-compose up        # Start Postgres + Redis

Server (Express — recommended)

cd server-express
npm install
npm run dev              # Development with --watch (http://localhost:3000)
npm start                # Production

Server (NestJS — original)

cd 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 tests

Both servers expose identical APIs on port 3000. Use one or the other.

Mobile App (React Native + Expo)

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 tests

Update LOCALHOST in mobile/constants/Config.ts to your machine's local IP when testing on a physical device.

Admin Dashboard (React + Vite)

cd admin-dashboard
npm install
npm run dev              # Vite dev server (http://localhost:5173)
npm run build            # Production build
npm run lint
npm test                 # Vitest

API Endpoints

All 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

Server Comparison

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

Environment Variables

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

Testing

  • NestJS server: cd server && bun test (Bun test runner, unit + e2e)
  • Mobile app: bun test from repo root (Bun + React Native Testing Library)
  • Admin dashboard: cd admin-dashboard && npm test (Vitest + React Testing Library)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages