Next.js 15 Admin Dashboard with MooseStack Analytics
Real-time OLAP analytics powered by ClickHouse
An admin dashboard demonstrating embedded OLAP analytics using MooseStack within a Next.js application.
| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript |
| Auth | NextAuth.js (GitHub OAuth) |
| CRUD Database | PostgreSQL (Neon) + Drizzle ORM |
| Analytics Database | ClickHouse via MooseStack |
| Styling | Tailwind CSS + Radix UI |
- ARCHITECTURE.md — Complete guide to the codebase structure
- olap/MOOSE_IN_NEXT_GUIDE.md — How to set up Moose in Next.js
- Node.js v20 (required for native module compatibility)
- Docker (for ClickHouse via Moose)
- pnpm (recommended)
pnpm installCopy .env.example to .env.local and configure:
# PostgreSQL (Neon)
POSTGRES_URL="postgresql://..."
# NextAuth
AUTH_SECRET="your-secret"
AUTH_GITHUB_ID="your-github-client-id"
AUTH_GITHUB_SECRET="your-github-client-secret"
# Moose
MOOSE_CLIENT_ONLY=trueTerminal 1 — Moose (manages ClickHouse):
pnpm dev:mooseTerminal 2 — Next.js:
pnpm devOpen http://localhost:3000 to view the dashboard.
| Script | Description |
|---|---|
pnpm dev |
Build OLAP models + start Next.js |
pnpm dev:next |
Start Next.js only (Turbopack) |
pnpm dev:moose |
Start Moose dev server |
pnpm build:olap |
Compile OLAP models with schema injection |
pnpm build |
Production build |
admin-dashboard/
├── app/ # Next.js pages & API routes
│ └── (dashboard)/ # Dashboard pages (/, /analytics, /products)
├── components/ # React components
│ ├── ui/ # Generic UI primitives
│ └── analytics/ # Analytics charts & tables
├── lib/ # PostgreSQL + auth utilities
├── olap/ # MooseStack OLAP layer ⭐
│ ├── models/ # ClickHouse table definitions
│ └── queries/ # Analytics query functions
└── dist/ # Compiled OLAP output (generated)
Create the products table:
CREATE TYPE status AS ENUM ('active', 'inactive', 'archived');
CREATE TABLE products (
id SERIAL PRIMARY KEY,
image_url TEXT NOT NULL,
name TEXT NOT NULL,
status status NOT NULL,
price NUMERIC(10, 2) NOT NULL,
stock INTEGER NOT NULL,
available_at TIMESTAMP NOT NULL
);Seed with: GET /api/seed
Moose automatically manages ClickHouse. The events table is created based on olap/models/events.ts.