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:
29
apps/api/package.json
Normal file
29
apps/api/package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "@eden/api",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"start": "node dist/main.js",
|
||||
"dev": "tsx watch src/main.ts",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
"lint": "echo 'no linter configured yet'",
|
||||
"test": "echo 'no tests yet'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eden/database": "workspace:*",
|
||||
"@nestjs/common": "^10.4.15",
|
||||
"@nestjs/core": "^10.4.15",
|
||||
"@nestjs/platform-express": "^10.4.15",
|
||||
"@nestjs/terminus": "^10.2.3",
|
||||
"express": "^4.21.2",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.10.5",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
9
apps/api/src/app.module.ts
Normal file
9
apps/api/src/app.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { TerminusModule } from "@nestjs/terminus";
|
||||
import { HealthController } from "./health/health.controller";
|
||||
|
||||
@Module({
|
||||
imports: [TerminusModule],
|
||||
controllers: [HealthController],
|
||||
})
|
||||
export class AppModule {}
|
||||
36
apps/api/src/health/health.controller.ts
Normal file
36
apps/api/src/health/health.controller.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Controller, Get } from "@nestjs/common";
|
||||
import {
|
||||
HealthCheck,
|
||||
HealthCheckError,
|
||||
HealthCheckService,
|
||||
HealthIndicatorResult,
|
||||
} from "@nestjs/terminus";
|
||||
import { query } from "@eden/database";
|
||||
|
||||
@Controller("health")
|
||||
export class HealthController {
|
||||
constructor(private readonly health: HealthCheckService) {}
|
||||
|
||||
@Get("live")
|
||||
live() {
|
||||
// Liveness never depends on external services — only "is the process up".
|
||||
return { status: "ok" };
|
||||
}
|
||||
|
||||
@Get("ready")
|
||||
@HealthCheck()
|
||||
ready() {
|
||||
return this.health.check([(): Promise<HealthIndicatorResult> => this.checkPostgres()]);
|
||||
}
|
||||
|
||||
private async checkPostgres(): Promise<HealthIndicatorResult> {
|
||||
try {
|
||||
await query("SELECT 1");
|
||||
return { postgres: { status: "up" } };
|
||||
} catch (err) {
|
||||
throw new HealthCheckError("postgres check failed", {
|
||||
postgres: { status: "down", message: (err as Error).message },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
13
apps/api/src/main.ts
Normal file
13
apps/api/src/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import "reflect-metadata";
|
||||
import { NestFactory } from "@nestjs/core";
|
||||
import { AppModule } from "./app.module";
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const port = Number(process.env.EDEN_API_PORT ?? 8080);
|
||||
await app.listen(port, "0.0.0.0");
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[eden-api] listening on :${port}`);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
15
apps/api/tsconfig.json
Normal file
15
apps/api/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node",
|
||||
"target": "ES2022",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"strictPropertyInitialization": false
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user