Skip to content

shared + backend: design unified platform deep-link resolver with fallback chain #42

@ShantKhatri

Description

@ShantKhatri

Summary

The follow/connect flow currently has fragmented deep-link logic spread across packages/shared/src/platforms.ts and apps/backend/src/routes/follow.ts. Refactor into a unified DeepLinkResolver utility in packages/shared that supports a priority fallback chain: native deep link → universal link → web URL → webview.

Context

Different devices and install states require different URL schemes. The resolver should determine the best link strategy for a given platform + device context and expose a clean interface for both web and mobile consumers.

Tasks

  • in packages/shared/src/deepLinks.ts (new file), define:
    • type LinkStrategy = 'native-deeplink' | 'universal-link' | 'web-url' | 'webview'.
    • type ResolvedLink = { strategy: LinkStrategy; url: string; fallback?: ResolvedLink }.
    • function resolveDeepLink(platform: string, username: string, context: { hasApp?: boolean; isMobile?: boolean }): ResolvedLink — returns the whole fallback chain.
  • update PLATFORMS entries in platforms.ts to include:
    • nativeScheme: string | null — e.g. 'linkedin://'.
    • universalLink: string | null — e.g. 'https://linkedin.com/in/{username}'.
    • webViewFallback: boolean — true for platforms (like LinkedIn) that need WebView for actions.
  • refactor apps/backend/src/routes/follow.ts to use resolveDeepLink from shared.
  • refactor apps/mobile/src/screens/DevCardViewScreen.tsx to use resolveDeepLink for button behavior.
  • write exhaustive unit tests in packages/shared/src/__tests__/deepLinks.test.ts covering all strategy combinations.

Acceptance Criteria

  • every platform in PLATFORMS has a complete resolver entry.
  • mobile and backend both use the shared resolver — no duplicated URL logic.
  • unit tests cover all 4 strategies and fallback chain traversal.
  • pnpm -r test passes.

Difficulty

senior — requires cross-package refactoring, polymorphic type design, and deep understanding of every platform's URL scheme.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions