<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Khanh Tran</title>
    <description>The latest articles on Forem by Khanh Tran (@harrytranswe).</description>
    <link>https://forem.com/harrytranswe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3629715%2F3d5248eb-8528-4a36-bac1-5863446f8ef4.jpg</url>
      <title>Forem: Khanh Tran</title>
      <link>https://forem.com/harrytranswe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/harrytranswe"/>
    <language>en</language>
    <item>
      <title>Building a Scalable Frontend Monorepo with Turborepo, Vite, TailwindCSS V4, React 19, Tanstack Router, Tanstack Form</title>
      <dc:creator>Khanh Tran</dc:creator>
      <pubDate>Thu, 27 Nov 2025 08:29:50 +0000</pubDate>
      <link>https://forem.com/harrytranswe/building-a-scalable-frontend-monorepo-with-turborepo-vite-tailwindcss-v4-react-19-tanstack-21ko</link>
      <guid>https://forem.com/harrytranswe/building-a-scalable-frontend-monorepo-with-turborepo-vite-tailwindcss-v4-react-19-tanstack-21ko</guid>
      <description>&lt;h1&gt;
  
  
  Building a Scalable Frontend Monorepo: Architecture Best Practices
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In modern frontend development, managing multiple applications and shared packages efficiently is crucial for maintaining code quality, enforcing consistency, and accelerating development velocity. This article introduces a production-ready monorepo architecture that demonstrates best practices for structuring large-scale frontend projects.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;Monorepo UI Starter&lt;/strong&gt; is built with cutting-edge tools and follows industry-standard patterns to solve common challenges in enterprise frontend development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🚀 &lt;strong&gt;Code Sharing&lt;/strong&gt;: Reusable components, utilities, and configurations across multiple apps&lt;/li&gt;
&lt;li&gt;🏗️ &lt;strong&gt;Scalability&lt;/strong&gt;: Clear separation of concerns with a modular package structure&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Performance&lt;/strong&gt;: Optimized builds with caching and parallel execution via Turborepo&lt;/li&gt;
&lt;li&gt;🎨 &lt;strong&gt;Developer Experience&lt;/strong&gt;: Integrated Storybook for component development and documentation&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;Type Safety&lt;/strong&gt;: End-to-end TypeScript with shared type definitions&lt;/li&gt;
&lt;li&gt;🔧 &lt;strong&gt;Maintainability&lt;/strong&gt;: Consistent linting, formatting, and build configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Modern Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React 19&lt;/strong&gt; with React Compiler for automatic optimization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vite 7&lt;/strong&gt; for lightning-fast builds and HMR&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript 5.9&lt;/strong&gt; with strict type checking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind CSS v4&lt;/strong&gt; for utility-first styling&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Complete Form System
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Form&lt;/strong&gt; integration with type-safe form state management&lt;/li&gt;
&lt;li&gt;Pre-built form components (TextField, SelectField, SubmitButton)&lt;/li&gt;
&lt;li&gt;Lazy loading for optimal bundle size&lt;/li&gt;
&lt;li&gt;Automatic validation and error handling&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Query&lt;/strong&gt; for server state management&lt;/li&gt;
&lt;li&gt;Separate packages for queries and mutations&lt;/li&gt;
&lt;li&gt;Automatic caching and background refetching&lt;/li&gt;
&lt;li&gt;Optimistic updates support&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Type-Safe Routing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Router&lt;/strong&gt; with file-based routing&lt;/li&gt;
&lt;li&gt;Auto-generated route tree&lt;/li&gt;
&lt;li&gt;Protected route groups&lt;/li&gt;
&lt;li&gt;Type-safe navigation and params&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Component Library
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mantine v8&lt;/strong&gt; + &lt;strong&gt;Tailwind v4&lt;/strong&gt; hybrid approach&lt;/li&gt;
&lt;li&gt;Atomic design structure (atoms, molecules, templates)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storybook&lt;/strong&gt; for component documentation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phosphor Icons&lt;/strong&gt; for consistent iconography&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Developer Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Turborepo for build orchestration&lt;/li&gt;
&lt;li&gt;pnpm for fast, efficient package management&lt;/li&gt;
&lt;li&gt;ESLint and Prettier for code quality&lt;/li&gt;
&lt;li&gt;Type checking across all packages&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technology Stack
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Core Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://turbo.build/repo" rel="noopener noreferrer"&gt;Turborepo&lt;/a&gt;&lt;/strong&gt;: High-performance build system for JavaScript/TypeScript monorepos (v2.6.1)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://pnpm.io/" rel="noopener noreferrer"&gt;pnpm&lt;/a&gt;&lt;/strong&gt;: Fast, disk space efficient package manager with excellent monorepo support (v9.0.0)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://react.dev/" rel="noopener noreferrer"&gt;React 19&lt;/a&gt;&lt;/strong&gt;: Latest version with React Compiler support (v19.2.0)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite 7&lt;/a&gt;&lt;/strong&gt;: Next-generation frontend build tool (v7.2.4)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript 5.9&lt;/a&gt;&lt;/strong&gt;: Strict type checking across the entire codebase (v5.9.3)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  UI &amp;amp; Styling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://mantine.dev/" rel="noopener noreferrer"&gt;Mantine&lt;/a&gt;&lt;/strong&gt;: Comprehensive React component library (v8.3.8)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS v4&lt;/a&gt;&lt;/strong&gt;: Utility-first CSS framework (v4.1.17)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://storybook.js.org/" rel="noopener noreferrer"&gt;Storybook&lt;/a&gt;&lt;/strong&gt;: Component development and documentation environment (v10.0.8)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://phosphoricons.com/" rel="noopener noreferrer"&gt;Phosphor Icons&lt;/a&gt;&lt;/strong&gt;: Flexible icon family (v2.1.10)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Application Framework
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tanstack.com/router" rel="noopener noreferrer"&gt;TanStack Router&lt;/a&gt;&lt;/strong&gt;: Type-safe routing with automatic route generation (v1.139.1)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tanstack.com/query" rel="noopener noreferrer"&gt;TanStack Query&lt;/a&gt;&lt;/strong&gt;: Powerful asynchronous state management (v5.90.10)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tanstack.com/form" rel="noopener noreferrer"&gt;TanStack Form&lt;/a&gt;&lt;/strong&gt;: Headless, type-safe form state management (v1.26.0)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://axios-http.com/" rel="noopener noreferrer"&gt;Axios&lt;/a&gt;&lt;/strong&gt;: HTTP client for API requests (v1.13.2)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://zod.dev/" rel="noopener noreferrer"&gt;Zod&lt;/a&gt;&lt;/strong&gt;: TypeScript-first schema validation (v4.1.12)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Utility Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/dcastil/tailwind-merge" rel="noopener noreferrer"&gt;tailwind-merge&lt;/a&gt;&lt;/strong&gt;: Efficiently merge Tailwind CSS classes (v3.4.0)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.tailwind-variants.org/" rel="noopener noreferrer"&gt;tailwind-variants&lt;/a&gt;&lt;/strong&gt;: Create variant-based component styles (v3.2.2)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://usehooks.com/" rel="noopener noreferrer"&gt;@uidotdev/usehooks&lt;/a&gt;&lt;/strong&gt;: Collection of modern React hooks (v2.4.1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monorepo Architecture
&lt;/h2&gt;

