Shared Packages
The six shared packages — database schema, Hono API, Better Auth, SSE EventBus, UI design system, and i18n catalogues.
The monorepo contains six shared packages under packages/. Each is consumed by one or more of the five apps; none of them can depend on another app.
packages/database — Prisma schema & client
The data layer for the platform. Key characteristics:
- Multi-file Prisma schema — the schema is split into domain-bounded files under
packages/database/prisma/schema/(base, auth, enums, fleet, pricing, crm, quotes, orders, missions, billing, documents, audit, and Phase 2 additions). - Single Prisma client — all schema files are compiled into one generated client at
packages/database/src/index.ts. - Migrations — tracked in
packages/database/prisma/migrations/and applied viapnpm prisma migrate. - Multi-tenancy: virtually every VTC model has an
organizationIdfield — records are isolated per operator organization.
See also: Data Model overview for entity-by-entity documentation.
packages/api — Hono REST + SSE server
The HTTP API layer, consumed by all four business apps.
- Framework: Hono 4.12+ running on Node.js.
- Routes: organized under
packages/api/src/routes/vtc/by bounded context (pricing, fleet, crm, billing, missions, settings, integrations) plus Phase 2 routes (driver, tracking, agency, realtime). - OpenAPI:
hono-openapiis already wired — Story 85-5 completes coverage and emits a singleopenapi.jsonbuild artifact. - Auth middleware:
requireOperatorAuth,requireAgencyAuth,requireDriverAuth,validateTrackingToken(public). - SSE streams:
GET /api/v1/realtime/stream(operator) andGET /api/v1/driver/realtime/stream(driver) usepackages/realtime's EventBus.
See also: API Reference for the interactive endpoint explorer.
packages/auth — Better Auth sessions
Centralized authentication and authorization.
- Library: Better Auth.
- Identity types: operator users (multi-organization), agency portal users (
AgencyPortalUser), driver users. - Organization membership with role-based policies — operators can have multiple organization memberships.
- Session storage: server-side session tokens validated by API middleware.
- No
apps/docscoupling:apps/docsis public and does not importpackages/auth.
packages/realtime — EventBus & SSE streams
The real-time communication backbone.
- EventBus — an in-process publish/subscribe bus. Services in
packages/apipublish events (mission status changes, driver location updates); SSE handlers subscribe and forward events to connected clients. - SSE management — handles client connection lifecycle, heartbeats, and graceful disconnection.
- Driver location —
DriverLocationrecords are written on each driver position update (deduplicated at ≥ 20 m movement threshold) and broadcast via the EventBus. - Operator stream —
packages/api/src/routes/vtc/realtime.tspushes operator-relevant events (driver connected, mission accepted, location update). - Driver stream —
packages/api/src/routes/driver/realtime.tspushes driver-relevant events (mission broadcast, dispatch assignment).
packages/ui — Design system
The shared component library, based on shadcn/ui and Tailwind CSS.
- Provides reusable UI primitives (Button, Input, Dialog, Table, Badge, etc.) consumed by
apps/web,apps/agency, andapps/tracking. - Tailwind design tokens (colors, spacing, typography) are defined here and referenced by all consuming apps.
apps/docsmay reference design tokens for visual consistency only if that introduces no runtime coupling. In practice,apps/docsuses FumaDocs' own Tailwind configuration.
packages/i18n — Translation catalogues
Internationalization strings for the three Next.js business apps.
- Library: next-intl.
- Structure:
packages/i18n/translations/fr.json(primary) +en.json— JSON key-value catalogues. - Consumed by:
apps/web,apps/agency,apps/tracking. - Not used by
apps/docsorapps/driver.apps/docsuses FumaDocs' own routing-based i18n (physical per-locale MDX duplication);apps/driverhas its ownpublic/locales/resource files.
Note:
packages/i18n(next-intl JSON keys) andapps/docsi18n (FumaDocs MDX duplication) are completely separate i18n regimes and do not share infrastructure.
See also: Apps overview · Monorepo layout · Data Model