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
Backend
Express.js server with TypeScript, routing, and middleware - the foundation of every backend app type project
Frontend
Next.js 16 or TanStack Start with React 19 and Tailwind CSS v4 - selected via the full-stack framework prompt
Database
PostgreSQL (Prisma or Drizzle) or MongoDB (Mongoose) - selected in a two-step prompt
Auth
JWT + bcrypt for Express, Better Auth for Next.js and TanStack Start (requires a database)
Docker
Multi-stage Dockerfile and docker-compose.yml - optional for any app type
How Modules Are Selected
The CLI prompts govern which modules are included:
| Prompt answer | Module(s) activated |
|---|---|
App type = backend | Express base module |
App type = fullstack + framework = nextjs | Next.js base module |
App type = fullstack + framework = tanstack | TanStack Start base module |
Database = postgresql + ORM = prisma | Prisma module for the chosen framework |
Database = postgresql + ORM = drizzle | Drizzle module for the chosen framework |
Database = mongodb + ORM = mongoose | Mongoose module (Express, Next.js, TanStack) |
Auth = yes (Express) | JWT auth module |
Auth = yes (Next.js / TanStack, database selected) | Better Auth module |
Docker = yes | Docker 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
| Module | Backend (Express) | Full-stack (Next.js) | Full-stack (TanStack) |
|---|---|---|---|
| Express base | Always | - | - |
| Next.js base | - | Always | - |
| TanStack base | - | - | Always |
| PostgreSQL + Prisma | Yes | Yes | Yes |
| PostgreSQL + Drizzle | Yes | Yes | Yes |
| MongoDB + Mongoose | Yes | Yes | Yes |
| JWT Auth | Yes | - | - |
| Better Auth | - | Yes (requires DB) | Yes (requires DB) |
| Docker | Yes | Yes | Yes |
| NestJS | Coming 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 regeneratessrc/routeTree.gen.tsduring dev/build), server functions ->createServerFn, components ->src/components/
Adding to the database
- Prisma: edit
prisma/schema.prisma, then runnpm run prisma:migrate - Drizzle: edit
lib/schema.ts, then runnpm run db:generate && npm run db:migrate - Mongoose: add new model files to
src/models/