&lt;h3&gt;
  
  
  High-Level Structure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;monorepo-ui-starter/
├── apps/                    # Deployable applications
│   ├── web/                # Main web application
│   └── storybook/          # Component documentation
├── packages/               # Shared internal packages
│   ├── ui/                 # Component library
│   ├── api-client/         # API layer
│   ├── hooks/              # React hooks &amp;amp; queries
│   ├── types/              # TypeScript definitions
│   ├── utils/              # Utility functions
│   ├── eslint-config/      # Shared ESLint configs
│   └── typescript-config/  # Shared TypeScript configs
├── package.json            # Root workspace configuration
├── pnpm-workspace.yaml     # pnpm workspace definition
└── turbo.json              # Turborepo pipeline configuration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Design Philosophy
&lt;/h3&gt;

&lt;p&gt;This architecture follows the &lt;strong&gt;"apps and packages"&lt;/strong&gt; pattern, which separates:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Applications&lt;/strong&gt; (&lt;code&gt;apps/&lt;/code&gt;): Deployable, user-facing applications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Packages&lt;/strong&gt; (&lt;code&gt;packages/&lt;/code&gt;): Reusable internal libraries and configurations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This separation ensures clear boundaries and enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Independent deployment of applications&lt;/li&gt;
&lt;li&gt;Shared code without duplication&lt;/li&gt;
&lt;li&gt;Incremental adoption of shared packages&lt;/li&gt;
&lt;li&gt;Clear dependency graphs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deep Dive: Package Structure
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;apps/web&lt;/code&gt; - Main Application
&lt;/h3&gt;

