Skip to content

awell-health/navi

Repository files navigation

Navi Monorepo

A monorepo for the Navi healthcare activities SDK, following a Stripe-like architecture for maximum security, performance, and developer experience.

🚧 Development Status: Currently in v0.x.x development phase - building toward v1.0.0 production release.

πŸ“š Documentation

Complete development and architecture documentation:

For Developers: Read .cursor/rules for critical development guidelines and patterns. For Architecture: Review API-CONTRACTS.md and REPOSITORY-STRATEGY.md for system design. For Releases: Follow RELEASE-PIPELINE.md for deployment coordination.

πŸ—οΈ Architecture Overview

This monorepo implements a CDN + NPM package distribution model similar to Stripe.js:

🌐 CDN Distribution

  • packages/navi.js/ β†’ Built and deployed to CDN (Google Cloud/Cloudflare/Vercel)
  • Global distribution for optimal performance and caching
  • Version pinning for predictable behavior

πŸ”’ Embed Portal

  • apps/navi-portal/ β†’ Deployed to Vercel as embed-only content
  • Cross-origin iframes for security and compliance
  • Isolated rendering of healthcare activities

πŸ“¦ NPM Packages

  • packages/navi-js/ β†’ Wrapper package that loads CDN script (like @stripe/stripe-js)
  • packages/navi-react/ β†’ React components and hooks for direct integration
  • packages/navi-core/ β†’ Shared utilities, types, and services

πŸ§ͺ Development & Testing

  • examples/test-integration/ β†’ Integration testing app for both SDK patterns
  • Cross-origin testing between localhost:3001 (customer) and localhost:3000 (embed)

πŸš€ Distribution Strategy

Production Deployment

🌐 CDN: https://cdn.awellhealth.com
└── /v1/navi.js                 ← JavaScript SDK

πŸ”’ Embed: https://navi-portal.awellhealth.com
└── /[pathway_id]               ← Iframe content

πŸ“¦ NPM: @awell-health/navi-js
└── Loads CDN script securely

Development Environment

🏒 Portal: localhost:3000
β”œβ”€β”€ /navi.js                    ← Development SDK
└── /embed/[pathway_id]         ← Iframe content

πŸ§ͺ Test App: localhost:3001
└── Tests both SDK integration patterns

πŸ“¦ Package Responsibilities

@awell-health/navi-js

NPM wrapper package that securely loads the Navi SDK from CDN. Provides TypeScript types and a clean loading interface, similar to how @stripe/stripe-js works.

@awell-health/navi-react

React components for customers who want to embed Navi activities directly into their React applications instead of using iframes.

@awell-health/navi-core

Shared utilities, TypeScript types, authentication services, and common functionality used across the SDK packages.

navi.js (CDN Bundle)

The main JavaScript SDK that gets distributed via CDN. Creates secure cross-origin iframes and handles all communication with the Navi embed portal.

navi-portal (Embed Application)

Vercel-deployed application that renders healthcare activities inside secure iframes. Handles JWT authentication, branding, and activity rendering.

πŸ› οΈ Development

Prerequisites

  • Node.js 22+
  • pnpm package manager

Quick Start

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Start development servers
pnpm dev

This starts both the portal (localhost:3000) and test integration app (localhost:3001) to test cross-origin iframe functionality.

Package Development

# Build packages only
pnpm build:packages

# Test specific package
pnpm --filter navi-react test

# Lint all code
pnpm lint

🌍 Deployment Targets

  • CDN: Google Cloud CDN, Cloudflare, or Vercel Edge Network
  • Portal: Vercel (navi-portal.awellhealth.com)
  • NPM: Public registry for customer installation

πŸ“ Workspace Structure

navi/
β”œβ”€β”€ apps/
β”‚   └── navi-portal/              # Embed portal (Vercel deployment)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ navi-js/                  # NPM wrapper (loads CDN)
β”‚   β”œβ”€β”€ navi.js/                  # JavaScript SDK (CDN bundle)
β”‚   β”œβ”€β”€ navi-react/               # React components (NPM)
β”‚   └── navi-core/                # Shared utilities (NPM)
β”œβ”€β”€ examples/
β”‚   └── simple-embed/             # Cross-origin testing app
└── requirements/                 # Architecture & API documentation
graph TD
    A["Customer Website<br/>localhost:3001"] --> B["Install @awell-health/navi-js"]
    B --> C["loadNavi('pk_test_...')"]
    C --> D["CDN Request<br/>localhost:3000/v1/navi.js"]
    D --> E["navi.js SDK<br/>(15KB bundle)"]
    E --> F["Creates iframe<br/>β†’ localhost:3000/embed/pathway"]
    F --> G["Navi Portal<br/>Activities & Forms"]

    H["@awell-health/navi-js-react"] --> I["React Components"]
    I --> J["Direct Components<br/>(No iframe)"]
    J --> G

    K["navi-core"] --> L["Shared Types<br/>& Utilities"]
    L --> E
    L --> G
    L --> I
Loading

πŸ”„ Release Management

Uses Changesets for coordinated package versioning:

pnpm changeset           # Add changeset
pnpm changeset:version   # Update versions
pnpm changeset:publish   # Publish to NPM

CDN deployment happens automatically via GitHub Actions when tags are pushed.

🎯 Design Goals

  • Security: Cannot bundle or self-host (like Stripe's PCI compliance model)
  • Performance: Global CDN distribution with aggressive caching
  • Developer Experience: Clean APIs with full TypeScript support
  • Reliability: Version pinning and backward compatibility
  • Compliance: HIPAA-aligned architecture for healthcare data

πŸ“„ License

MIT

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/name)
  3. Commit changes (git commit -m 'Description')
  4. Push branch (git push origin feature/name)
  5. Open Pull Request

πŸ“ž Support

For questions or issues, please open a GitHub issue or contact the Awell Health team.