Documentation Index Fetch the complete documentation index at: https://mintlify.com/amanvarshney01/create-better-t-stack/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Better-T-Stack generates a Turborepo-based monorepo structure that organizes your code into logical packages and applications. The structure adapts based on your stack choices, creating only what you need.
Base Structure
Every project starts with this foundation:
my-project/
├── apps/ # Applications (web, server, native)
├── packages/ # Shared packages
├── bts.jsonc # Project configuration
├── package.json # Root package.json with workspaces
├── turbo.json # Turborepo configuration
└── tsconfig.json # TypeScript base config
Root Configuration
The root package.json defines workspace structure:
// packages/template-generator/templates/base/package.json.hbs
{
"name" : "better-t-stack" ,
"private" : true ,
"type" : "module" ,
"workspaces" : [
"apps/*" ,
"packages/*"
],
"scripts" : {}
}
Application Layouts
The apps/ directory contains your runnable applications. Structure varies by stack:
Web Application
Next.js
TanStack Router
Nuxt
Svelte
apps/web/
├── src/
│ ├── app/ # App router pages
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── components/ # React components
│ │ └── ui/ # UI components (shadcn/ui)
│ ├── lib/ # Utilities
│ └── styles/ # Global styles
├── public/ # Static assets
├── next.config.ts # Next.js config
├── tailwind.config.ts # Tailwind config
├── tsconfig.json
└── package.json
apps/web/
├── src/
│ ├── routes/ # File-based routing
│ │ ├── __root.tsx
│ │ └── index.tsx
│ ├── components/ # React components
│ │ └── ui/
│ ├── lib/ # Utilities
│ ├── main.tsx # Entry point
│ └── index.css
├── public/
├── index.html
├── vite.config.ts # Vite config
├── tailwind.config.ts
├── tsconfig.json
└── package.json
apps/web/
├── app/
│ ├── pages/ # File-based routing
│ │ └── index.vue
│ ├── components/ # Auto-imported components
│ ├── layouts/
│ └── app.vue
├── server/ # Server routes (if backend: self)
│ ├── api/
│ └── trpc/
├── public/
├── nuxt.config.ts # Nuxt config
├── tailwind.config.ts
├── tsconfig.json
└── package.json
apps/web/
├── src/
│ ├── routes/ # SvelteKit routes
│ │ ├── +layout.svelte
│ │ └── +page.svelte
│ ├── lib/
│ │ └── components/
│ └── app.html
├── static/
├── svelte.config.js
├── vite.config.ts
├── tailwind.config.ts
├── tsconfig.json
└── package.json
Server Application
Generated when you select a backend framework (hono, express, fastify, elysia):
apps/server/
├── src/
│ ├── index.ts # Server entry point
│ ├── app.ts # Hono app setup
│ ├── routes/ # API routes
│ │ └── trpc.ts # tRPC handler (if api: trpc)
│ └── lib/ # Utilities
├── tsconfig.json
└── package.json
apps/server/
├── src/
│ ├── index.ts
│ ├── app.ts # Express app
│ ├── routes/
│ │ └── trpc.ts
│ └── middleware/
├── tsconfig.json
└── package.json
Native Application
Generated for React Native projects:
app/native/
├── app/ # Expo Router
│ ├── _layout.tsx
│ └── index.tsx
├── components/
│ └── ui/ # NativeWind/Unistyles components
├── assets/
├── app.json # Expo config
├── babel.config.js
├── metro.config.js
├── tailwind.config.js # If using NativeWind
├── tsconfig.json
└── package.json
Package Organization
The packages/ directory contains shared code:
Core Packages
Shared configuration files for TypeScript, ESLint, and Tailwind: packages/config/
├── eslint/
│ ├── base.js
│ ├── react.js
│ └── node.js
├── tailwind/
│ └── index.ts
├── typescript/
│ ├── base.json
│ ├── react.json
│ └── node.json
└── package.json
Database schema and client (generated when database is selected): Drizzle: packages/db/
├── src/
│ ├── index.ts # Exported client
│ ├── schema/ # Table schemas
│ │ └── user.ts
│ └── migrations/ # Migration files
├── drizzle.config.ts
├── tsconfig.json
└── package.json
Prisma: packages/db/
├── prisma/
│ ├── schema.prisma # Prisma schema
│ └── migrations/
├── src/
│ └── index.ts # Prisma client export
├── tsconfig.json
└── package.json
tRPC or oRPC API definitions (generated when api is selected): tRPC: packages/api/
├── src/
│ ├── index.ts # Export router
│ ├── trpc.ts # tRPC setup
│ ├── root.ts # Root router
│ └── routers/ # Feature routers
│ └── user.ts
├── tsconfig.json
└── package.json
oRPC: packages/api/
├── src/
│ ├── index.ts
│ ├── orpc.ts # oRPC setup
│ ├── root.ts
│ └── procedures/
│ └── user.ts
├── tsconfig.json
└── package.json
Authentication setup (generated when auth is selected): Better Auth: packages/auth/
├── src/
│ ├── index.ts # Auth client
│ ├── server.ts # Server-side auth
│ └── react.tsx # React hooks (for web)
├── tsconfig.json
└── package.json
Environment variable validation using @t3-oss/env-core: packages/env/
├── src/
│ ├── web.ts # Client env vars
│ └── server.ts # Server env vars
├── tsconfig.json
└── package.json
Infrastructure as code using Alchemy (when deployment is configured): packages/infra/
├── alchemy.run.ts # Deployment config
├── tsconfig.json
└── package.json
See packages/template-generator/templates/packages/infra/alchemy.run.ts.hbs for the full template.
Turborepo Configuration
The turbo.json file orchestrates builds across packages:
// turbo.json
{
"$schema" : "https://turbo.build/schema.json" ,
"ui" : "tui" ,
"tasks" : {
"transit" : {
"dependsOn" : [ "^transit" ]
},
"build" : {
"dependsOn" : [ "^build" ],
"inputs" : [ "$TURBO_DEFAULT$" ],
"outputs" : [ ".next/**" , "!.next/cache/**" , "dist/**" , "templates-binary/**" ]
},
"lint" : {
"dependsOn" : [ "transit" ]
},
"dev" : {
"cache" : false ,
"persistent" : true
}
}
}
The ^ prefix in dependsOn means “run this task in dependencies first”. For example, "^build" ensures shared packages build before apps.
Example Configurations
Full-Stack Monorepo (Next.js + Hono + tRPC)
my-project/
├── apps/
│ ├── web/ # Next.js app
│ └── server/ # Hono API server
├── packages/
│ ├── api/ # Shared tRPC routers
│ ├── auth/ # Better Auth setup
│ ├── db/ # Drizzle schema + client
│ ├── config/ # Shared configs
│ ├── env/ # Env validation
│ └── infra/ # Deployment config
├── bts.jsonc
├── package.json
├── turbo.json
└── tsconfig.json
Serverless (Convex Backend)
my-project/
├── apps/
│ └── web/ # TanStack Router SPA
├── packages/
│ ├── backend/
│ │ └── convex/ # Convex functions
│ ├── auth/ # Better Auth (Convex adapter)
│ └── config/
├── bts.jsonc
├── package.json
├── turbo.json
└── tsconfig.json
Mobile + Web (React Native + Next.js)
my-project/
├── apps/
│ ├── web/ # Next.js
│ ├── native/ # React Native (Expo)
│ └── server/ # Shared backend
├── packages/
│ ├── api/ # Shared tRPC routers
│ ├── auth/ # Auth for both platforms
│ ├── db/
│ ├── ui/ # Shared components (if applicable)
│ └── config/
├── bts.jsonc
├── package.json
├── turbo.json
└── tsconfig.json
Workspace Dependencies
Packages reference each other using workspace protocol:
// apps/web/package.json
{
"name" : "web" ,
"dependencies" : {
"@repo/api" : "workspace:*" ,
"@repo/auth" : "workspace:*" ,
"@repo/db" : "workspace:*"
}
}
The workspace:* protocol ensures you always use the local version during development. Package managers like pnpm and bun resolve these automatically.
Package Naming Convention
By default, packages use the @repo scope:
@repo/api
@repo/db
@repo/auth
@repo/config
@repo/env
Applications are not scoped:
Build Order
Turborepo automatically determines build order based on dependencies:
Shared configs build first
packages/config has no dependencies and builds first
Database layer builds next
packages/db depends on config
API layer builds after DB
packages/api needs the database schema types
Applications build last
apps/web and apps/server depend on API, auth, and DB packages
Development Workflow
Install dependencies
Build all packages
Run web + server in parallel
Build specific package
bts.jsonc Configuration that determines project structure
Templates How templates generate this structure