Better-TS-Stack
Modules

Modules Overview

The modular architecture of better-ts-stack projects

Modular by Design

better-ts-stack composes projects from independent modules. Each module contributes its own template files, npm dependencies, scripts, and environment variables. Only the modules you select are included.


Available Modules


How Modules Are Selected

The CLI prompts govern which modules are included:

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

When you select multiple modules, the CLI merges their config.json configurations:

  • Dependencies: merged into a single package.json
  • Scripts: merged - later modules can add new 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",
    "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": "tsx watch src/index.ts",
    "build": "tsc",
    "start": "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)Full-stack (Next.js)Full-stack (TanStack)
Express baseAlways--
Next.js base-Always-
TanStack base--Always
PostgreSQL + PrismaYesYesYes
PostgreSQL + DrizzleYesYesYes
MongoDB + MongooseYesYesYes
JWT AuthYes--
Better Auth-Yes (requires DB)Yes (requires DB)
DockerYesYesYes
NestJSComing soon--

Extending After Generation

All generated code is plain TypeScript - edit any file freely.

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, then run npm run db:generate && npm run db:migrate
  • Mongoose: add new model files to src/models/

On this page