Project Structure
Understanding the structure of projects created by Better-T-Stack CLI
Better-T-Stack CLI scaffolds a monorepo with apps/* and packages/*. packages/config is always present; other packages and apps appear based on your choices (frontend, backend, API, database/ORM, auth, addons, runtime, deploy). This page mirrors what the CLI actually writes.
At the repository root you will see:
Notes:
bts.jsonc lets the CLI detect and enhance your project later; keep it if you plan to use create-better-t-stack add.turbo.json exists only if you picked the Turborepo addon.nx.json exists only if you picked the Nx addon.pnpm-workspace.yaml, bunfig.toml, and .npmrc are added based on the package manager you choose.packages/infra is created when a Cloudflare or Prisma deployment is enabled.Notes:
apps/desktop is created only with the Electrobun addon.apps/docs is created only with the Starlight addon.apps/fumadocs is created only with the Fumadocs addon.When --backend self is used, API routes live inside apps/web (no apps/server).
The structure varies by framework. Items marked "(auth)" or "(API)" appear only when those options are enabled.
Notes:
--backend self with Next.js, TanStack Start, Nuxt, SvelteKit, Solid, or Astro, API routes live inside apps/web (no apps/server).src/app/login/* and src/app/dashboard/* plus sign-in components.React web apps (tanstack-router, react-router, tanstack-start, and next) share shadcn/ui primitives through packages/ui.
packages/ui/src/styles/globals.csspackages/ui/src/components/*packages/ui/components.json and apps/web/components.jsonRun this from the project root to add more primitives to the shared UI package:
npx shadcn@latest add accordion dialog popover sheet table -c packages/uiImport shared components like this:
import { Button } from "@your-project/ui/components/button";If you want to add app-specific shadcn blocks instead of shared primitives, run the shadcn CLI from apps/web.
The server structure depends on your backend choice:
When runtime=workers, the server targets Cloudflare Workers. If you also choose Cloudflare deployment, you'll get packages/infra/alchemy.run.ts and related infra files.
API and auth scaffolding (conditional):
src/lib/trpc.ts, src/lib/context.tssrc/lib/orpc.ts, src/lib/context.tssrc/lib/auth.tsAdded only when you selected a database and ORM:
If you selected auth, additional files are added for your ORM:
src/db/schema/auth.tsprisma/schema/auth.prismasrc/db/models/auth.model.tsIf dbSetup=docker, a docker-compose.yml is added in apps/server/ for your database.
Created only when you include React Native (NativeWind or Unistyles):
If an API is selected, a client utility is added:
utils/trpc.tsutils/orpc.tsFumadocs is generated by create-fumadocs-app inside apps/fumadocs. The exact structure depends on the template you choose (MDX vs static).
Electrobun adds an apps/desktop workspace with its own package.json, electrobun.config.ts, and src/bun/index.ts. Electrobun 2 builds through Hutch: the first electrobun command downloads the toolchain and projects the SDK into apps/desktop/.hutch/devkit (gitignored), which the desktop tsconfig.json extends. The desktop shell reuses apps/web during development and bundles its built static output for release builds. Use a separate backend or no backend for desktop apps; --backend self emits server routes inside apps/web and cannot be bundled as static desktop assets.
{
"$schema": "https://r2.better-t-stack.dev/schema.json",
"version": "<cli-version>",
"createdAt": "<timestamp>",
"database": "<none|sqlite|postgres|mysql|mongodb>",
"orm": "<none|drizzle|prisma|mongoose>",
"backend": "<none|hono|express|fastify|elysia|convex|self>",
"runtime": "<bun|node|workers|none>",
"frontend": ["<tanstack-router|react-router|tanstack-start|next|nuxt|svelte|solid|astro|native-bare|native-uniwind|native-unistyles|none>"] ,
"addons": ["<pwa|tauri|electrobun|starlight|fumadocs|biome|lefthook|husky|mcp|turborepo|nx|vite-plus|ultracite|oxlint|opentui|wxt|skills|evlog|axiom|none>"] ,
"examples": ["<ai|todo|none>"] ,
"auth": <"better-auth"|"clerk"|"none">,
"packageManager": "<bun|pnpm|npm>",
"dbSetup": "<turso|neon|prisma-postgres|planetscale|mongodb-atlas|supabase|d1|docker|none>",
"api": "<none|trpc|orpc>",
"webDeploy": "<cloudflare|docker|vercel|none>",
"serverDeploy": "<cloudflare|docker|vercel|none>"
}Generated only if you chose the Turborepo addon.
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}Generated only if you chose the Nx addon.
Generated Vite frontends import defineConfig from vite-plus when you choose the Vite+ addon. A root vite.config.ts centralizes Vite+ lint, format, and staged-file checks, while root workspace scripts use vp run for task orchestration.
When Vite+ is selected without Husky or Lefthook, generated projects also include hooks:setup for optional native Vite+ Git hooks. Run it if you want vp config to install hooks into .vite-hooks and use vp staged from vite.config.ts; see the Vite+ commit hooks guide.
import { defineConfig } from "vite-plus";
export default defineConfig({
lint: {
options: {
typeAware: false,
typeCheck: false,
},
},
fmt: {
sortPackageJson: true,
},
staged: {
"*.{js,ts,jsx,tsx,vue,svelte,json,jsonc,css,md}": "vp check --fix",
},
});Better-T-Stack always creates packages/config. Other packages are added based on your selections:
packages/api: when --api is not none (non-Convex)packages/auth: when --auth is not none (non-Convex)packages/db: when both --database and --orm are selected (non-Convex)packages/backend: Convex backend onlypackages/infra: Alchemy infrastructure for Cloudflare and/or Prisma deploymentsEach application owns an .env.schema and a generated src/env.ts. Varlock generates the local ENV accessor during installation. Run the root env:generate script after changing a schema; do not edit generated types. This uses @generateTsTypes(path=./src/env.ts, exposeEnv=local), as recommended for separate application schemas in Varlock's monorepo guide.
Shared database and authentication packages accept configuration and database clients from their owning app. Database command-line tools import the app's database settings through packages/db/.env.schema.
Scripts are adjusted based on your package manager and whether the Turborepo, Nx, or Vite+ addon is selected.
With Turborepo:
{
"scripts": {
"dev": "turbo run dev",
"build": "turbo run build",
"check-types": "turbo run check-types",
"dev:web": "turbo run dev -F web",
"dev:server": "turbo run dev -F server",
"db:push": "turbo run db:push -F server",
"db:studio": "turbo run db:studio -F server"
}
}With Nx:
{
"scripts": {
"dev": "nx run-many -t dev",
"build": "nx run-many -t build",
"check-types": "nx run-many -t check-types",
"dev:web": "nx run-many -t dev --projects=web",
"dev:server": "nx run-many -t dev --projects=server"
}
}With Vite+:
{
"scripts": {
"dev": "vp run -r dev",
"build": "vp run -r build",
"check-types": "vp run -r check-types",
"check": "vp check && vp run -r check-types",
"lint": "vp lint",
"format": "vp fmt",
"staged": "vp staged",
"dev:web": "vp run --filter web dev",
"dev:server": "vp run --filter server dev"
}
}Without Turborepo, Nx, or Vite+ (example for Bun):
{
"scripts": {
"dev": "bun run --filter '*' dev",
"build": "bun run --filter '*' build",
"check-types": "bun run --filter '*' check-types",
"dev:web": "bun run --filter web dev",
"dev:server": "bun run --filter server dev"
}
}Notes:
dev:setup for initial backend configuration.db:*) are added only when a database + ORM are selected (Drizzle/Prisma). D1 + Cloudflare omits db:push and db:studio.apps/* and packages/* are created only when relevant (except packages/config, which is always present)apps/web, while shared shadcn/ui primitives live in packages/uisrc/utils/trpc.ts or src/utils/orpc.ts added to web/native when selectedbetter-auth: src/lib/auth.ts on server and login/dashboard pages on web appclerk: Clerk provider setup and authentication componentspnpm-workspace.yaml, bunfig.toml, or .npmrc added based on package manager and choicespackages/infra/alchemy.run.ts containing the selected application and database resourcesThis reflects the actual files written by the CLI so new projects match what's documented here.