A two-player concentration game built with Next.js and React. Enter player names, match card pairs, keep score, and see the winner at the end.
Next.js + React- handles routing, rendering, and page composition.Zustand- keeps game state in one place (turns, scores, selected cards, winner flow).Tailwind CSS- powers responsive layouts and styling.Contentful GraphQL API- provides card content and metadata.Jest + React Testing Library- covers unit/integration behavior.Playwright- covers real browser flows and viewport checks.
- The app fetches card content from Contentful.
- Card data is normalized into the local game shape.
- The store controls game rules (flip, match, score, turn switching, winner).
- UI components react to store state and render the game board, player cards, and winner overlay.
- Restart/exit actions reset game state and route the player accordingly.
app/ # routes, layout, page-level UI
components/ # reusable UI components
store/ # Zustand store and game actions
utils/ # CMS client + data helpers
e2e/ # Playwright tests
app/__tests__/ # page-level unit/integration tests
components/__tests__/ # component-level tests
store/__tests__/ # store behavior tests
nvm use
npm install
npm run devApp runs on http://localhost:3000 by default.
Production commands:
npm run build
npm run startCreate a .env.local file in the project root:
NEXT_PUBLIC_CONTENTFUL_SPACE_ID=your_space_id
NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN=your_contentful_access_tokenRun unit/integration tests:
npm testRun in watch mode:
npm run test:watchRun end-to-end tests:
npm run test:e2eInstall Playwright browser binaries (first run only):
npx playwright install chromiumRegression tests are included for home form validation, game flow, and responsive layout overflow checks.
If you see a hydration mismatch in development:
- Stop and restart the dev server.
- Hard refresh the browser.
- Clear
sessionStoragekeymemory-storein DevTools.
If Contentful cards do not load, verify .env.local values and restart the server.
If Playwright fails before tests start, run npx playwright install chromium.