&lt;p&gt;The primary React application built with Vite and modern routing patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File-based routing&lt;/strong&gt; with TanStack Router&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Route generation&lt;/strong&gt; via &lt;code&gt;@tanstack/router-plugin&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication context&lt;/strong&gt; with protected routes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layout system&lt;/strong&gt; for consistent UI structure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature-based organization&lt;/strong&gt; for scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Directory Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web/
├── src/
│   ├── main.tsx                    # App entry point
│   ├── routeTree.gen.ts           # Auto-generated routes
│   ├── components/
│   │   └── layouts/               # Layout components
│   │       └── MainLayout/
│   ├── context/
│   │   └── auth.tsx               # Auth state management
│   ├── features/                  # Feature modules
│   │   ├── Home/
│   │   ├── Login/
│   │   ├── Users/
│   │   ├── AddUser/
│   │   └── UserDetail/
│   ├── hooks/                     # App-specific hooks
│   ├── routes/                    # Route definitions
│   │   ├── __root.tsx
│   │   ├── (auth)/               # Auth route group
│   │   │   └── login.tsx
│   │   └── (main)/               # Protected route group
│   │       ├── index.tsx
│   │       ├── route.tsx
│   │       └── users/
│   │           ├── index.tsx      # /users
│   │           ├── create.tsx     # /users/create
│   │           └── $userId.tsx    # /users/:userId
│   └── styles/
│       └── globals.css
├── package.json
└── vite.config.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best Practices Demonstrated:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Feature-Based Organization&lt;/strong&gt;: Each feature (Home, Users, Login) is self-contained with its own components and logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Route Grouping&lt;/strong&gt;: Using &lt;code&gt;(auth)&lt;/code&gt; and &lt;code&gt;(main)&lt;/code&gt; for logical separation without affecting URLs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type-Safe Routing&lt;/strong&gt;: TanStack Router provides full TypeScript support&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Separation&lt;/strong&gt;: Auth logic separated from components&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2. &lt;code&gt;apps/storybook&lt;/code&gt; - Component Documentation
&lt;/h3&gt;

&lt;p&gt;Dedicated Storybook instance for developing and documenting the UI component library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual component testing&lt;/li&gt;
&lt;li&gt;Interactive documentation&lt;/li&gt;
&lt;li&gt;Design system showcase&lt;/li&gt;
&lt;li&gt;Isolated development environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;storybook/
├── src/
│   ├── examples/              # Example implementations
│   │   ├── Icons.tsx
│   │   └── table.tsx
│   └── stories/               # Component stories
│       ├── Button.stories.ts
│       ├── Input.stories.ts
│       ├── TextInput.stories.ts
│       ├── Table.stories.ts
│       ├── EmptyState.stories.tsx
│       └── Icons.stories.ts
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. &lt;code&gt;packages/ui&lt;/code&gt; - Component Library
&lt;/h3&gt;

