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.
- 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
User → Post (grouped by Topic) → Comment (self-referential tree via parentId)
Topics are identified by a unique slug used in URLs.
- Node.js 20+
- Docker (for local Postgres)
- Install dependencies:
npm install- Copy the example env file and fill in the values:
cp .env.example .envRequired variables:
DATABASE_URL=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URL=
BETTER_AUTH_SECRET=
- Start the database:
docker compose up -d- Apply migrations and generate the Prisma client:
npx prisma migrate dev
npx prisma generate- Start the dev server:
npm run devOpen http://localhost:3000.
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 databaseactions/ # 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