Bootstrap EDEN: Fase 0 (arquitetura) e Fase 1 (monorepo + infra)

Fase 0 — descoberta e arquitetura:
- Inventário do projeto, glossário de domínio, arquitetura com bounded
  contexts e topologia de containers, threat model inicial.
- 12 ADRs cobrindo modular monolith, topologia de containers (Postgres
  isolado + eden-core/parceiros/assinante em containers e portas
  distintos), auth/sessões, modelo de permissões, criptografia/segredos,
  contrato first-class, stock ledger, separação billing/finance/fiscal,
  outbox transacional, adapters SaperX e Focus NFe, e identidade
  compartilhada entre as 3 apps.
- 14 subagentes e 7 skills especializados por domínio em .claude/.
- Hooks de segurança (PreToolUse/PostToolUse/Stop) testados via pipe.

Fase 1 — plataforma (em andamento):
- Monorepo pnpm workspaces + Turborepo: apps/{api,worker,core-web,
  reseller-web,subscriber-web} + 9 packages compartilhados.
- apps/api: NestJS mínimo com /health/live e /health/ready (checando
  Postgres real via @eden/database).
- 3 frontends Vite + React + TypeScript + Tailwind, com o favicon
  oficial do EDEN.
- packages/database: migration baseline (node-pg-migrate) criando
  roles/role_permissions/applications/users/user_applications/sessions/
  audit_log — audit log append-only com hash-chain, testado ao vivo
  (UPDATE/DELETE bloqueados pelo trigger).
- compose.yaml implementando a topologia da ADR-0002, validada de ponta
  a ponta: os 6 containers sobem e ficam saudáveis com um único
  `docker compose up`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-03 08:01:14 -03:00
commit 44510bd019
149 changed files with 13006 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
# Shared Dockerfile for Node.js services (API, worker). Parametrized by
# APP_NAME (the workspace package's folder name under apps/) and PORT.
#
# Not yet size-optimized (copies the whole monorepo incl. devDependencies
# into the runtime stage) — deliberate simplification for Fase 1 bootstrap.
# Image-size hardening (pnpm deploy / multi-stage prune) is Fase 10 scope,
# see docs/implementation-plan.md.
FROM node:22-slim AS base
RUN corepack enable
WORKDIR /repo
FROM base AS build
COPY . .
RUN pnpm install --frozen-lockfile
ARG APP_NAME
RUN pnpm turbo run build --filter=@eden/${APP_NAME}...
FROM node:22-slim AS runtime
RUN corepack enable
WORKDIR /repo
COPY --from=build /repo /repo
ENV NODE_ENV=production
ARG APP_NAME
ENV EDEN_APP_NAME=${APP_NAME}
CMD ["sh", "-c", "pnpm --filter @eden/${EDEN_APP_NAME} start"]

View File

@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1
# Shared Dockerfile for the 3 EDEN frontends (core-web, reseller-web,
# subscriber-web). Parametrized by APP_NAME. Builds static assets with Vite,
# serves them with nginx (SPA fallback to index.html — see nginx-spa.conf).
FROM node:22-slim AS build
RUN corepack enable
WORKDIR /repo
COPY . .
RUN pnpm install --frozen-lockfile
ARG APP_NAME
RUN pnpm turbo run build --filter=@eden/${APP_NAME}...
FROM nginx:1.27-alpine AS runtime
ARG APP_NAME
COPY infra/docker/nginx-spa.conf /etc/nginx/conf.d/default.conf
COPY --from=build /repo/apps/${APP_NAME}/dist /usr/share/nginx/html
EXPOSE 80

View File

@@ -0,0 +1,15 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location = /healthz {
return 200 "ok\n";
add_header Content-Type text/plain;
}
}