KHEL Console is a high-performance, read-only dashboard designed to provide real-time visibility into the ZK Gaming Platform's database. Built with Next.js 15, Prisma, and Tailwind CSS, it visualizes game performance, player acquisition, and ZK-proof verification status.
- Framework: Next.js 16.2.4 (App Router)
- Database: PostgreSQL (Supabase)
- ORM: Prisma
- UI Components: Shadcn UI (Radix UI) + Lucide Icons
- Visuals: Tremor / Tailwind CSS
- Package Manager: pnpm
The project uses a consolidated flat structure to minimize monorepo overhead while maintaining clear separation of concerns:
dashboard-console/
├── prisma/ # Database schema and migrations
├── src/
│ ├── app/ # Next.js pages, layouts, and server actions
│ ├── components/ # UI layer (Dashboard, Tables, Filters)
│ ├── lib/ # Core logic (Prisma Singleton, Data Fetchers)
│ ├── types/ # TypeScript interfaces
│ └── utils/ # Formatting and helper functions
├── .env # Environment variables (DB credentials)
├── next.config.ts # Next.js configuration
└── package.json # Dependencies and scripts
To maximize performance and reduce TTI (Time To Interactive), this project utilizes Next.js Server Components. Data is fetched directly from the database using Prisma inside server components, bypassing the need for a separate REST or tRPC API layer for initial page loads.
To prevent connection exhaustion during development (HMR) and in serverless environments, we implement a Singleton pattern in src/lib/db.ts. This ensures a single connection pool is shared across the application.
- All-Time: Reads from the PlayerGameLeaderboard table (cached/indexed).
- Filtered (Today/Week/Custom): Aggregates real-time data from the SessionPlayer table based on specific time-bounds and gameId.
- Node.js 20+
- pnpm 9+
- A Supabase/PostgreSQL instance with the provided schema applied.
git clone <repository-url>
cd dashboard-console
pnpm install
Create a .env file in the root directory:
# Transaction Pooler (Used for runtime)
DATABASE_URL="postgres://postgres.[ID]:[PASS]@[aws-0.pooler.supabase.com:6543/postgres?pgbouncer=true](https://aws-0.pooler.supabase.com:6543/postgres?pgbouncer=true)"
# Direct Connection (Used for Prisma migrations)
DIRECT_URL="postgres://postgres.[ID]:[PASS]@db.[ID].supabase.co:5432/postgres"
Generate the Prisma client based on the local schema:
npx prisma generate
pnpm dev
The dashboard will be available at http://localhost:3000.
pnpm build
pnpm start
- Database: Ensure your Supabase instance is accessible and the connection pooler is enabled.
- Platform: Deploy to Vercel or any Next.js-compatible provider.
- Env Vars: Configure DATABASE_URL and DIRECT_URL in the deployment settings.
- Read-Only: It is highly recommended to use a database user with SELECT only permissions for the production DATABASE_URL.
| Board | Metric | Database Table |
|---|---|---|
| Main | Total Games | games |
| Main | Unique Players | proof_players (Distinct Address) |
| Sub | Session Volume | game_sessions (Status: FINISHED) |
| Sub | Active Players | proof_players (Filtered by range) |
| Sub | New Players | proof_players (First appearance in range) |
Note: Sub-board metrics utilize a "Two-Window Fetch" to calculate trend percentages (Current vs. Previous Period).