This project is based on the T3 stack (Next.js + tRPC + Prisma + Tailwind), with Better Auth and Discord OAuth.
- Node.js 20+
- pnpm (repo uses
pnpm@10.33.0) - PostgreSQL, either:
- via Docker (recommended), or
- local Postgres installed directly
pnpm iCopy .env.example to .env and fill in required values:
cp .env.example .envAt minimum, set:
DATABASE_URLBETTER_AUTH_SECRETBETTER_AUTH_URL(usuallyhttp://localhost:3000in local dev)BETTER_AUTH_DISCORD_CLIENT_IDBETTER_AUTH_DISCORD_CLIENT_SECRET
BETTER_AUTH_SECRET can be anything, but I would recommend generating something from
https://www.uuidgenerator.net/ or https://diceware.dmuth.org/
In the Discord Developer Portal:
- Create an application (name it whatever you want).
- Go into it -> OAuth2.
- In the OAuth2 section:
- Add redirect URI:
http://localhost:3000/api/auth/callback/discord - Copy client ID and client secret into
.env:BETTER_AUTH_DISCORD_CLIENT_IDBETTER_AUTH_DISCORD_CLIENT_SECRET- You will probably need to reset to generate a client secret
- Add redirect URI:
docker compose up -dpnpm db:pushThis creates/updates your database schema and runs Prisma client generation.
pnpm devApp runs at http://localhost:3000 (unless that port is in use).
# --- General Scripts ---
pnpm dev # start dev server
pnpm check # lint + typecheck
pnpm lint:fix # fix lint issues (that can be auto fixed)
pnpm format:write # format project (with prettier)
pnpm preview # production preview
pnpm build # create production build
# --- Database scripts ---
pnpm db:generate # Regenerates prisma types
pnpm db:migrate # Creates a new migration (based on the changes from the previous migration and current schema.prisma)
pnpm db:push # Pushes the current schema to the database + generate types
pnpm db:studio # Built-in DB inspector
pnpm db:reset # Drops the database, re-applies all migrations, and re-seeds (destructive)
pnpm db:deploy # Applies unapplied migrations (e.g. for prod or after pulling changes)src/app/layout.tsx: root app shell and global wrapperssrc/app/page.tsx: main home page routesrc/app/_components/: other custom components used in the appsrc/components/ui/: UI components created by shadcn
src/server/api/root.ts: tRPC router composition rootsrc/server/api/routers/: tRPC feature routerssrc/server/api/trpc.ts: tRPC context/procedures/middleware setupsrc/server/db.ts: Prisma client initializationsrc/server/better-auth/: Better Auth server/client configuration
src/app/api/trpc/[trpc]/route.ts: tRPC HTTP handlersrc/app/api/auth/[...all]/route.ts: Better Auth route handler
prisma/schema.prisma: data model and database schemaprisma/migrations/: migration history- For local setup or quick schema sync without a migration file, use
pnpm db:push - When you open a PR that has schema changes, run
pnpm db:migrate - In staging/production, apply migrations with
pnpm db:deploy
Shadcn UI components live in src/components/ui/ (for example button.tsx, card.tsx, input.tsx). Prefer composing new feature UI from these shared building blocks before introducing one-off component patterns.
layout.tsxfiles define persistent UI wrappers for routes.page.tsxfiles define route content.src/app/**/_components/contains components used specific to that route (e.g. the_componentsfolder in the rootappdirectory is for anywhere, but inside/testwould be components specific to routes under/test)src/components/uiis for core reusable components installed via shadcn/ui. (No manually written components should go here).
If you are not familiar with the different technologies used in this project, these docs are a good reference:
To learn more about the T3 stack: