Skip to content

feat(app): scaffold @packrat/app shared package with FSD organization#2375

Draft
andrew-bierman wants to merge 9 commits into
developmentfrom
feat/packages-domain
Draft

feat(app): scaffold @packrat/app shared package with FSD organization#2375
andrew-bierman wants to merge 9 commits into
developmentfrom
feat/packages-domain

Conversation

@andrew-bierman
Copy link
Copy Markdown
Collaborator

Summary

  • Scaffolds a new packages/app workspace package (@packrat/app) intended to be the shared layer for both the Expo app and future web app
  • Moves all cleanly extractable types, utils, and lib files from apps/expo/features/ into packages/app/src/ following Feature-Sliced Design organization
  • Expo app and future web app become thin routing shells; shared business logic lives in @packrat/app

What moved

All feature types, pure utils, and lib files were git mv'd (tracked as renames) from apps/expo/features/{feature}/ into packages/app/src/{feature}/:

Feature Moved
packs types.ts, input.ts, utils/convertToGrams, utils/convertFromGrams, utils/computePackWeights
catalog types.ts, lib/normalizeDescription
trips types.ts
pack-templates types.ts, utils/computePacktemplateWeight
ai types.ts, lib/constants
ai-packs types.ts
feed types.ts
guides types.ts
profile types.ts
trail-conditions types.ts
wildlife types.ts, data/speciesDatabase, lib/offlineIdentifier

Package design

  • Sub-path exports: @packrat/app/packs, @packrat/app/catalog, etc. — no single barrel, FSD-style import paths
  • Self-referential tsconfig alias: files inside packages/app can import siblings via @packrat/app/packs instead of deep ../../ traversal
  • No re-export stubs: expo callers import directly from @packrat/app/{feature} — clean break, no compatibility shims
  • Zero type errors after migration (bun check-types clean)

Left for follow-up PRs

  • Auth atoms (depend on kvStorage — needs persistence injection pattern)
  • Legend-state stores (need platform split for persistence layer)
  • .web.tsx UI components (next major phase — expo/web thin shells)

Post-Deploy Monitoring & Validation

No additional operational monitoring required: purely a refactor moving code between packages with no runtime behavior changes.

Adds packages/domain with package.json, tsconfig, and barrel index files
for packs, catalog, trips, and pack-templates sub-packages. Registers
@packrat/domain/* paths in the root tsconfig.
- Fix imports in moved domain files to use @packrat/api/types instead of
  expo-app/* aliases
- Add thin re-export stubs in expo features so all existing imports are
  unaffected (zero churn to callers)
- Add @packrat/domain workspace dependency to expo package.json
Renames packages/domain → packages/app and updates all references.
The shared package will hold full FSD feature slices (types, hooks,
utils, and .web.tsx UI variants) — not just domain logic — so 'app'
is the more accurate name. Expo and web apps become thin routing
shells on top of packages/app.
Moves 7 feature type files (ai-packs, ai, feed, guides, profile,
trail-conditions, wildlife) to packages/app/src with index barrels
and sub-path exports. Adds re-export stubs in expo so existing
imports are unaffected. Adds `ai` catalog dep to packages/app.

Skipped: weather/types.ts (refs MaterialIconName from expo-app),
auth atoms/store (kvStorage — needs injection pattern PR).
Move all cleanly extractable code from apps/expo/features to packages/app
following FSD organization. Callers import directly via @packrat/app/{feature}
sub-path exports — no re-export stubs.

Moved:
- packs, catalog, trips, pack-templates, ai, ai-packs, feed, guides,
  profile, trail-conditions, wildlife — types, utils, lib, data files

packages/app gets self-referential tsconfig paths so internal files
can import siblings via @packrat/app/packs instead of deep ../.. traversal.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9b6d6e04-ff37-4be0-85aa-793f3edfad5c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/packages-domain

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file mobile labels May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Coverage Report for Expo Unit Tests Coverage (./apps/expo)

Status Category Percentage Covered / Total
🔵 Lines Unknown% 0 / 0
🔵 Statements Unknown% (🎯 75%) 0 / 0
🔵 Functions Unknown% 0 / 0
🔵 Branches Unknown% 0 / 0
File CoverageNo changed files found.
Generated in workflow #1045 for commit 8ba584e by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Coverage Report for API Unit Tests Coverage (./packages/api)

Status Category Percentage Covered / Total
🔵 Lines 72.93% 609 / 835
🔵 Statements 72.93% (🎯 65%) 609 / 835
🔵 Functions 96% 48 / 50
🔵 Branches 88.27% 271 / 307
File CoverageNo changed files found.
Generated in workflow #1045 for commit 8ba584e by the Vitest Coverage Report Action

…ms, components, screens)

Completes the mass migration of apps/expo/features/ to packages/app/src/.
Every feature slice now lives in the shared package — expo becomes a thin
routing shell.

Moved:
- hooks, stores, atoms (all features)
- components, screens (all features)
- lib dirs (ai, catalog, weather)
- offline-ai feature (new slice)
- weather feature (new slice with types, atoms, hooks, components, screens)

Import strategy:
- Deep paths for cross-feature hook/component imports (@packrat/app/{feature}/hooks/X)
- Type barrel (@packrat/app/{feature}) for type-only imports
- expo-app/* internal refs are transitional (lib/, components/ not yet moved)

packages/app tsconfig updated to allow deep path resolution.
Relocates all remaining non-routing directories from apps/expo/ to
packages/app/src/ via git mv (atoms, components, lib, screens, types,
utils, providers, theme, data) and rewrites all expo-app/* imports in
both packages/app/src/ and apps/expo/app/ routing files to use the
@packrat/app/* path alias. The expo routing shell retains only
expo-app/app/_layout and expo-app/config cross-references which
legitimately remain in apps/expo. Also updates biome.json overrides to
point to new file paths and nativewindui tsconfig alias.
…mport paths

- Fix all expo routing files: expo-app/config → @packrat/app/config
- Fix settings screen: expo-app/app/_layout appAlert → @packrat/app/lib/appAlert
- Fix auth screens: expo-app/assets → @packrat/app/assets requires
- Add packages/app/src/lib/appAlert.ts with registerAppAlert() pattern
- Move apps/expo/config.ts → packages/app/src/config.ts (git rename)
- Move assets/packrat-app-icon-gradient.png and adaptive-icon.png to packages/app/src/assets/
- Fix biome formatting on all changed files

Zero type errors, zero remaining expo-app/ imports outside comments.
apps/expo is now a thin routing shell with only routing files and base config.
@andrew-bierman
Copy link
Copy Markdown
Collaborator Author

Unblocked by #2423 (@packrat/db + @packrat/schemas extraction) which just landed rebased and is mergeable. Once #2423 merges, this can proceed as-is on that foundation rather than the old shim shape.

Three review focuses when this comes out of draft:

  1. FSD layer boundaries: confirm features/ only depends on entities/ and shared/, and that nothing in entities/ imports from features/ (FSD's hard rule). A lint/check enforcing this would be valuable — easier to add now than after consumers start depending on the structure.
  2. Re-export surface: with 528 files affected, the public API of @packrat/app is huge. Worth deciding whether all entity schemas re-export through @packrat/app (current pattern, per refactor: extract @packrat/db and @packrat/schemas from @packrat/api #2423's plan) or whether @packrat/app is application-only and entities stay in @packrat/schemas. Pick one to avoid a third schema-import path.
  3. Migration ordering vs chore(lint): enforce single-parameter owned functions #2422: the single-param refactor (chore(lint): enforce single-parameter owned functions #2422) is rebased and on track to land. If this scaffold introduces multi-param helpers, please ensure they conform to the scripts/lint/no-owned-max-params.ts check from chore(lint): enforce single-parameter owned functions #2422.

Ready to do a deeper structural review once you flip from draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant