CodeGarden is a full-stack code snippet manager built with TanStack Start, PostgreSQL, Drizzle ORM, Better Auth, Shiki, and CodeMirror.
- TanStack Start with React 19
- PostgreSQL via
postgres+ Drizzle ORM - Better Auth with the Drizzle Postgres adapter
- Server-side syntax highlighting with Shiki
- Client-side editing with lazy-loaded CodeMirror 6
- Tailwind CSS v4 + shadcn/ui
- Install dependencies:
bun install- Create
.env.localwith:
DATABASE_URL=postgres://...
BETTER_AUTH_SECRET=generate-a-long-random-secret
BETTER_AUTH_URL=http://localhost:3000
VITE_SENTRY_DSN=Generate a secret with:
bunx --bun @better-auth/cli secret-
Apply the Drizzle SQL migrations in
drizzle/to your Postgres database. -
Start the app:
bun --bun run devThe app runs on http://localhost:3000.
bun --bun run devstarts the local dev server with dotenv + Sentry instrumentation.bun --bun run buildbuilds the TanStack Start app and copies the server instrumentation file intodist/server.bun --bun run startruns the production server fromdist/server/server.js.bun --bun run testruns Vitest in non-failing no-tests mode.bunx tsc --noEmitruns a full TypeScript check.
drizzle/0001_extensions.sqlenablespg_trgm, recreatessearch_vectoras a generated stored column, and adds the required GIN indexes.drizzle/0002_better_auth.sqladds the Better Auth persistence tables:session,account, andverification.- Search uses weighted full-text ranking over
title,description, andkeywords, plus trigram and substring matching overcode_body.
- Snippet detail pages are public.
- Creating, editing, and deleting snippets requires authentication.
- Only the author of a snippet can edit or delete it.
- Search is URL-driven from the global topbar search field.