Skip to content

Repository files navigation

Discuss

A Reddit-style discussion app built with Next.js 16 App Router, React 19, Prisma 7, and Better Auth. Users can browse topics, create posts, and reply in threaded comment trees.

Stack

  • Framework: Next.js 16 (App Router)
  • UI: React 19, Tailwind CSS 4, shadcn (Base UI primitives)
  • Database: PostgreSQL via Prisma 7 (@prisma/adapter-pg)
  • Auth: Better Auth (GitHub OAuth)
  • Validation: Zod 4

Data Model

UserPost (grouped by Topic) → Comment (self-referential tree via parentId)

Topics are identified by a unique slug used in URLs.

Getting Started

Prerequisites

  • Node.js 20+
  • Docker (for local Postgres)

Setup

  1. Install dependencies:
npm install
  1. Copy the example env file and fill in the values:
cp .env.example .env

Required variables:

DATABASE_URL=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URL=
BETTER_AUTH_SECRET=
  1. Start the database:
docker compose up -d
  1. Apply migrations and generate the Prisma client:
npx prisma migrate dev
npx prisma generate
  1. Start the dev server:
npm run dev

Open http://localhost:3000.

Commands

npm run dev      # development server
npm run build    # production build
npm run lint     # ESLint

# Database
docker compose up -d                              # start Postgres
npx prisma migrate dev --name <name>              # create and apply a migration
npx prisma generate                               # regenerate client after schema changes
npx prisma studio                                 # GUI for the database

Project Structure

actions/          # Server Actions (re-exported from actions/index.ts)
app/              # Next.js App Router pages and API routes
components/
  auth/           # Auth-gating components (Authenticated, UnauthenticatedAction, etc.)
  layout/         # Shell, nav, sidebar
  posts/          # Post list, post form, post detail
  topics/         # Topic list, topic header
  ui/             # shadcn base components
lib/
  auth.ts         # Better Auth server config + getSession()
  auth-client.ts  # Better Auth client (useSession, signIn, signOut)
  generated/      # Prisma generated client
  prisma.ts       # Prisma singleton
  queries/        # Read-only DB queries
  utils/          # Shared utilities (timeout wrapper, cn, etc.)
path.ts           # Centralised route constants — always import from @/path
prisma/
  schema.prisma   # Database schema

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages