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
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
| Part | Where it lives | Page |
|---|---|---|
| Constants | packages/libraries/src/constants/ | Constants |
| Utilities | packages/libraries/src/utils/ | Utilities |
| Database types | packages/libraries/src/types/ | Types |
| Profanity matcher and Text rule check errors | packages/libraries/src/moderation/ | Moderation |
| URL state parsers | packages/libraries/src/nuqs/ | URL state (nuqs) |
| React hooks | packages/libraries/src/hooks/ | Hooks |
| Share kit rules | packages/libraries/src/share-kit/ | Share kit modules |
| Brand kit files | packages/libraries/src/brand-kit/, packages/libraries/assets/brand/ | Brand kit |
| Everything else | seo/, 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 point | Holds |
|---|---|
. | ./constants again, and nothing else |
./constants | Payment, service, shop, Team and Connected app constants |
./utils | Formatting, links, sharing, phone and moderation helpers |
./types, ./types/supabase | The Database type; the second adds the table helpers |
./moderation, ./text-rule-check | The profanity matcher; the Text rule check refusal reader |
./nuqs, ./hooks | URL 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.css | Brand kit list, brand files, brand CSS tokens |
./seo, ./marketing-assets | Brand head tags and manifest; CDN URLs for the marketing bucket |
./sentry-build, ./sentry-privacy | Sentry build options; privacy and noise rules |
./analytics/* (3 entry points) | Google Tag Manager bootstrap and dataLayer |
./first-party-token, ./client-ip | Which bearer tokens act as a person; the rate-limit IP key |
./rewards | The Reward earning rule and its hint |
./desktop, ./locale, ./site-links, ./product-info | Constant modules with one job each |
./content-blocks, ./content-feedback-storage, ./evaluate-formula, ./testing/membership-copy-claims | Shared by apps/docs and apps/marketing only |
import { DEFAULT_COFFEE_PRICE } from "@hobenakicoffee/libraries/constants";
import { formatAmount } from "@hobenakicoffee/libraries/utils";
import type { Database } from "@hobenakicoffee/libraries/types";Common tasks
- Run the package's tests:
bunx nx run @hobenakicoffee/libraries:test. It worked when Bun's test runner exits 0. - Typecheck and lint:
bunx nx run @hobenakicoffee/libraries:typecheckandbunx nx run @hobenakicoffee/libraries:check. Both exit 0 when clean. - Add an entry point: add the file under
packages/libraries/src/, add a line toexportsinpackages/libraries/package.json, then import it from an app. It worked when that app'stypecheckpasses. - After you edit
packages/libraries/src/sentry/privacy.tsorpackages/libraries/src/auth/first-party-token.ts, runbun run --cwd packages/libraries sync:backend. It worked whenbunx nx run @hobenakicoffee/backend:checkpasses.
Gotchas
- The root entry point (
@hobenakicoffee/libraries) re-exports./constantsonly. Import a utility from./utils. ./utilsis 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 boundarieschecks it.
Other shared packages
packages/ holds five more shared packages, each with its own page:
packages/post-body: renders a post's Markdown body. See Post body.packages/letter-shapes: draws text as outlined letter shapes. See Letter shapes.packages/page-widget: the Page widget script. See Page widget.packages/cast: the story cast's drawings. See Doel bhai: the cast.packages/emails: the email templates and renderers. See Email notifications.
Related
- Constants: every shared constant and the database copies it mirrors.
- Types: the
Databasetype and typed RPC results. - Share kit modules: the rules every Share kit tool shares.
- Brand kit: how the Brand kit's files are made.
- Single-purpose modules: SEO, Sentry, analytics and the rest.