Skip to content

Conversation

@williamw
Copy link
Collaborator

@williamw williamw commented Oct 9, 2025

This PR contains a major architectural refactoring that migrates the GenAI Cookbook from npm to a pnpm workspace monorepo structure. The changes include significant code cleanup, removal of technical debt, performance improvements, and bug fixes. The result is a more maintainable, performant, and scalable codebase with ~2,100 fewer lines of code.

Key Changes

🏗️ Architecture & Structure

  • Migrated to pnpm workspace monorepo

    • Replaced npm with pnpm package manager
    • Created workspace structure with apps/ and packages/ directories
    • Added pnpm-workspace.yaml configuration
    • Removed package-lock.json, added pnpm-lock.yaml
  • Restructured codebase into monorepo

    • apps/cookbook/ - Next.js 14 application with App Router
    • packages/recipes/ - Shared recipe implementations (UI + API)
    • Improved code organization and separation of concerns
    • Switched from Webpack to Turbopack for dev (better hot reload support for monorepos)

🧹 Code Refactoring & Cleanup

  • Removed useCookbook from recipe UI components

    • Reduced coupling between app and recipes
    • Cleaner component interfaces
  • Added general-purpose cache utility (apps/cookbook/utils/cache.ts)

    • Consolidated EndpointStore and API key retrieval
    • Removed RecipeStore
  • Simplified recipe API handlers (apps/cookbook/app/cookbook/[recipe]/api/route.ts:1)

    • Improves visibility into how the recipes use the AD SDK
    • Improves type safety and error handling
  • Moved theme into cookbook app (apps/cookbook/utils/theme.ts:1)

    • Reduced cross-package dependencies
    • Simplified recipes package (only uses vanilla Mantine components)

🐛 Bug Fixes & Improvements

  • Fixed token animation bug in multi-turn chat (packages/recipes/src/multiturn-chat/ui.tsx:1)
  • Simplified recipe source code retrieval

Migration Notes

For Developers

If you're pulling this branch, you'll need to:

  1. Install pnpm (if not already installed):

    npm install -g pnpm
  2. Remove old dependencies:

    rm -rf node_modules package-lock.json
  3. Install dependencies:

    pnpm install
  4. Run development server:

    pnpm dev

Statistics

  • Files changed: 124
  • Insertions: +5,616
  • Deletions: -7,727
  • Net reduction: ~2,111 lines of code

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

@williamw williamw changed the title Migrate to pnpm workspace monorepo with architectural refactoring [cookbook] Migrate to pnpm workspace monorepo Oct 9, 2025
@williamw williamw merged commit a779098 into main Oct 9, 2025
1 check passed
@williamw williamw deleted the billw/pnpm branch October 9, 2025 18:21
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