Skip to content

Khel-fun/minesweeper

Repository files navigation

minesweeper

This project was created with Better-T-Stack, a modern TypeScript stack that combines React, React Router, Express, TRPC, and more.

Features

  • TypeScript - For type safety and improved developer experience
  • React Router - Declarative routing for React
  • TailwindCSS - Utility-first CSS for rapid UI development
  • Shared UI package - shadcn/ui primitives live in packages/ui
  • Express - Fast, unopinionated web framework
  • tRPC - End-to-end type-safe APIs
  • Node.js - Runtime environment
  • Prisma - TypeScript-first ORM
  • PostgreSQL - Database engine

Getting Started

First, install the dependencies:

pnpm install

Database Setup

This project uses PostgreSQL with Prisma.

  1. Make sure you have a PostgreSQL database set up.

  2. Update your apps/server/.env file with your PostgreSQL connection details.

  3. Apply the schema to your database:

pnpm run db:push

Then, run the development server:

pnpm run dev

Open http://localhost:5173 in your browser to see the web application. The API is running at http://localhost:3000.

UI Customization

React web apps in this stack share shadcn/ui primitives through packages/ui.

  • Change design tokens and global styles in packages/ui/src/styles/globals.css
  • Update shared primitives in packages/ui/src/components/*
  • Adjust shadcn aliases or style config in packages/ui/components.json and apps/web/components.json

Add more shared components

Run this from the project root to add more primitives to the shared UI package:

npx shadcn@latest add accordion dialog popover sheet table -c packages/ui

Import shared components like this:

import { Button } from "@minesweeper/ui/components/button";

Add app-specific blocks

If you want to add app-specific blocks instead of shared primitives, run the shadcn CLI from apps/web.

Project Structure

minesweeper/
├── apps/
│   ├── web/         # Frontend application (React + React Router)
│   └── server/      # Backend API (Express, TRPC)
├── packages/
│   ├── ui/          # Shared shadcn/ui components and styles
│   ├── api/         # API layer / business logic
│   └── db/          # Database schema & queries

Testing player DB writes, wallet, and proofs

These steps cover the Player / SessionPlayer / ProofPlayer / leaderboard work and optional on-chain signing.

Automated checks

pnpm run check-types
pnpm run db:push   # ensure schema matches DB

Local stack

  1. PostgreSQLDATABASE_URL in apps/server/.env.
  2. RedisREDIS_URL (proof worker / BullMQ). Start Redis locally if you use the default URL.
  3. KurierKURIER_URL and KURIER_API must be valid; startGame fetches a seed from Kurier.
  4. CORSCORS_ORIGIN should match the web app (e.g. http://localhost:5173).
  5. Optional: getOnchainPayload — set SIGNING_PRIVATE_KEY in apps/server/.env (hex, with or without 0x) to test server signing.
pnpm run dev

Open http://localhost:5173, use an injected wallet (e.g. MetaMask).

UI flow checklist

Step What to do What it exercises
1 Connect wallet Wallet address available for startGame
2 New Game (disabled until connected) player.upsert, SessionPlayer row, GameSession + MinesweeperSession, INIT_BOARD enqueue
3 Play safe cells revealCell, session IN_PROGRESS
4a Win (reveal 71 safe cells) then wait endGameresolveSession → aggregates + leaderboard + FINISHED; GAME_STATE enqueue; getGame XP
4b New Game, click a mine Mine path: resolveSession with XP 0; then endGame idempotent path (no double stats)
5 Dev only: after a finished game, use “Fetch on-chain payload (dev)” getOnchainPayload + SessionPlayer XP / winner + signature (requires SIGNING_PRIVATE_KEY)

Database inspection

pnpm run db:studio

After New Game, confirm players and session_players. After a finished round, check player_game_leaderboard and (once the proof worker has run) proofs / proof_players / verification_jobs.

Proof pipeline

If proof status stays on “Queued”, check server logs: Redis, Kurier, and local proof generation must succeed for the worker to create Proof, ProofPlayer, and VerificationJob rows.

Available Scripts

  • pnpm run dev: Start all applications in development mode
  • pnpm run build: Build all applications
  • pnpm run dev:web: Start only the web application
  • pnpm run dev:server: Start only the server
  • pnpm run check-types: Check TypeScript types across all apps
  • pnpm run db:push: Push schema changes to database
  • pnpm run db:generate: Generate database client/types
  • pnpm run db:migrate: Run database migrations
  • pnpm run db:studio: Open database studio UI

Releases

No releases published

Packages

 
 
 

Contributors