&lt;p&gt;The heart of the design system, providing reusable React components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architecture Highlights:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Atomic Design Pattern&lt;/strong&gt;: Organized into atoms, molecules, organisms, and templates&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polymorphic Components&lt;/strong&gt;: Using Mantine's &lt;code&gt;createPolymorphicComponent&lt;/code&gt; for flexibility&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind + Mantine Hybrid&lt;/strong&gt;: Leverages both utility classes and component library&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS Export&lt;/strong&gt;: Exports &lt;code&gt;globals.css&lt;/code&gt; for consistent styling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ui/
├── src/
│   ├── globals.css           # Global styles
│   ├── assets/
│   │   └── images/
│   ├── atoms/                # Basic building blocks
│   │   ├── ActionIcon.tsx
│   │   ├── Button.tsx
│   │   ├── Input.tsx
│   │   ├── TextInput.tsx
│   │   ├── Select.tsx
│   │   ├── Table.tsx
│   │   ├── Icon.tsx
│   │   ├── EmptyState.tsx
│   │   ├── CopyButton.tsx
│   │   ├── UIProvider.tsx
│   │   └── index.ts
│   ├── molecules/            # Composite components
│   │   ├── Form/            # TanStack Form integration
│   │   │   ├── components/
│   │   │   │   ├── FormContainer.tsx
│   │   │   │   ├── FormTextField.tsx
│   │   │   │   ├── FormSelectField.tsx
│   │   │   │   ├── SubmitButton.tsx
│   │   │   │   └── index.ts
│   │   │   ├── context.tsx
│   │   │   └── index.ts
│   │   └── index.ts
│   └── templates/            # Page templates
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Component Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Wrapping Mantine with custom styling&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;MButton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;MButtonProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@mantine/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createPolymorphicComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;forwardRef&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLButtonElement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MButton&lt;/span&gt;
      &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;classNames&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
        &lt;span class="na"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;focus:ring-2 focus:ring-brand-400&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;section&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[&amp;amp;_svg]:text-brand-300&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}}&lt;/span&gt;
    &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consistent component API across the application&lt;/li&gt;
&lt;li&gt;Easy customization through Tailwind classes&lt;/li&gt;
&lt;li&gt;Type-safe props with TypeScript&lt;/li&gt;
&lt;li&gt;Accessible components out of the box (Mantine)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Form System with TanStack Form:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The UI package includes a sophisticated form system built on TanStack Form v1.26.0, providing type-safe, headless form state management:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Form hook creation with field and form components&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;createFormHook&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@tanstack/react-form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TextField&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./FormTextField&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SelectField&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./FormSelectField&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SubmitButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./SubmitButton&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;useAppForm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withForm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withFieldGroup&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createFormHook&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;fieldComponents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;SelectField&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;formComponents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;SubmitButton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;fieldContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;formContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Form Components:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;FormContainer&lt;/code&gt;: Wrapper component for form layout&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FormTextField&lt;/code&gt;: Text input field with validation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FormSelectField&lt;/code&gt;: Select dropdown field&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SubmitButton&lt;/code&gt;: Form submission button with loading state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lazy loading for optimal bundle size&lt;/li&gt;
&lt;li&gt;Type-safe field definitions&lt;/li&gt;
&lt;li&gt;Automatic validation and error handling&lt;/li&gt;
&lt;li&gt;Consistent form behavior across the application&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;code&gt;packages/api-client&lt;/code&gt; - API Layer
&lt;/h3&gt;

&lt;p&gt;Centralized HTTP client with type-safe API endpoints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api-client/
├── src/
│   ├── index.ts              # Main client export
│   ├── axios.ts              # Axios configuration
│   ├── user.ts               # User endpoints
│   └── product.ts            # Product endpoints
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client Configuration&lt;/strong&gt;: Single source for base URL, auth tokens, and interceptors&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Organization&lt;/strong&gt;: Each domain (user, product) has its own file&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type Integration&lt;/strong&gt;: Uses shared types from &lt;code&gt;@repo/types&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token Management&lt;/strong&gt;: Integrates with utility functions for auth&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Centralized API logic&lt;/li&gt;
&lt;li&gt;Easy to mock for testing&lt;/li&gt;
&lt;li&gt;Consistent error handling&lt;/li&gt;
&lt;li&gt;Reusable across multiple apps&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. &lt;code&gt;packages/hooks&lt;/code&gt; - React Hooks &amp;amp; Queries
&lt;/h3&gt;

&lt;p&gt;Custom hooks and TanStack Query integration layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hooks/
├── src/
│   ├── lib/                  # Utility hooks
│   │   ├── api.ts
│   │   └── index.ts
│   ├── queries/              # TanStack Query hooks
│   │   ├── index.ts
│   │   ├── user.ts
│   │   └── product.ts
│   └── mutations/            # TanStack Query mutations
│       ├── index.ts
│       └── user.ts
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Multi-path Export Strategy:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./lib"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/lib/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./queries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/queries/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./mutations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/mutations/index.ts"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separation of general hooks from data-fetching hooks&lt;/li&gt;
&lt;li&gt;Server state management with TanStack Query&lt;/li&gt;
&lt;li&gt;Consistent data fetching patterns (queries) and mutation patterns&lt;/li&gt;
&lt;li&gt;Automatic caching and refetching&lt;/li&gt;
&lt;li&gt;Optimistic updates and error handling for mutations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. &lt;code&gt;packages/types&lt;/code&gt; - Type Definitions
&lt;/h3&gt;

