Skip to main content

Architecture

Chrono One is a pnpm-workspaces monorepo with three applications and one shared contract package:

chrono-one/
apps/
shell-frontend/ # Vite + React 18 static host (Module Federation host)
shell-backend/ # NestJS REST API (auth, roles, permissions, audit)
docs/ # Docusaurus documentation site
packages/
shell-sdk/ # @chrono-one/shell-sdk — types + event bus only

The shell host (apps/shell-frontend)​

A React 18 static application compiled by Vite (build target esnext). As the Module Federation host, it owns:

  • the top-level React tree, router (React Router v6 data router) and layout;
  • Firebase Auth session initialisation (the only place Firebase is initialised);
  • the statically configured global navigation menu;
  • the <div> mounting points where remote microfrontends render;
  • the @chrono-one/shell-sdk contract handed to every mounted microfrontend.

The shell compiles to a static bundle (HTML + JS + CSS) served from object storage / CDN. It never renders HTML server-side.

The shell API (apps/shell-backend)​

A NestJS API on Node.js LTS that:

  1. verifies Firebase ID tokens (Firebase Admin SDK) on every route;
  2. manages global roles and product-permission grants (PostgreSQL 16, TypeORM);
  3. caches decoded tokens (60s) and role lookups (5min) in Redis 7;
  4. writes audit log entries asynchronously via BullMQ (backed by Redis 7);
  5. emits structured JSON logs (nestjs-pino), OpenTelemetry traces, and Prometheus metrics (@willsoto/nestjs-prometheus);
  6. emits openapi.json on startup, consumed by the frontend's @hey-api/openapi-ts client generator.

The shared SDK (packages/shell-sdk)​

A TypeScript-only package with no React, no Firebase SDK and no business logic. It defines ShellContext, NavItem, UserIdentity, GlobalRole, MicrofrontendMount, the ShellEventBus (typed Custom Events) and the PermissionChecker interface. See SDK contract.

Data flow​

Browser ──sign in──▶ Firebase Auth
│
└──Bearer ID token──▶ shell-backend (verify → roles/permissions)
│
└──ShellContext (identity, roles, navigate, events)──▶ mounted MFE

Observability​

  • Logs — structured JSON to stdout via nestjs-pino, each line carrying service: 'shell-backend', traceId and userId.
  • Traces — OpenTelemetry SDK (started only when OTEL_* env is present).
  • Metrics — Prometheus-compatible at GET /metrics.
  • Errors — Sentry (@sentry/nestjs + @sentry/react), initialised only when a DSN is configured.