This project was created with Better-T-Stack, a modern TypeScript stack that combines React, React Router, Express, TRPC, and more.
- 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
First, install the dependencies:
pnpm installThis project uses PostgreSQL with Prisma.
-
Make sure you have a PostgreSQL database set up.
-
Update your
apps/server/.envfile with your PostgreSQL connection details. -
Apply the schema to your database:
pnpm run db:pushThen, run the development server:
pnpm run devOpen http://localhost:5173 in your browser to see the web application. The API is running at http://localhost:3000.
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.jsonandapps/web/components.json
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/uiImport shared components like this:
import { Button } from "@minesweeper/ui/components/button";If you want to add app-specific blocks instead of shared primitives, run the shadcn CLI from apps/web.
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
These steps cover the Player / SessionPlayer / ProofPlayer / leaderboard work and optional on-chain signing.
pnpm run check-types
pnpm run db:push # ensure schema matches DB- PostgreSQL —
DATABASE_URLinapps/server/.env. - Redis —
REDIS_URL(proof worker / BullMQ). Start Redis locally if you use the default URL. - Kurier —
KURIER_URLandKURIER_APImust be valid;startGamefetches a seed from Kurier. - CORS —
CORS_ORIGINshould match the web app (e.g.http://localhost:5173). - Optional:
getOnchainPayload— setSIGNING_PRIVATE_KEYinapps/server/.env(hex, with or without0x) to test server signing.
pnpm run devOpen http://localhost:5173, use an injected wallet (e.g. MetaMask).
| 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 | endGame → resolveSession → 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) |
pnpm run db:studioAfter 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.
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.
pnpm run dev: Start all applications in development modepnpm run build: Build all applicationspnpm run dev:web: Start only the web applicationpnpm run dev:server: Start only the serverpnpm run check-types: Check TypeScript types across all appspnpm run db:push: Push schema changes to databasepnpm run db:generate: Generate database client/typespnpm run db:migrate: Run database migrationspnpm run db:studio: Open database studio UI