Skip to content

Libraries ​

@hobenakicoffee/libraries (packages/libraries) is the code the apps share: constants, formatting and link helpers, the database types, the profanity matcher, the Share kit's link rules, the Brand kit's files, and the SEO, Sentry and analytics setup. Each rule lives here once, so a payment status or a Share kit link reads the same in every app.

It ships TypeScript source, not a build: every entry in the exports map of packages/libraries/package.json points at a .ts file, and each consumer's bundler compiles it.

How it fits together ​

Who imports the libraries packageThe libraries package is imported as a workspace dependency by the web apps, the MCP Worker, the docs sites, the desktop app and three other shared packages. The Deno edge functions cannot import it, so two of its files are copied into the backend.sync:backend copiespackages/librariesapps/app, apps/admin,apps/marketing, apps/mcpapps/docs, apps/developer,apps/desktoppackages/post-body,packages/page-widget,packages/emailsapps/backend(types, scripts)Edge functionsapps/backend/supabase/functions/

An app declares "@hobenakicoffee/libraries": "workspace:*" in its package.json and Bun links it. apps/router does not use it.

The backend's edge functions run on Deno, which cannot import a workspace package. For the two files they need, bun run --cwd packages/libraries sync:backend writes a generated copy, marked do-not-edit, into the backend: src/sentry/privacy.ts and src/auth/first-party-token.ts. The backend's check target fails when a copy has drifted. packages/emails follows the same pattern (ADR 0003).

For example, Rahim sends Nusrat three coffees on her Demo profile at /@nusrat. The gift form's price comes from DEFAULT_COFFEE_PRICE (20 taka) in ./constants, so three coffees are ৳60. The gift action checks his message with checkModeration from ./utils. In the app, Nusrat's Earnings page types its Supabase calls with Database from ./types.

Key parts ​

PartWhere it livesPage
Constantspackages/libraries/src/constants/Constants
Utilitiespackages/libraries/src/utils/Utilities
Database typespackages/libraries/src/types/Types
Profanity matcher and Text rule check errorspackages/libraries/src/moderation/Moderation
URL state parserspackages/libraries/src/nuqs/URL state (nuqs)
React hookspackages/libraries/src/hooks/Hooks
Share kit rulespackages/libraries/src/share-kit/Share kit modules
Brand kit filespackages/libraries/src/brand-kit/, packages/libraries/assets/brand/Brand kit
Everything elseseo/, sentry/, analytics/, auth/, rewards/Single-purpose modules

Exports ​

Import from an entry point, never from a file path. The entry points, from the exports map:

Entry pointHolds
../constants again, and nothing else
./constantsPayment, service, shop, Team and Connected app constants
./utilsFormatting, links, sharing, phone and moderation helpers
./types, ./types/supabaseThe Database type; the second adds the table helpers
./moderation, ./text-rule-checkThe profanity matcher; the Text rule check refusal reader
./nuqs, ./hooksURL state parsers; useIsMobile
./share-kit-* (10 entry points)Share kit links, Page widget, Website button, Stream alerts and more
./brand-kit, ./brand-assets/*, ./brand-tokens.cssBrand kit list, brand files, brand CSS tokens
./seo, ./marketing-assetsBrand head tags and manifest; CDN URLs for the marketing bucket
./sentry-build, ./sentry-privacySentry build options; privacy and noise rules
./analytics/* (3 entry points)Google Tag Manager bootstrap and dataLayer
./first-party-token, ./client-ipWhich bearer tokens act as a person; the rate-limit IP key
./rewardsThe Reward earning rule and its hint
./desktop, ./locale, ./site-links, ./product-infoConstant modules with one job each
./content-blocks, ./content-feedback-storage, ./evaluate-formula, ./testing/membership-copy-claimsShared by apps/docs and apps/marketing only
ts
import { DEFAULT_COFFEE_PRICE } from "@hobenakicoffee/libraries/constants";
import { formatAmount } from "@hobenakicoffee/libraries/utils";
import type { Database } from "@hobenakicoffee/libraries/types";

Common tasks ​

  1. Run the package's tests: bunx nx run @hobenakicoffee/libraries:test. It worked when Bun's test runner exits 0.
  2. Typecheck and lint: bunx nx run @hobenakicoffee/libraries:typecheck and bunx nx run @hobenakicoffee/libraries:check. Both exit 0 when clean.
  3. Add an entry point: add the file under packages/libraries/src/, add a line to exports in packages/libraries/package.json, then import it from an app. It worked when that app's typecheck passes.
  4. After you edit packages/libraries/src/sentry/privacy.ts or packages/libraries/src/auth/first-party-token.ts, run bun run --cwd packages/libraries sync:backend. It worked when bunx nx run @hobenakicoffee/backend:check passes.

Gotchas ​

  • The root entry point (@hobenakicoffee/libraries) re-exports ./constants only. Import a utility from ./utils.
  • ./utils is a barrel: importing one function loads all of them, about 60 KB of browser modules. Marketing's landing scripts must not import it; see First paint.
  • cn (class merging) is not here; each app has its own.
  • Shared packages are dependency sinks: they never import an app. bun run boundaries checks it.

Other shared packages ​

packages/ holds five more shared packages, each with its own page: