Skip to content

Latest commit

 

History

History
100 lines (70 loc) · 4.62 KB

README.md

File metadata and controls

100 lines (70 loc) · 4.62 KB

preflight

A production-ready full-stack web application template built with TanStack Start, Better Auth, and Drizzle ORM. It runs on Bun-native APIs and drivers (bun.SQL, Bun.s3, Bun.redis).

Features

  • SSR & Routing: TanStack Start with file-based routes and type-safe navigation.
  • Server Engine: Nitro for high-performance server-side logic.
  • Authentication: Better Auth — email + password (with reset and verification emails), email OTP, passkeys, and optional Google OAuth. Rate limited (20 req/60 s). Session-guarded protected routes and redirect logic included.
  • Database: Drizzle ORM with Bun's native SQL driver (bun.SQL / drizzle-orm/bun-sql).
  • Account management: /settings route — profile, email verification, password change, linked providers, passkeys, and account deletion via Better Auth.
  • File uploads: An auth-guarded server function presigns PUT URLs with Bun's native S3 client (Bun.s3) for S3-compatible storage (SeaweedFS locally; swap to AWS S3, Cloudflare R2, or Supabase Storage with an env var change).
  • Email: Transactional email with Resend and React Email, or an SMTP relay via SMTP_URL for local and E2E runs. OTP, verification, and password-reset templates included.
  • Styling: Tailwind CSS v4
  • Theme System: Class-based light/dark switching via next-themes.
  • Observability: LogTape structured logging with a Sentry sink. PII off by default, conservative sample rate. Debug routes gated to development.
  • Architecture: Feature-based structure (src/features) with server-function data boundaries.
  • DX:
    • Oxlint & Oxfmt for fast linting and formatting.
    • Playwright for E2E tests in tests/e2e/.
    • Vitest for unit tests in tests/unit/ and integration tests in tests/integration/.
    • Lefthook for git hooks.
    • CI on GitHub Actions: lint, typecheck, format, migration drift, unit tests, integration tests, E2E, security checks, and a production build.

Getting Started

Prerequisites

  • Bun v1.4.4 or later
  • Docker for local services (Postgres, SeaweedFS, Redis, Mailpit) and for the Testcontainers the integration and E2E suites start

Setup

  1. Install dependencies

    bun install
  2. Configure environment

    cp .env.example .env

    Open .env and fill in the required values (see the Environment Variables Reference in the Development Guide).

  3. Start local services

    docker compose up -d postgres redis seaweedfs mailpit

    This starts the infrastructure only; the app container binds port 3000 and would clash with the dev server. Mailpit captures the password-reset email for the E2E suite.

  4. Prepare the database

    Apply migrations:

    bun run db:migrate

    (Or push schema directly during local prototyping: bun run db:push)

    Optionally seed with initial data:

    bun run db:seed
  5. Start the dev server

    bun run dev

    Open http://localhost:3000. Sign up, sign in, and land on the protected dashboard.

For complete workflow instructions, script catalogs, testing guidelines, and environment configuration, see the Development Guide.

Deployment

The template ships a Dockerfile and docker-compose.yaml for containerised deployment.

docker build -t preflight .
docker run -p 3000:3000 preflight

Documentation

  • Development — local setup, scripts catalog, database management, testing, and tooling.
  • Adding a Feature — the schema-to-tests sequence for a new feature.
  • Architecture — project structure, data flow, auth, and observability.
  • Design System — aesthetic and design tokens.
  • Agents Guide — rules for coding agents working in this repo.
  • Deployment — hosting options and platform-specific configuration.
  • Changelog — version history.
  • Contributing — branch, commit, and test conventions.