Files
electro4ort/README.md
T
olehhapuk 98b2e0ce4b
CI / Lint, types, build, tests (push) Canceled after 0s
CI / Docker images build (push) Canceled after 0s
update
2026-12-03 10:53:09 +02:00

3.8 KiB

electro4ort

A chat app: friends and direct messages, group chats, realms with cauldrons (communities and the rooms in them), files, reactions, and voice and video calls.

Where What
apps/api The API: NestJS, PostgreSQL through Drizzle, Better Auth, Socket.IO, LiveKit
apps/web The web app: TanStack Start, TanStack Query, React 19
packages/contracts Request and response shapes shared by both, as Zod schemas
packages/ui The components (shadcn/ui on Base UI)

Development

Needs Node 24, pnpm and Docker.

docker compose -f docker-compose.local.yml up -d   # PostgreSQL, Redis, LiveKit
cp apps/api/.env.example apps/api/.env             # then set BETTER_AUTH_SECRET
cp apps/web/.env.example apps/web/.env
pnpm install
pnpm --filter api db:migrate
pnpm dev                                           # web on :3000, API on :3001

After changing the tables in apps/api/src/db/schema, run pnpm db:generate --name <what-changed> and pnpm db:migrate in apps/api.

To add a shadcn/ui component: pnpm dlx shadcn@latest add button -c apps/web. It lands in packages/ui/src/components and is imported as @repo/ui/components/button.

Checks

pnpm turbo run lint typecheck build   # everything
pnpm turbo run test                   # unit tests
pnpm --filter api test:e2e            # API end to end; needs the containers above

.github/workflows/ci.yml runs the same on every push and pull request, and builds both Docker images.

Deploying

docker-compose.yml runs the whole app on one server: Caddy in front (HTTPS with certificates it fetches itself), the web app, the API, PostgreSQL, Redis and LiveKit.

  1. Point three DNS names at the server: example.com, api.example.com and livekit.example.com (yours in place of example.com). The web app and the API must share a parent domain like this: the session cookie is only sent between pages of one site.

  2. Open the firewall for 80 and 443 (TCP), 443 (UDP), and for calls 7881 (TCP) and 7882 (UDP).

  3. On the server, in a checkout of this repository:

    cp .env.example .env   # fill in the domain and the secrets; the file says how to make each
    docker compose up -d --build
    

To update: git pull, then docker compose up -d --build again. Migrations are applied by the migrate service before the new API starts.

What to know before relying on it:

  • Back up the postgres-data volume (docker compose exec postgres pg_dump -U electro4ort electro4ort) and, unless files go to S3, the files volume.
  • Files are kept on the server's disk by default. Set the S3_* variables in .env to keep them in a bucket instead, which is also what running more than one API instance needs.
  • Calls work for people whose network allows UDP or TCP to the two ports above. Networks that only let HTTPS out need a TURN server, which LiveKit can run itself: see its deployment guide.
  • Accounts need no email confirmation and there is no password reset yet: both need an email provider.
  • The API trusts one proxy in front of it (TRUST_PROXY=1, Caddy). Behind another load balancer as well, raise it, or rate limits count the balancer instead of the caller.

To run the images elsewhere (Kubernetes, a platform): docker build --target api . and docker build --target web --build-arg VITE_API_URL=https://api.example.com .; the API's settings are listed in apps/api/.env.example, and its migrations run with node dist/db/migrate.js in the same image.