Piecelet Connect is the online service that lets users connect their NeoDB accounts to Piecelet and manage authentication and sessions for the Piecelet apps.
This repository is a Turborepo monorepo (root package name: piecelet-online-services) and was previously named piecelet-account before being renamed to piecelet-connect.
apps/account– SvelteKit 2 + Svelte 5 frontend for Piecelet Connect, deployed to Cloudflare (Pages/Workers). Handles NeoDB sign‑in, a simple dashboard, and session management.apps/api– Cloudflare Workers API built with Hono, Better Auth, Drizzle ORM, Cloudflare D1, and KV. Provides auth routes, NeoDB OAuth, geolocation‑aware session handling, and CORS.packages/eslint-config– Shared ESLint configuration used across the monorepo.packages/typescript-config– Shared TypeScript configuration presets.packages/types– Shared TypeScript types.packages/utils– Shared utility functions for Workers and other packages.
- Node.js 18+
- pnpm
- Cloudflare account with Workers, D1, and KV enabled
- Wrangler CLI (
npm install -g wrangler)
Install dependencies at the repo root:
pnpm installThe API lives in apps/api and uses Cloudflare D1 and KV bindings configured via wrangler.jsonc.
-
Copy and customise the Wrangler config if needed:
cd apps/api cp wrangler-template.jsonc wrangler.jsonc # if you don't already have one # fill in ACCOUNT_DATABASE / ACCOUNT_KV details for your Cloudflare account
-
Start the API in development:
pnpm dev
This runs
wrangler devand serves the Better Auth + Hono API locally (seeapps/api/README.mdandapps/api/CORS.mdfor endpoints and CORS details).
The frontend lives in apps/account and is a SvelteKit app configured for Cloudflare Pages/Workers.
-
Create and configure environment variables:
cd apps/account cp .env.example .env # first time only
Set
VITE_API_URLin.env(or via Wrangler vars) to point at your API base URL, e.g. your localwrangler devURL or a deployedapps/apiWorker. -
Start the SvelteKit dev server:
pnpm dev
The UI will be available on the default Vite dev port (usually
http://localhost:5173) and will talk to the API configured viaVITE_API_URL.
From the repository root you can also use the Turborepo scripts:
# Run all dev targets (API + frontend) in watch mode
pnpm dev
# Build all apps and packages
pnpm build
# Lint and type-check
pnpm lint
pnpm type-checkYou can filter to a single app using Turbo filters if you prefer more granular control, for example:
pnpm dev --filter api
pnpm dev --filter accountBoth apps are configured for Cloudflare:
apps/api– deploy withpnpm deployfromapps/api(Cloudflare Workers, D1, KV).apps/account– deploy withpnpm deployfromapps/account(SvelteKit Cloudflare adapter).
For production, make sure:
- The API Worker has D1 and KV bindings configured (see
apps/api/wrangler-template.jsonc). - The account frontend has
VITE_API_URLpointing at the deployed API (seeapps/account/wrangler-template.jsonc). - Allowed origins are kept in sync with
apps/api/src/config/origins.tsand documented inapps/api/CORS.md.
apps/account/README.md– details of the Piecelet Connect SvelteKit frontend and auth flow.apps/api/README.md– details of the Better Auth + Hono API.apps/api/CORS.md– CORS and origin configuration used by the API.
If you are coming from the old piecelet-account repository, this is the same project, now renamed and organised as piecelet-connect with a clearer API/frontend split.