Open History to see the last commit
1# TanStack Start + DB Projects Example
2
3This is a TanStack Start project with tRPC API running on Start's server functions so it's easily deployable to many hosting platforms.
4
5All reads from the Postgres database are done via tRPC queries which populate TanStack DB query collections.
6
7We sync normalized data from tables into TanStack DB collections in the client & then write client-side queries for displaying data in components.
8
9## Initial setup
10
11Before you started, all necessary package install is done via `pnpm install` and a dev server is started with `pnpm dev`.
12
13## Linting and formatting
14
15Human devs have IDEs that autoformat code on every file save. After you edit files, you must do the equivalent by running `pnpm lint`.
16
17This command will also report linter errors that were not automatically fixable. Use your judgement as to which of the linter violations should be fixed.
18
19## Build/Test Commands
20
21- `pnpm run dev` - Start development server with Docker services
22- `pnpm run build` - Build for production
23- `pnpm run test` - Run all Vitest tests
24- `vitest run <test-file>` - Run single test file
25- `pnpm run start` - Start production server
26
27## Architecture
28
29- **Frontend**: TanStack Start (SSR framework for React and other frameworks) with file-based routing in `src/routes/`
30- **Database**: PostgreSQL with Drizzle ORM, schema in `src/db/schema.ts`
31- **Services**: Docker Compose setup (Postgres on 54321)
32- **Styling**: Tailwind CSS v4
33- **Authentication**: better-auth
34- **API**: tRPC for full e2e typesafety.
35
36## Code Style
37
38- **TypeScript**: Strict mode, ES2022 target, bundler module resolution
39- **Imports**: Use `@/*` path aliases for `src/` directory imports
40- **Components**: React 19 with JSX transform, functional components preferred
41- **Server DB**: Drizzle ORM with PostgreSQL dialect, schema-first approach
42- **Client DB**: TanStack DB with Query Collections
43- **Routing**: File-based with TanStack Router, use `Link` component for navigation
44- **Testing**: Vitest with @testing-library/react for component tests
45- **file names** should always use kebab-case