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-sdkcontract 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:
- verifies Firebase ID tokens (Firebase Admin SDK) on every route;
- manages global roles and product-permission grants (PostgreSQL 16, TypeORM);
- caches decoded tokens (60s) and role lookups (5min) in Redis 7;
- writes audit log entries asynchronously via BullMQ (backed by Redis 7);
- emits structured JSON logs (
nestjs-pino), OpenTelemetry traces, and Prometheus metrics (@willsoto/nestjs-prometheus); - emits
openapi.jsonon startup, consumed by the frontend's@hey-api/openapi-tsclient 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 carryingservice: 'shell-backend',traceIdanduserId. - 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.