SilkChat is a TanStack Start and Convex chat application with Better Auth, hosted and BYOK models, resumable streaming, file imports and uploads, web search, personas, usage metering, and fal-backed image generation.
src/: TanStack Start application, server routes, UI, hooks, and browser stateconvex/: Better Auth, chat runtime, models, tools, billing, storage, and scheduled jobstests/: Vitest coverage grouped by backend, routes, components, hooks, imports, and librariesscripts/: local-development, environment-sync, and deployment helpersenvs/: ignored, target-specific environment files used by the scripts
Requirements: Bun (the version is pinned in package.json) and access to a Convex deployment.
- Install dependencies:
bun install-
Copy
.env.exampletoenvs/.env.localand fill in the app values you need. -
Create
envs/.env.cloud-dev:
CLOUD_DEV_CONVEX_DEPLOYMENT="dev:your-cloud-dev-deployment"
CLOUD_DEV_CONVEX_URL="https://your-deployment.convex.cloud"
CLOUD_DEV_CONVEX_API_URL="https://your-deployment.convex.site"
CLOUD_DEV_CONVEX_SITE_URL="https://your-deployment.convex.site"
VITE_R2_PUBLIC_BASE_URL="https://your-public-r2-host"- Start the app:
bun run devThis starts Vite at http://localhost:3000 and the local Sharp image optimizer. Its
terminal controls can sync Convex, restart individual services, clear the optimizer
cache, or restart the whole local stack without stopping bun run dev. When
DEV_PUBLIC_URL and CLOUDFLARE_TUNNEL_TOKEN are configured, it also starts the
named Cloudflare Tunnel for HTTPS and mobile-device access. It does not push local
Convex changes automatically; press b (Sync Backend) in the runner or use this command when backend
or schema changes need to reach cloud dev:
bun run cloud:dev:pushSee Setup Guide for environment and deployment details.
bun run dev # Vite + local image optimizer against cloud dev
bun run cloud:dev:push # push local Convex code to cloud dev
bun run check-types # TypeScript validation
bun run test # one-shot Vitest suite
bun run build # production frontend build
bun run lint # Biome check with writes
bun run staging:deploy # verify, deploy Convex staging, push staging branch
bun run prod:deploy # verify, deploy Convex production, push main branchDo not use bun test; the canonical test command is bun run test.
The synchronized deploy commands require a clean worktree and the matching branch (staging or main). Use staging:push and prod:push only for an explicitly intended Convex-only or manual deployment operation.
The app/Vercel runtime needs browser and server-proxy values such as:
VITE_CONVEX_URLVITE_CONVEX_API_URLVITE_CONVEX_SITE_URLVITE_ENABLED_INTERNAL_PROVIDERSVITE_ENABLE_VOICE_INPUT- analytics and checkout URL variables
- outbound email variables
Convex owns backend secrets and runtime configuration such as:
BETTER_AUTH_SECRET,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET, and optionalJWKSVITE_BETTER_AUTH_URLandVITE_CONVEX_SITE_URLused by Convex-hosted Better AuthOPENROUTER_API_KEYandENCRYPTION_KEY- speech-to-text, search, fal, storage, billing, and usage-metering variables
IDENTITY_FINGERPRINT_PEPPERfor account-deletion tombstones
envs/.env.convex is the shared source for Convex environment values. Target overrides live in:
envs/.env.convex.cloud-devenvs/.env.convex.stagingenvs/.env.convex.production
Push them with the matching env:convex:*:push script. Environment files contain secrets and must not be committed.
Hosted built-in chat models use OpenRouter. Convex must have OPENROUTER_API_KEY, and the browser must expose the desired groups through VITE_ENABLED_INTERNAL_PROVIDERS.
User BYOK chat is OpenRouter-based. Image generation uses native fal queue/webhook APIs, while speech-to-text can use Google or Groq. Provider identity metadata supports grouping and stored preferences independently of runtime routing.
- Setup and deployment
- OAuth and auth
- Models and providers
- BYOK
- Image generation
- Composer intent guide
- Voice input
- Account deletion
- Testing overview and test-writing guide
- Dev tools
- Font styling
- Convex runtime notes
src/lib/auth-server.ts: TanStack Start bridge to Convex-hosted Better Authsrc/routes/api/auth/$.ts: stable/api/auth/*proxy and GET coalescingconvex/auth.ts: Better Auth configuration and account-restoration triggersconvex/auth.config.ts: Convex JWT validation configurationconvex/lib/models.ts: built-in model registryconvex/lib/models/fal/: fal image-model descriptorsconvex/lib/provider_factory.ts: OpenRouter and custom OpenAI-compatible providersconvex/chat_http/get_model.ts: selected-model resolutionconvex/chat_http/post.route.ts: chat validation, tools, metering, and streamingconvex/image_generation_jobs.ts: durable image-generation job state and recoveryconvex/account_deletion.ts: resumable account-deletion workflow