&lt;p&gt;Shared TypeScript interfaces and types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;types/
├── src/
│   ├── index.ts              # Main exports
│   ├── user.ts               # User types
│   ├── product.ts            # Product types
│   └── response.ts           # API response types
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Best Practices:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Domain-based type organization&lt;/li&gt;
&lt;li&gt;Export both types and validators&lt;/li&gt;
&lt;li&gt;Single source of truth for data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. &lt;code&gt;packages/utils&lt;/code&gt; - Utility Functions
&lt;/h3&gt;

&lt;p&gt;Pure utility functions for common operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;utils/
├── src/
│   ├── index.ts
│   └── cookies.ts            # Cookie management
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Framework-agnostic utilities&lt;/li&gt;
&lt;li&gt;Shared business logic&lt;/li&gt;
&lt;li&gt;Helper functions&lt;/li&gt;
&lt;li&gt;No external dependencies (when possible)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Configuration Packages
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;packages/eslint-config&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Shared ESLint configurations for consistent code quality.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eslint-config/
├── eslint.base.js            # Base config
├── eslint.react.js           # React-specific rules
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consistent linting across all packages&lt;/li&gt;
&lt;li&gt;Easy to update rules globally&lt;/li&gt;
&lt;li&gt;Different configs for different package types&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;packages/typescript-config&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Shared TypeScript configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;typescript-config/
├── tsconfig.base.json        # Base config
├── tsconfig.vite.json        # Vite-specific config
└── package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Configuration Inheritance:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;In&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;app's&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;tsconfig.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@repo/typescript-config/tsconfig.vite.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;App-specific&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;overrides&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Workspace Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  pnpm Workspace
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;pnpm-workspace.yaml&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;packages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;apps/*"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;packages/*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple configuration tells pnpm to treat all directories under &lt;code&gt;apps/&lt;/code&gt; and &lt;code&gt;packages/&lt;/code&gt; as workspace packages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single &lt;code&gt;node_modules&lt;/code&gt; at root (with proper hoisting)&lt;/li&gt;
&lt;li&gt;Fast installation with content-addressable storage&lt;/li&gt;
&lt;li&gt;Strict dependency management&lt;/li&gt;
&lt;li&gt;Workspace protocol for internal packages&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Turborepo Pipeline
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;turbo.json&lt;/code&gt;:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"$schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://turborepo.com/schema.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"ui"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tui"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tasks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"dependsOn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"^build"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"inputs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"$TURBO_DEFAULT$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;".env*"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"outputs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".next/**"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"!.next/cache/**"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"dependsOn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"^lint"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"check-types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"dependsOn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"^check-types"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"cache"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"persistent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Task Dependencies&lt;/strong&gt;: &lt;code&gt;^build&lt;/code&gt; means "run build in dependencies first"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt;: Automatic caching of build outputs for fast rebuilds&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel Execution&lt;/strong&gt;: Independent tasks run in parallel&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incremental Builds&lt;/strong&gt;: Only rebuild changed packages&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Workflow Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build everything (with dependency order)&lt;/span&gt;
pnpm build

&lt;span class="c"&gt;# Build only web app and its dependencies&lt;/span&gt;
pnpm build &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;web

&lt;span class="c"&gt;# Develop specific app&lt;/span&gt;
pnpm dev &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;storybook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dependency Management Strategy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Workspace Dependencies
&lt;/h3&gt;

&lt;p&gt;Internal packages reference each other using the &lt;code&gt;workspace:*&lt;/code&gt; protocol:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@repo/ui"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"workspace:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@repo/hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"workspace:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@repo/types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"workspace:*"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always uses local version during development&lt;/li&gt;
&lt;li&gt;Prevents version mismatches&lt;/li&gt;
&lt;li&gt;Clear indication of internal dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Peer Dependencies
&lt;/h3&gt;

&lt;p&gt;UI components declare React as a peer dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"peerDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^19.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^19.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensures single React instance across the app&lt;/li&gt;
&lt;li&gt;Prevents duplicate React in bundle&lt;/li&gt;
&lt;li&gt;Consumer controls the React version&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Version Synchronization
&lt;/h3&gt;

&lt;p&gt;Common dependencies use the same version across packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;typescript&lt;/code&gt;: &lt;code&gt;~5.9.3&lt;/code&gt; (all packages)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;eslint&lt;/code&gt;: &lt;code&gt;^9.39.1&lt;/code&gt; (all packages)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-dom&lt;/code&gt;: &lt;code&gt;^19.2.0&lt;/code&gt; (web + storybook)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@tanstack/react-query&lt;/code&gt;: &lt;code&gt;^5.90.10&lt;/code&gt; (web + hooks)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@tanstack/react-form&lt;/code&gt;: &lt;code&gt;^1.26.0&lt;/code&gt; (web + ui)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vite&lt;/code&gt;: &lt;code&gt;^7.2.4&lt;/code&gt; (web + storybook + ui)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tailwindcss&lt;/code&gt;: &lt;code&gt;^4.1.17&lt;/code&gt; (web + ui)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@mantine/core&lt;/code&gt;: &lt;code&gt;^8.3.8&lt;/code&gt; (ui)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Routing Architecture
&lt;/h2&gt;

&lt;h3&gt;
  
  
  TanStack Router Features
&lt;/h3&gt;

&lt;p&gt;The web app uses TanStack Router with advanced features:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. File-Based Routing&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;routes/
├── __root.tsx                 # Root layout
├── (auth)/
│   └── login.tsx             # /login
└── (main)/
    ├── route.tsx             # Layout for protected routes
    ├── index.tsx             # /
    └── users/
        ├── index.tsx         # /users
        └── $userId.tsx       # /users/:userId
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Route Context&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;AppRouterContext&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;QueryClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AuthContext&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createRouter&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;routeTree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Type-Safe Navigation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Auto-generated types for all routes&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@tanstack/react-router&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/users/$userId&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  State Management Patterns
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Server State (TanStack Query)
&lt;/h3&gt;

&lt;p&gt;For data from APIs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In @repo/hooks/queries/user.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;queryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;queryFn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;apiClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For data mutations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In @repo/hooks/mutations/user.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useCreateUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;mutationFn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CreateUserData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;apiClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;onSuccess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invalidateQueries&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;queryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatic caching&lt;/li&gt;
&lt;li&gt;Background refetching&lt;/li&gt;
&lt;li&gt;Optimistic updates&lt;/li&gt;
&lt;li&gt;Loading/error states&lt;/li&gt;
&lt;li&gt;Automatic query invalidation after mutations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Authentication State (Context)
&lt;/h3&gt;

&lt;p&gt;For global auth state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In apps/web/src/context/auth.tsx&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AuthProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// Auth logic&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;AuthContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Local State (React Hooks)
&lt;/h3&gt;

&lt;p&gt;For component-specific state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isOpen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsOpen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Development Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
pnpm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Develop all apps&lt;/span&gt;
pnpm dev

&lt;span class="c"&gt;# Develop specific app&lt;/span&gt;
pnpm dev &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;web
pnpm dev &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;storybook

&lt;span class="c"&gt;# Build all packages&lt;/span&gt;
pnpm build

&lt;span class="c"&gt;# Lint everything&lt;/span&gt;
pnpm lint

&lt;span class="c"&gt;# Type check all packages&lt;/span&gt;
pnpm check-types

&lt;span class="c"&gt;# Format code&lt;/span&gt;
pnpm format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a New Package
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create package directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;packages/new-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add &lt;code&gt;package.json&lt;/code&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@repo/new-package"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/index.ts"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The package is automatically detected by pnpm workspace&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Adding a New App
&lt;/h3&gt;

&lt;p&gt;Similar to package, but in &lt;code&gt;apps/&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;apps/new-app
&lt;span class="c"&gt;# Add package.json with appropriate dependencies&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices &amp;amp; Patterns
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Package Naming Convention
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;@repo/&lt;/code&gt; scope for all internal packages&lt;/li&gt;
&lt;li&gt;Descriptive names: &lt;code&gt;@repo/ui&lt;/code&gt;, &lt;code&gt;@repo/api-client&lt;/code&gt;, &lt;code&gt;@repo/hooks&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Consistent with standard naming (e.g., &lt;code&gt;eslint-config&lt;/code&gt;, &lt;code&gt;typescript-config&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Export Strategy
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Named Exports for Atoms:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// @repo/ui/atoms/index.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;TextInput&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./TextInput&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Select&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Select&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Table&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Table&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;EmptyState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./EmptyState&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Icon&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Icon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Icon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sub-path Exports for Categories:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./globals.css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/globals.css"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./atoms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/atoms/index.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"./molecules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/molecules/index.ts"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Usage in Applications:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Import atoms&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Select&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@repo/ui/atoms&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Import molecules (Form components)&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FormContainer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useAppForm&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@repo/ui/molecules&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Import global styles&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@repo/ui/globals.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Type Safety
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Strict TypeScript in all packages&lt;/li&gt;
&lt;li&gt;Shared types in &lt;code&gt;@repo/types&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Runtime validation with Zod where needed&lt;/li&gt;
&lt;li&gt;Proper peer dependencies for React components&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Code Organization
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Feature-Based Structure in Apps:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;features/
├── Users/
│   ├── Users.tsx
│   ├── UserList.tsx
│   ├── UserCard.tsx
│   └── index.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Atomic Design in UI Package:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ui/
├── atoms/          # Button, Input
├── molecules/      # SearchBar, Card
├── organisms/      # Header, Sidebar
└── templates/      # PageLayout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Documentation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;README in each package explaining its purpose&lt;/li&gt;
&lt;li&gt;Storybook for visual components&lt;/li&gt;
&lt;li&gt;JSDoc comments for complex functions&lt;/li&gt;
&lt;li&gt;TypeScript types as inline documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Performance Optimization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tree-shaking&lt;/strong&gt;: ES modules for optimal bundling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code splitting&lt;/strong&gt;: Dynamic imports for routes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt;: Turborepo caches all build outputs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Compiler&lt;/strong&gt;: Enabled for automatic optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Testing Strategy
&lt;/h3&gt;

&lt;p&gt;While not shown in current structure, recommended additions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;packages/ui/
├── src/
│   └── atoms/
│       ├── Button.tsx
│       └── Button.test.tsx
└── vitest.config.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scaling Considerations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  When to Create New Packages
&lt;/h3&gt;

&lt;p&gt;Create a new package when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Code is reused across 2+ apps&lt;/li&gt;
&lt;li&gt;✅ It has a clear, single responsibility&lt;/li&gt;
&lt;li&gt;✅ It can be developed/tested independently&lt;/li&gt;
&lt;li&gt;✅ It has stable interfaces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't create a package if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ It's only used in one app&lt;/li&gt;
&lt;li&gt;❌ It's tightly coupled to app logic&lt;/li&gt;
&lt;li&gt;❌ The API changes frequently&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Adding More Apps
&lt;/h3&gt;

&lt;p&gt;This structure easily supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Admin dashboard (&lt;code&gt;apps/admin&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Mobile web app (&lt;code&gt;apps/mobile&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Landing page (&lt;code&gt;apps/landing&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Internal tools (&lt;code&gt;apps/tools&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All sharing the same packages for consistency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multi-Framework Support
&lt;/h3&gt;

&lt;p&gt;While this starter uses React, you could add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vue app using &lt;code&gt;@repo/types&lt;/code&gt; and &lt;code&gt;@repo/api-client&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Node.js backend using &lt;code&gt;@repo/types&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;React Native app using &lt;code&gt;@repo/hooks&lt;/code&gt; and &lt;code&gt;@repo/utils&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Migration Path for Existing Projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Monorepo Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Add &lt;code&gt;pnpm-workspace.yaml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;turbo.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Update root &lt;code&gt;package.json&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Extract Shared Code
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Move shared components to &lt;code&gt;packages/ui&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Move API calls to &lt;code&gt;packages/api-client&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Move types to &lt;code&gt;packages/types&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Configure Dependencies
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Update imports to use &lt;code&gt;@repo/*&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add workspace dependencies&lt;/li&gt;
&lt;li&gt;Test builds and dev mode&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Optimize
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Configure Turborepo caching&lt;/li&gt;
&lt;li&gt;Set up parallel execution&lt;/li&gt;
&lt;li&gt;Add Storybook for components&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Pitfalls &amp;amp; Solutions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Issue: Circular Dependencies
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Use dependency injection and proper layering&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;utils → types → api-client → hooks → ui → apps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Issue: Slow Installations
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Use pnpm and Turborepo caching&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# pnpm is much faster than npm/yarn&lt;/span&gt;
pnpm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--frozen-lockfile&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Issue: Type Errors Across Packages
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Use project references in TypeScript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"references"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"../../packages/types"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Issue: Hot Reload Not Working
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Configure Vite to watch workspace packages&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vite.config.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;ignored&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;!**/node_modules/@repo/**&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-World Benefits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Development Speed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Shared components&lt;/strong&gt;: Build once, use everywhere&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Type safety&lt;/strong&gt;: Catch errors at compile time&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Fast builds&lt;/strong&gt;: Turborepo cache eliminates redundant work&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code Quality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Consistent patterns&lt;/strong&gt;: Shared configs enforce standards&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Reusability&lt;/strong&gt;: DRY principle across all apps&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Team Collaboration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Clear ownership&lt;/strong&gt;: Each package has clear boundaries&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Independent work&lt;/strong&gt;: Teams can work on different apps/packages&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Shared knowledge&lt;/strong&gt;: Common patterns across codebase&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Maintainability
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Single source of truth&lt;/strong&gt;: Types, configs, and components&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Easy updates&lt;/strong&gt;: Change once, update everywhere&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Dependency management&lt;/strong&gt;: Workspace protocol prevents version drift&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This monorepo architecture represents modern best practices for frontend development at scale. By combining Turborepo's build orchestration, pnpm's efficient package management, and a well-organized structure, it provides:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Exceptional Developer Experience&lt;/strong&gt;: Fast builds, hot reload, type safety&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Reusability&lt;/strong&gt;: Shared packages eliminate duplication&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Easy to add new apps and packages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability&lt;/strong&gt;: Consistent patterns and single source of truth&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Optimized builds with caching and parallel execution&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whether you're starting a new project or migrating an existing one, this architecture provides a solid foundation for building modern, scalable frontend applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turborepo Documentation&lt;/strong&gt;: &lt;a href="https://turbo.build/repo/docs" rel="noopener noreferrer"&gt;https://turbo.build/repo/docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pnpm Workspaces&lt;/strong&gt;: &lt;a href="https://pnpm.io/workspaces" rel="noopener noreferrer"&gt;https://pnpm.io/workspaces&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Router&lt;/strong&gt;: &lt;a href="https://tanstack.com/router/latest" rel="noopener noreferrer"&gt;https://tanstack.com/router/latest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Query&lt;/strong&gt;: &lt;a href="https://tanstack.com/query/latest" rel="noopener noreferrer"&gt;https://tanstack.com/query/latest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TanStack Form&lt;/strong&gt;: &lt;a href="https://tanstack.com/form/latest" rel="noopener noreferrer"&gt;https://tanstack.com/form/latest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mantine UI&lt;/strong&gt;: &lt;a href="https://mantine.dev/" rel="noopener noreferrer"&gt;https://mantine.dev/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tailwind CSS&lt;/strong&gt;: &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;https://tailwindcss.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phosphor Icons&lt;/strong&gt;: &lt;a href="https://phosphoricons.com/" rel="noopener noreferrer"&gt;https://phosphoricons.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vite&lt;/strong&gt;: &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;https://vitejs.dev/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Repository
&lt;/h2&gt;

&lt;p&gt;Check out the full implementation at: [&lt;a href="https://github.com/khanhspring/monorepo-ui-starter" rel="noopener noreferrer"&gt;https://github.com/khanhspring/monorepo-ui-starter&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Feel free to use this starter as a foundation for your next project, and contribute improvements back to the community!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Last updated: November 27, 2025&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Built with ❤️ for the frontend community&lt;/em&gt;&lt;/p&gt;

</description>
      <category>turborepo</category>
      <category>tailwindcss</category>
      <category>vite</category>
      <category>react</category>
    </item>
  </channel>
</rss>
