Better-TS-Stack
Modules

Modules Overview

The modular architecture of better-ts-stack projects

How modules work

A generated project is built from modules. Each module adds its own template files, npm dependencies, scripts, and environment variables. Only the modules you select are added.


Available Modules


How Modules Are Selected

Your prompt answers decide which modules are added:

Prompt answerModule(s) activated
App type = backendExpress base module
App type = fullstack + framework = nextjsNext.js base module
App type = fullstack + framework = tanstackTanStack Start base module
Database = postgresql + ORM = prismaPrisma module for the chosen framework
Database = postgresql + ORM = drizzleDrizzle module for the chosen framework
Database = mongodb + ORM = mongooseMongoose module (Express, Next.js, TanStack)
Auth = yes (Express)JWT auth module
Auth = yes (Next.js / TanStack, database selected)Better Auth module
Docker = yesDocker module

Better Auth is only prompted for Next.js and TanStack Start projects when a database has been selected. If database type is none, auth is skipped automatically.


How Module Merging Works

Each module has a config.json. When you select several modules, the CLI merges them:

  • Dependencies: merged into a single package.json
  • Scripts: merged, so each module can add its own scripts
  • Environment variables: merged into .env.example / .env
  • Template files: each module's files are copied into the project

Example: Express + PostgreSQL + Prisma + JWT Auth

The final package.json will include:

{
  "dependencies": {
    "express": "^5.2.1",
    "cors": "^2.8.6",
    "cross-env": "^10.1.0",
    "helmet": "^8.3.0",
    "morgan": "^1.12.0",
    "dotenv": "^17.4.2",
    "@prisma/client": "^7.10.0",
    "bcrypt": "^6.0.0",
    "jsonwebtoken": "^9.0.3"
  },
  "scripts": {
    "dev": "cross-env NODE_ENV=development tsx watch src/index.ts",
    "build": "tsc",
    "start": "cross-env NODE_ENV=production node dist/index.js",
    "lint": "eslint src",
    "format": "prettier --write \"src/**/*.ts\"",
    "type:check": "tsc --noEmit",
    "prisma:generate": "prisma generate",
    "prisma:migrate": "prisma migrate dev",
    "prisma:studio": "prisma studio",
    "prebuild": "prisma generate"
  }
}

Module Availability Matrix

ModuleBackend (Express)Backend (NestJS)Full-stack (Next.js)Full-stack (TanStack)
Express baseAlways---
NestJS base-Always--
Next.js base--Always-
TanStack base---Always
PostgreSQL + PrismaYesYesYesYes
PostgreSQL + DrizzleYesYesYesYes
MongoDB + MongooseYesYesYesYes
JWT AuthYesYes--
Better Auth--Yes (requires DB)Yes (requires DB)
DockerYesYesYesYes

Extending After Generation

All generated code is plain TypeScript, so you can edit any file.

Adding to the backend

  • New routes -> src/routes/
  • New middleware -> src/middleware/
  • New controllers -> src/controllers/

Adding to the frontend

  • Next.js: new pages -> app/, API routes -> app/api/, components -> components/
  • TanStack Start: new routes -> src/routes/ (Vite regenerates src/routeTree.gen.ts during dev/build), server functions -> createServerFn, components -> src/components/

Adding to the database

  • Prisma: edit prisma/schema.prisma, then run npm run prisma:migrate
  • Drizzle: edit lib/schema.ts (Next.js) or src/lib/schema.ts (Express, TanStack Start), then run npm run db:generate && npm run db:migrate
  • Mongoose: add new model files to src/models/ (models/ in Next.js)

On this page