Jose Selesan dd9cf4ce43 feat(api): ship logs and HTTP metrics to OpenObserve
Replace Pino with LogTape and add OpenTelemetry metrics, both pushed to
OpenObserve over OTLP/HTTP when OPENOBSERVE_URL is set (console only otherwise).

- lib/logger.ts: console sink (pretty in dev, JSON lines in production) plus an
  OpenObserve sink via @logtape/otel. Each request runs inside
  withContext({ requestId }), so every record logged during it carries the id.
- The request middleware logs method, path, route pattern, status, durationMs,
  userId and user agent, at error/warning/info by status (/api/health at debug).
- lib/metrics.ts: http.server.request.duration (histogram, 5 ms to 10 s) and
  http.server.active_requests, attributed by method, route pattern and status,
  exported every METRICS_EXPORT_INTERVAL_MS (15 s).
- lib/openobserve.ts holds the shared endpoint and Basic auth settings; logs and
  metrics are flushed on SIGINT/SIGTERM.
- docs/openobserve-dashboard.md explains the dashboard and its queries, and
  docs/openobserve-dashboard.json can be imported as is.
- New variables are declared in turbo.json, the .env examples and the compose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 11:59:17 -03:00
2026-10-29 10:29:57 -03:00
2026-10-29 10:53:15 -03:00

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, LogTape 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 (workspace package manager and API runtime)
  • Postgres (only needed once you run migrations)

Getting started

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:

bun run dev            # turbo run dev → api on :4100, web on :7153

Or a single workspace: bun run dev --filter=@superlist/web.

Verification

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:

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.

Description
No description provided
Readme 1.5 MiB
Languages
TypeScript 98.4%
CSS 0.9%
Dockerfile 0.4%
HTML 0.3%