Skip to content

okane16/admin-dashboard

Repository files navigation

Next.js 15 Admin Dashboard with MooseStack Analytics
Real-time OLAP analytics powered by ClickHouse

Overview

An admin dashboard demonstrating embedded OLAP analytics using MooseStack within a Next.js application.

Tech Stack

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

📚 Documentation


Quick Start

Prerequisites

  • Node.js v20 (required for native module compatibility)
  • Docker (for ClickHouse via Moose)
  • pnpm (recommended)

1. Install Dependencies

pnpm install

2. Set Up Environment

Copy .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=true

3. Start Development Servers

Terminal 1 — Moose (manages ClickHouse):

pnpm dev:moose

Terminal 2 — Next.js:

pnpm dev

Open http://localhost:3000 to view the dashboard.


NPM Scripts

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

Project Structure

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)

Database Setup

PostgreSQL (Products)

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

ClickHouse (Analytics)

Moose automatically manages ClickHouse. The events table is created based on olap/models/events.ts.


Learn More

Releases

No releases published

Packages

No packages published