nginx proxied to `api:4100` over the shared `dokploy-network`, where the generic name `api` resolved to more than one container (a stale one from a previous deploy, or another project's service). nginx pinned those IPs at startup and round-robined across them, so requests hit a refused upstream and could reach a foreign container. - api now lives only on a stack-private `internal` network, aliased as `superlist-api`; only web joins `dokploy-network` for Traefik. - nginx proxies via a variable with Docker's resolver (127.0.0.11, valid=10s), so API redeploys never leave it on a stale IP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
4.0 KiB
Markdown
91 lines
4.0 KiB
Markdown
# Superlist
|
|
|
|
Monorepo with a Bun + Hono API and a React + Vite admin app.
|
|
|
|
| Workspace | What it is |
|
|
| ----------------- | ----------------------------------------------------------------------- |
|
|
| `apps/api` | Bun + Hono backend, Prisma (Postgres), Zod validation, Pino logging |
|
|
| `apps/web` | React + Vite + TypeScript frontend, shadcn/ui, TanStack Router + Query |
|
|
| `packages/shared` | `@superlist/shared` — Result pattern and RFC 9457 Problem Details types |
|
|
|
|
See `STACK.md` for the stack and `AGENTS.md` for the architecture conventions.
|
|
|
|
## Requirements
|
|
|
|
- [Bun](https://bun.sh) (workspace package manager and API runtime)
|
|
- Postgres (only needed once you run migrations)
|
|
|
|
## Getting started
|
|
|
|
```bash
|
|
bun install
|
|
|
|
# API
|
|
cp apps/api/.env.example apps/api/.env # then edit DATABASE_URL / BETTER_AUTH_SECRET
|
|
bun run db:generate # prisma generate
|
|
bun run db:migrate # requires a reachable Postgres
|
|
|
|
# Web
|
|
cp apps/web/.env.example apps/web/.env
|
|
```
|
|
|
|
Run everything in parallel:
|
|
|
|
```bash
|
|
bun run dev # turbo run dev → api on :4100, web on :7153
|
|
```
|
|
|
|
Or a single workspace: `bun run dev --filter=@superlist/web`.
|
|
|
|
## Verification
|
|
|
|
```bash
|
|
bun run build # turbo run build
|
|
bun run lint # biome check per package (lint + format + import order)
|
|
bun run typecheck # tsc
|
|
bun run test # bun test (api) / vitest (web, shared)
|
|
```
|
|
|
|
There is no hosted CI: run these locally (in that order) before pushing. `bun run lint:ci` runs the exact
|
|
same Biome check as `biome ci` would.
|
|
|
|
## Deployment (Dokploy)
|
|
|
|
`docker-compose.yml` at the repo root defines the two runtime services — `api` (Bun + nginx-free Hono server)
|
|
and `web` (static build behind nginx, proxying `/api/*` to the API). The database is external (provided by
|
|
Dokploy). Only `web` joins the external `dokploy-network` so Traefik can reach it; `web` and `api` talk over
|
|
the stack-private `internal` network, where the API answers to the unique alias `superlist-api` (a generic
|
|
name like `api` on the shared network could resolve to another project's container).
|
|
|
|
- One public domain: nginx serves the SPA and proxies `/api/*` → `http://superlist-api:4100`. All API routes are
|
|
mounted under `/api` for that reason — never mount a route at the root of the API.
|
|
- Env vars are interpolated from the Dokploy service env (`docker-compose.yml` marks `DATABASE_URL`,
|
|
`BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `CORS_ORIGIN` and `WEB_APP_URL` as required). See `.env.example`.
|
|
- Point the domain in Dokploy's **Domains** UI at the `web` service, container port `80` (the compose file
|
|
publishes no host ports on purpose).
|
|
- Migrations run automatically on API startup (`prisma migrate deploy` before `bun run start`).
|
|
|
|
Local smoke test of the same setup:
|
|
|
|
```bash
|
|
docker network create dokploy-network # once, mimics Dokploy's network
|
|
docker compose up --build
|
|
```
|
|
|
|
## Useful scripts
|
|
|
|
| Command | Effect |
|
|
| --------------------- | ------------------------------------------------------------------- |
|
|
| `bun run lint:fix` | Apply Biome fixes: lint, formatting and import sorting (whole repo) |
|
|
| `bun run lint:ci` | `biome ci` — whole-repo check, stricter than `lint` |
|
|
| `bun run format` | Format with Biome (`format:check` to verify only) |
|
|
| `bun run db:generate` | Regenerate the Prisma client into `apps/api/src/generated` |
|
|
| `bun run db:migrate` | Create and apply a migration (development) |
|
|
| `bun run db:studio` | Open Prisma Studio |
|
|
|
|
## Auth
|
|
|
|
BetterAuth is mounted by the API under `/api/auth/*` and uses the Prisma adapter. The web app talks to it
|
|
through `apps/web/src/lib/auth-client.ts`; the `_authenticated` route layout redirects to `/sign-in` when there
|
|
is no session.
|