Files
superlist/README.md
Jose Selesan fbd6942a6e docs: document the /api prefix and the Dokploy deployment
Update AGENTS.md and README.md for the same-origin `/api` routing and
the Docker Compose deployment: no hosted CI, how the images and nginx
proxy fit together, and the required env vars.
2026-10-16 15:44:31 -03:00

89 lines
3.7 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), and both services join the external `dokploy-network` so Traefik can reach them.
- One public domain: nginx serves the SPA and proxies `/api/*` → `http://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.