Skip to content

Conversation

@SakshiKekre
Copy link
Collaborator

@SakshiKekre SakshiKekre commented Dec 26, 2025

Summary

Restructures the PolicyEngine app into a proper Turborepo monorepo with separate apps and shared packages.

New Structure

policyengine-app-v2/
├── apps/
│   ├── website/           # policyengine.org (port 3000)
│   └── calculator/        # app.policyengine.org (port 3001)
├── packages/
│   ├── design-system/     # Shared UI components and design tokens
│   └── shared/            # Common utilities, hooks, routing
└── app/                   # DELETED - old monolithic app

Key Changes

Apps separation:

  • apps/website/ - Static website with NO Redux, NO React Query (lightweight)
  • apps/calculator/ - Interactive calculator with full Redux + React Query stack

Shared packages:

  • @policyengine/design-system - Design tokens, HomeHeader component, chart utilities
  • @policyengine/shared - Country config, useCurrentCountry hook, geolocation routing, URL utilities

Code consolidation:

  • Country labels consolidated to single source of truth in shared package
  • HomeHeader refactored to "dumb" component accepting props (moved to design-system)
  • Each app has thin wrapper components for app-specific navigation logic

New utilities:

  • replaceCountryInPath() - Clean URL manipulation for country switching
  • COUNTRIES / WEBSITE_COUNTRIES arrays for dropdowns
  • countryLabels record for display names

Testing:

  • Added organizations validation test (ensures all orgs have country IDs)
  • Updated vitest.setup.ts with browser API mocks for Mantine components

Before Merging

  1. Rebase after PR feat: Allow multiple instances of the dev server to run simultaneously #540 - That PR adds dynamic port discovery which resolves the dev mode cross-app URL issue.

  2. Vercel Dashboard - Configure Root Directory for each project:

    • policyengine-websiteapps/website
    • policyengine-calculatorapps/calculator

Documentation

See repo-code-split-summary.md for detailed breakdown of all changes.

Test Plan

  • npm run typecheck passes
  • npm run packages:build succeeds
  • Website tests pass (npm test in apps/website)
  • Website dev server runs on :3000
  • Calculator dev server runs on :3001
  • Vercel deployments succeed (requires dashboard config)
  • Manual testing of both apps

@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
policyengine-app-v2 Error Error Dec 28, 2025 10:19pm
policyengine-calculator Error Error Dec 28, 2025 10:19pm
policyengine-website Error Error Dec 28, 2025 10:19pm

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants