<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karol Trzaska on Medium]]></title>
        <description><![CDATA[Stories by Karol Trzaska on Medium]]></description>
        <link>https://medium.com/@ktrzaska_54145?source=rss-8b86bab0d32f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KcK2oi02ArlLqKaiqIxF9A.jpeg</url>
            <title>Stories by Karol Trzaska on Medium</title>
            <link>https://medium.com/@ktrzaska_54145?source=rss-8b86bab0d32f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:40:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ktrzaska_54145/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Embedding IBM Lineage in Your Own React App]]></title>
            <link>https://medium.com/@ktrzaska_54145/embedding-ibm-lineage-in-your-own-react-app-820841874245?source=rss-8b86bab0d32f------2</link>
            <guid isPermaLink="false">https://medium.com/p/820841874245</guid>
            <category><![CDATA[watsonx]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[data-governance]]></category>
            <dc:creator><![CDATA[Karol Trzaska]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 12:38:05 GMT</pubDate>
            <atom:updated>2026-10-29T06:52:24.432Z</atom:updated>
            <content:encoded><![CDATA[<p>A step-by-step guide using Webpack Module Federation</p><h3>Introduction</h3><p>Watsonx.Data Intelligence comes with an interactive data lineage viewer — a graph that shows you where your data came from, where it flows, and what transformations happened along the way. It is a powerful tool. But what if you want that graph inside your own application, not just on the IBM platform?</p><p>This article shows you how to do exactly that. We will use a technique called Webpack Module Federation, which lets your app load a React component from a remote server at runtime — in this case, straight from Cloud Pak. No copy-paste of IBM’s source code, no iframe hacks, no reimplementation. You load the real thing.</p><p>We cover two approaches:</p><p><strong>Option A </strong>— use @ibm/federated-component, an open-source IBM npm package that handles all the low-level wiring for you. You write about 30 lines of React code and you are done.</p><p><strong>Option B</strong> — write the wiring yourself, from scratch. Takes a bit more code (~80 lines of TypeScript) but you own every line and depend on nothing extra.</p><p>Both options produce the same end result: the IBM lineage graph running live inside your React app, talking to watsonx through a small proxy server you control.</p><h3>What Is Module Federation?</h3><p>Normally, when you build a React app, Webpack bundles all your code into a single JavaScript file that is shipped to the browser. Module Federation changes that: it lets two completely separate apps share code with each other at runtime, without any ahead-of-time bundling between them.</p><p>In this setup there are two roles:</p><p><strong>Host</strong> — your app. It knows where to find the remote bundle and loads it on demand.</p><p><strong>Remote</strong> — the IBM lineage viewer. It sits on the watsonx server and exposes itself as a JavaScript bundle at a fixed URL.</p><p>That remote bundle URL looks like this:</p><p><strong>https://&lt;your-cloud-pak-host&gt;/lineage/lineage-components.js</strong></p><p>When your app loads that script, the lineage viewer registers itself on the browser’s window object. Your app then asks Webpack’s federation runtime to resolve the React component from that registration, wraps it in React.lazy(), and renders it like any other component.</p><p>One thing that makes this work cleanly: Module Federation has a built-in mechanism for sharing libraries. You tell it that React is a shared singleton, and both your app and the lineage viewer will use the same copy. Without that, you’d get two Reacts in one page, which causes subtle and annoying bugs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*1_1TmGbs3V2T8DLOBRj76g.png" /></figure><h3>Prerequisites</h3><p>- A React 18 app using Webpack 5 and CRACO, with the classic create-react-app layout (<em>public/index.html</em> and <em>src/index.tsx</em>). If you are starting fresh, see ‘Project structure’ in the section ‘Running Everything Locally’.</p><ul><li>Node.js 24 or newer.</li><li>Access to an IBM Cloud Pak for Data deployment with Data Lineage enabled.</li><li>An IBM Cloud API key</li></ul><h3>The Architecture in Three Parts</h3><p>Before writing any code it helps to see the full picture. There are three moving parts:</p><p>1. Your app (host) — runs in the browser. It loads the lineage viewer bundle from watsonx and renders it on screen. It sends data API calls to your own server, never directly to IBM.</p><p>2. A small Express server — runs alongside your front-end. Its only job is to get a bearer token from IBM and attach it to every API request that the lineage viewer makes. Your credentials never leave your server.</p><p>3. Watsonx.Data Intelligence — serves both the lineage JavaScript bundle (static, no auth needed) and the lineage data API (requires the bearer token).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*-Ia0CR10eCHgkIqP7O4oyw.png" /></figure><h3>Part 1 — The Proxy Server</h3><p>Both Option A and Option B need this proxy, so build it first.</p><h4>1.1 Environment variables</h4><p>Create a <em>.env</em> file at the root of your project. Never commit this file to version control.</p><pre># Target platform<br>REACT_APP_TARGET=CLOUD<br>REACT_APP_BASE_URL=https://&lt;your-watsonx-host&gt;<br>REACT_APP_TARGET_ENDPOINT=lineage<br><br># Proxy<br>REACT_APP_PROXY_ENDPOINT=/proxit<br>REACT_APP_PROXY_URL=http://localhost:3001/proxit<br><br># Server ports<br>HTTP_SERVER_PORT=8080<br>NODE_DEV_SERVER=3001<br><br># IBM Cloud credentials<br>API_KEY=&lt;your-ibm-cloud-api-key&gt;<br>CLOUD_IAM_DOMAIN=iam.cloud.ibm.com</pre><h4>1.2 Token service</h4><p>Create <em>src/server/services/auth.js</em>. It fetches a bearer token from IBM via the IBM Cloud IAM API key exchange. The token is cached in memory and refreshed automatically every 59 minutes (IBM tokens expire after 60).</p><pre><br>// src/server/services/auth.js<br>import axios from &#39;axios&#39;;<br>import https from &#39;https&#39;;<br>import cron  from &#39;node-cron&#39;;<br><br>let currentToken = null;<br><br>// IBM Cloud: exchange API key for bearer token via IAM<br>const getBearerTokenCloud = () =&gt;<br>  axios({<br>    url: `https://${process.env.CLOUD_IAM_DOMAIN}/identity/token`,<br>    method: &#39;POST&#39;,<br>    headers: { &#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39; },<br>    data: {<br>      grant_type: &#39;urn:ibm:params:oauth:grant-type:apikey&#39;,<br>      apikey: process.env.API_KEY,<br>    },<br>  });<br><br>// Refresh every 59 minutes so the token never expires mid-session<br>cron.schedule(&#39;*/59 * * * *&#39;, async () =&gt; {<br>  currentToken = await getBearerTokenCloud();<br>  console.debug(&#39;Bearer token refreshed&#39;);<br>});<br><br>export const getToken = async () =&gt; {<br>  if (!currentToken) currentToken = await getBearerTokenCloud();<br>  return currentToken.data.access_token<br>      || currentToken.data.accessToken;<br>};</pre><h4>1.3 Proxy route</h4><p>Create <em>src/server/routes/proxy.js</em>. Every request that arrives on <em>/proxit</em> gets the bearer token injected as an XX-Authorization header, then forwarded to the lineage <em>/_embedded</em> endpoint.</p><pre>// src/server/routes/proxy.js<br>import { Router } from &#39;express&#39;;<br>import { createProxyMiddleware, fixRequestBody }<br>  from &#39;http-proxy-middleware&#39;;<br>import { getToken } from &#39;../services/auth.js&#39;;<br><br>const proxyRouter = Router();<br><br>// Allow the lineage viewer (running in the browser) to call this proxy<br>proxyRouter.use((req, res, next) =&gt; {<br>  res.header(&#39;Access-Control-Allow-Origin&#39;, &#39;*&#39;);<br>  res.header(&#39;Access-Control-Allow-Headers&#39;,<br>    &#39;Origin, X-Requested-With, Content-Type, Accept&#39;);<br>  next();<br>});<br><br>const proxyMiddleware = async (req, res, next) =&gt; {<br>  const token  = await getToken();<br>  const target =<br>    `${process.env.REACT_APP_BASE_URL}` +<br>    `/${process.env.REACT_APP_TARGET_ENDPOINT}/_embedded`;<br><br>  return createProxyMiddleware({<br>    target,<br>    headers: {<br>      ...req.headers,<br>      &#39;XX-Authorization&#39;: `Bearer ${token}`,<br>    },<br>    on: fixRequestBody,<br>    secure: false,<br>    changeOrigin: true,<br>  })(req, res, next);<br>};<br><br>proxyRouter.all(&#39;/*splat&#39;, (req, res, next) =&gt;<br>  proxyMiddleware(req, res, next));<br><br>export default proxyRouter;</pre><p>Wire the router into Express. The first import loads your <em>.env</em> file into <em>process.env</em> — without it <em>REACT_APP_PROXY_ENDPOINT</em> and <em>HTTP_SERVER_PORT</em> are undefined and the server cannot start:</p><pre>// src/server/index.js<br>import &#39;dotenv/config&#39;;<br>import express from &#39;express&#39;;<br>import proxyRouter from &#39;./routes/proxy.js&#39;;<br><br>const app = express();<br>app.use(process.env.REACT_APP_PROXY_ENDPOINT, proxyRouter);<br>app.listen(process.env.HTTP_SERVER_PORT, () =&gt;<br>  console.log(`Proxy running on port ${process.env.HTTP_SERVER_PORT}`)<br>);</pre><h3>Part 2 — Webpack Module Federation Config</h3><p>Your React app needs to declare itself as a Module Federation host and mark React as a shared singleton. Without the singleton flag Webpack will load two separate copies of React — one from your bundle, one from the lineage bundle — which breaks hooks and context in subtle ways.</p><p>If you use CRACO (recommended for create-react-app projects), add the following to <em>craco.config.cjs</em>. For a plain Webpack 5 project, the same plugin block goes into <em>webpack.config.js</em>.</p><pre><br>// craco.config.cjs<br>require(&#39;dotenv&#39;).config();  // load .env before process.env is read below<br>const { ModuleFederationPlugin } = require(&#39;webpack&#39;).container;<br><br>module.exports = {<br>  devServer: {<br>    port: process.env.NODE_DEV_SERVER,<br>    proxy: {<br>      // The lineage viewer fetches its own CSS and images<br>      // using these paths — forward them to watsonx<br>      &#39;/lineage/js&#39;:       { target: process.env.REACT_APP_BASE_URL,<br>                             secure: false, changeOrigin: true },<br>      &#39;/lineage/css&#39;:      { target: process.env.REACT_APP_BASE_URL,<br>                             secure: false, changeOrigin: true },<br>      &#39;/lineage/graphics&#39;: { target: process.env.REACT_APP_BASE_URL,<br>                             secure: false, changeOrigin: true },<br>      // Forward data API calls to your Express proxy<br>      [process.env.REACT_APP_PROXY_ENDPOINT]:<br>        `http://localhost:${process.env.HTTP_SERVER_PORT}`,<br>    },<br>  },<br>  webpack: {<br>    configure: (webpackConfig) =&gt; {<br>      webpackConfig.plugins.push(<br>        new ModuleFederationPlugin({<br>          name: &#39;my_host_app&#39;,  // any name, just for MF bookkeeping<br>          shared: {<br>            // Both your app and the lineage viewer must use<br>            // the exact same React instance<br>            react: {<br>              singleton: true,<br>              eager: true,<br>              requiredVersion: &#39;^18.0.0&#39;,<br>            },<br>            &#39;react-dom&#39;: {<br>              singleton: true,<br>              eager: true,<br>              requiredVersion: &#39;^18.0.0&#39;,<br>            },<br>          },<br>        })<br>      );<br>      // Required for the async dynamic imports MF relies on<br>      webpackConfig.experiments = {<br>        ...webpackConfig.experiments,<br>        topLevelAwait: true,<br>      };<br>      return webpackConfig;<br>    },<br>  },<br>};</pre><p>A note on the proxy entries: <em>/lineage/js</em>, <em>/lineage/css</em>, and <em>/lineage/graphics</em> are not for your own code — they exist because the lineage bundle’s internal code fetches its own stylesheets and images using those relative paths. Without these proxy rules you would get a blank viewer with missing styles.</p><h3>Option A — Using @ibm/federated-component</h3><p>The @ibm/federated-component package is a small open-source library published by IBM (BSD-3 licence, available at github.com/IBM/federated-component). It gives you a React component called FederatedComponent that handles script injection, the Webpack federation handshake, Suspense loading states, and error boundaries — all in one place. You just tell it where the remote bundle is and what props to pass.</p><h4>A.1 Install</h4><p><strong>npm install @ibm/federated-component</strong></p><h4>A.2 Create a wrapper component</h4><p>The three fixed values inside federationConfig identify the IBM lineage module specifically: scope is always <em>lineage_components</em>, module is always <em>./ExportedLineageViewer</em>, and url is the path to the lineage bundle on your watsonx host. A cache-busting timestamp is appended so the browser always fetches the latest version.</p><pre>// src/components/LineageViewer.tsx<br>import React from &#39;react&#39;;<br>import { FederatedComponent } from &#39;@ibm/federated-component&#39;;<br><br>interface Props {<br>  // Provide EITHER (assetId + containerId) OR lineageAssetIds<br>  assetId?:         string;   // IBM catalog asset UUID<br>  containerId?:     string;   // Catalog or project UUID<br>  lineageAssetIds?: string[]; // Pre-resolved 64-char hex lineage IDs existing in Lineage database itself.<br>  apiProxyUrl:      string;   // URL of your Express proxy (/proxit)<br>}<br><br>const BUILD_TS = Date.now();<br><br>export const LineageViewer: React.FC&lt;Props&gt; = (props) =&gt; (<br>  &lt;FederatedComponent<br>    federationConfig={{<br>      scope:  &#39;lineage_components&#39;,<br>      module: &#39;./ExportedLineageViewer&#39;,<br>      // ?t= forces a fresh fetch so you always get the latest<br>      // version of the viewer from watsonx<br>      url: `${process.env.REACT_APP_BASE_URL}`<br>         + `/lineage/lineage-components.js?t=${BUILD_TS}`,<br>    }}<br>    federatedComponentProps={{<br>      darkMode: false,<br>      apiProxyUrl: props.apiProxyUrl,<br>      componentsConfig: {<br>        hideLineageViewerTree:  true,<br>        lineageUrl: process.env.REACT_APP_BASE_URL,<br>        hideScopeFilters:       true,<br>        hideRefreshTime:        true,<br>        hideAssetSettings:      true,<br>        hideAlternativeNames:   true,<br>        additionalNodeActions:  [],<br>      },<br>      lineageConfig: {<br>        assetId:               props.assetId,<br>        containerId:           props.containerId,<br>        lineageAssetIds:       props.lineageAssetIds,<br>        expansionDirection:    &#39;upstreamDownstream&#39;,<br>        numberOfExpansionHops: 1,<br>        filterByTechnologyTypes: [],<br>        featureFlags: [&#39;featureFiltersScopeSettingsCloud&#39;],<br>      },<br>    }}<br>    ErrorComponent={&lt;p&gt;Could not load lineage viewer.&lt;/p&gt;}<br>    LoadingComponent={&lt;p&gt;Loading lineage...&lt;/p&gt;}<br>  /&gt;<br>);</pre><h4>A.3 assetId + containerId vs lineageAssetIds</h4><p>There are two ways to tell the lineage viewer what to show:</p><p><em>assetId</em> + <em>containerId</em> — the standard IBM catalog asset UUID and the UUID of its catalog or project. This is the easiest option: the viewer resolves the lineage graph internally. You find both UUIDs in the URL bar when you open an asset in the watsonx UI.</p><p><em>lineageAssetIds</em> — an array of IDs in the lineage-specific 64-character hexadecimal format returned by the lineage search REST API. Use this when you have already queried that API separately.</p><p>You only need one of the two. If both are provided, <em>lineageAssetIds</em> takes precedence.</p><h3>Option B — Writing the Wiring Yourself</h3><p>This option skips the <strong>@ibm/federated-component</strong> package entirely. You build the same mechanism piece by piece — which is useful if you want zero extra dependencies, need to customise the loading behaviour, or simply prefer to own every line.</p><h4>B.1 Hook: inject a remote script</h4><p>This hook appends a<em> &lt;script&gt;</em> element to the page and tells you when it is ready. It caches loaded URLs so the script is injected only once, regardless of how many times the component mounts.</p><pre>// src/hooks/useDynamicScript.ts<br>import { useState, useEffect } from &#39;react&#39;;<br><br>const urlCache = new Set&lt;string&gt;();<br><br>export const useDynamicScript = (url: string | null) =&gt; {<br>  const [ready, setReady] = useState(false);<br>  const [errorLoading, setErrorLoading] = useState(false);<br><br>  useEffect(() =&gt; {<br>    if (!url) return;<br><br>    // Already loaded — report ready immediately<br>    if (urlCache.has(url)) {<br>      setReady(true);<br>      return;<br>    }<br><br>    setReady(false);<br>    setErrorLoading(false);<br><br>    const script   = document.createElement(&#39;script&#39;);<br>    script.src     = url;<br>    script.type    = &#39;text/javascript&#39;;<br>    script.async   = true;<br>    script.onload  = () =&gt; { urlCache.add(url); setReady(true); };<br>    script.onerror = () =&gt; { setReady(false); setErrorLoading(true); };<br><br>    document.head.appendChild(script);<br><br>    return () =&gt; {<br>      document.head.removeChild(script);<br>    };<br>  }, [url]);<br><br>  return { ready, errorLoading };<br>};</pre><h4>B.2 Utility: read from the remote Webpack container</h4><p>Once the script is loaded the remote bundle has registered itself on window. This function reads from that container. The two <em>__webpack_</em> globals are injected automatically by Webpack when you add <strong>ModuleFederationPlugin</strong> to your config — you do not write them, you just call them.</p><pre>// src/utils/loadComponent.ts<br><br>// Globals injected by Webpack&#39;s Module Federation runtime<br>declare const __webpack_init_sharing__: (s: string) =&gt; Promise&lt;void&gt;;<br>declare const __webpack_share_scopes__: { default: object };<br><br>export const loadComponent =<br>  (scope: string, module: string) =&gt;<br>  async () =&gt; {<br>    // 1. Fill the host&#39;s shared scope with known modules<br>    await __webpack_init_sharing__(&#39;default&#39;);<br><br>    // 2. Get the remote container from window<br>    const container = (window as any)[scope];<br><br>    // 3. Tell the remote which shared modules the host provides<br>    //    (this is what prevents two Reacts loading)<br>    await container.init(__webpack_share_scopes__.default);<br><br>    // 4. Resolve the specific export we need<br>    const factory = await container.get(module);<br>    return factory();<br>  };</pre><h4>B.3 Hook: combine script injection and container reading</h4><p>This hook ties the previous two pieces together and hands back a <em>React.lazy()</em> component ready to be rendered inside a Suspense boundary.</p><pre>// src/hooks/useFederatedComponent.ts<br>import { useMemo, lazy, ComponentType } from &#39;react&#39;;<br>import { useDynamicScript } from &#39;./useDynamicScript&#39;;<br>import { loadComponent }    from &#39;../utils/loadComponent&#39;;<br><br>export const useFederatedComponent = (<br>  remoteUrl: string,<br>  scope:     string,<br>  module:    string<br>) =&gt; {<br>  const { ready, errorLoading } = useDynamicScript(remoteUrl);<br>  const Component = useMemo&lt;ComponentType&lt;any&gt; | null&gt;(() =&gt; (ready ? lazy(loadComponent(scope, module)) : null), [ready, scope, module]);<br><br>  return { errorLoading, Component };<br>};</pre><h4>B.4 ErrorBoundary</h4><p>React’s Suspense handles the loading state, but runtime errors inside the loaded component need a class-based ErrorBoundary. This is a standard React pattern — nothing specific to Module Federation.</p><pre><br>// src/components/ErrorBoundary.tsx<br>import React, { ReactNode } from &#39;react&#39;;<br><br>interface State { hasError: boolean; }<br><br>export class ErrorBoundary extends React.Component&lt;<br>  { fallback: ReactNode; children: ReactNode },<br>  State<br>&gt; {<br>  state: State = { hasError: false };<br><br>  static getDerivedStateFromError() {<br>    return { hasError: true };<br>  }<br><br>  render() {<br>    if (this.state.hasError) return this.props.fallback;<br>    return this.props.children;<br>  }<br>}</pre><h4>B.5 The final LineageViewer component</h4><p>Now put everything together. The Suspense boundary shows a loading state while the remote bundle downloads. The ErrorBoundary catches any crash inside the lineage viewer and shows a safe fallback instead of breaking your page.</p><pre><br>// src/components/LineageViewer.tsx<br>import React, { Suspense } from &#39;react&#39;;<br>import { useFederatedComponent } from &#39;../hooks/useFederatedComponent&#39;;<br>import { ErrorBoundary }          from &#39;./ErrorBoundary&#39;;<br><br>interface Props {<br>  assetId?:         string;<br>  containerId?:     string;<br>  lineageAssetIds?: string[];<br>  apiProxyUrl:      string;<br>}<br><br>export const LineageViewer: React.FC&lt;Props&gt; = (props) =&gt; {<br>  const remoteUrl =<br>    `${process.env.REACT_APP_BASE_URL}` +<br>    `/lineage/lineage-components.js?t=${Date.now()}`;<br><br>  const { Component, errorLoading } = useFederatedComponent(<br>    remoteUrl,<br>    &#39;lineage_components&#39;,      // fixed: IBM lineage scope name<br>    &#39;./ExportedLineageViewer&#39;  // fixed: IBM lineage export name<br>  );<br><br>  if (errorLoading)<br>    return &lt;p&gt;Failed to load the lineage viewer.&lt;/p&gt;;<br><br>  return (<br>    &lt;Suspense fallback={&lt;p&gt;Loading lineage...&lt;/p&gt;}&gt;<br>      &lt;ErrorBoundary fallback={&lt;p&gt;Lineage viewer crashed.&lt;/p&gt;}&gt;<br>        {Component ? (<br>          &lt;Component<br>            darkMode={false}<br>            apiProxyUrl={props.apiProxyUrl}<br>            componentsConfig={{<br>              hideLineageViewerTree:  true,<br>              lineageUrl: process.env.REACT_APP_BASE_URL,<br>              hideScopeFilters:       true,<br>              hideRefreshTime:        true,<br>              hideAssetSettings:      true,<br>              hideAlternativeNames:   true,<br>              additionalNodeActions:  [],<br>            }}<br>            lineageConfig={{<br>              assetId:               props.assetId,<br>              containerId:           props.containerId,<br>              lineageAssetIds:       props.lineageAssetIds,<br>              expansionDirection:    &#39;upstreamDownstream&#39;,<br>              numberOfExpansionHops: 1,<br>              filterByTechnologyTypes: [],<br>              featureFlags: [&#39;featureFiltersScopeSettingsCloud&#39;],<br>            }}<br>          /&gt;<br>        ) : (<br>          &lt;p&gt;Loading...&lt;/p&gt;<br>        )}<br>      &lt;/ErrorBoundary&gt;<br>    &lt;/Suspense&gt;<br>  );<br>};</pre><h3>Option A vs Option B — Which Should You Pick?</h3><p>Both produce identical results at runtime. The choice is purely about how much you want to own.</p><p>Choose Option A if you want the fastest path to a working integration. You write about 30 lines of React code and the package handles script injection, the Webpack handshake, Suspense, and ErrorBoundary for you. The <strong>@ibm/federated-component</strong> package is open-source, MIT-friendly (BSD-3), and maintained by <strong>IBM</strong>.</p><p>Choose Option B if you have a policy against extra dependencies, need to tweak the loading behaviour at a low level (custom error handling, preloading, sharing additional libraries), or simply want to fully understand and own the mechanism. The full implementation is about 80 lines of TypeScript spread across four small files.</p><h3>Running Everything Locally</h3><p>So far you have built two separate programs: the Express proxy (Part 1) and the React app with its Webpack dev server (Part 2). This section wires them together so that a single command starts both.</p><h4>How the pieces connect</h4><p>In development two processes run side by side. The browser only ever talks to the Webpack dev server; the dev server decides which requests it answers itself and which it hands over to someone else:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Um4Ry4AfJ05N2FOirSxa3g.png" /></figure><p>This is the link between the two halves. The proxy entry in <em>craco.config.cjs</em> (the <em>[process.env.REACT_APP_PROXY_ENDPOINT]</em> line) forwards everything under <em>/proxit</em> from port 3001 to the Express server on port 8080. That is why <em>REACT_APP_PROXY_URL</em> in your <em>.env</em> points at port 3001 and not 8080: the lineage viewer calls the dev server, and the dev server relays the call to Express, which adds the token and talks to watsonx.</p><p>Both processes read the same <em>.env</em> file. That is why the Express entry point starts with import ‘<em>dotenv/config</em>’ and <em>craco.config.cjs</em> starts with <em>require(‘dotenv’).config()</em> — each process loads the file on its own, and neither works without it.</p><h4>Project structure</h4><p>CRACO builds on react-scripts, which expects the classic create-react-app layout: the HTML template at <em>public/index.html</em> and the entry point at <em>src/index.tsx</em>. A project generated with Vite (npm create vite) keeps these files elsewhere, and npm run client then stops with ‘<em>Could not find a required file: index.html’</em>. create-react-app itself is deprecated, so there is no generator to run — you create the folder and a handful of small files yourself, starting with a package.json:</p><p><strong>mkdir my-lineage-app &amp;&amp; cd my-lineage-app &amp;&amp; npm init -y</strong></p><p>The finished project looks like this. The server files come from Part 1, <em>craco.config.cjs</em> from Part 2, and <em>LineageViewer.tsx</em> from Option A or Option B:</p><pre>my-lineage-app/<br>├── .env                      (1.1)<br>├── craco.config.cjs          (Part 2)<br>├── nodemon.json              (below)<br>├── package.json<br>├── tsconfig.json<br>├── public/<br>│   └── index.html<br>└── src/<br>    ├── index.tsx<br>    ├── App.tsx<br>    ├── components/LineageViewer.tsx<br>    └── server/<br>        ├── index.js<br>        ├── routes/proxy.js<br>        └── services/auth.js</pre><p>The two entry files are tiny. <em>src/index</em>.tsx mounts the app, and <em>src/App.tsx</em> renders the LineageViewer you build in Option A or Option B (replace the placeholder UUIDs with real ones, see A.3):</p><pre>// src/index.tsx<br>import { StrictMode } from &#39;react&#39;;<br>import { createRoot } from &#39;react-dom/client&#39;;<br>import App from &#39;./App&#39;;<br>createRoot(document.getElementById(&#39;root&#39;)!).render(<br>  &lt;StrictMode&gt;&lt;App /&gt;&lt;/StrictMode&gt;,<br>);<br>// src/App.tsx<br>import { LineageViewer } from &#39;./components/LineageViewer&#39;;<br>export default function App() {<br>  return (<br>    &lt;LineageViewer<br>      assetId=&quot;&lt;your-asset-uuid&gt;&quot;<br>      containerId=&quot;&lt;your-catalog-or-project-uuid&gt;&quot;<br>      apiProxyUrl={process.env.REACT_APP_PROXY_URL as string}<br>    /&gt;<br>  );<br>}</pre><p>Finally, <em>tsconfig.json</em>. react-scripts needs a CRA-style configuration compatible with TypeScript 4.9 (the <em>tsconfig.app.json</em> and <em>moduleResolution</em> ‘bundler’ that Vite generates will not work):</p><pre>// tsconfig.json<br>{ &quot;compilerOptions&quot;: { &quot;target&quot;: &quot;es6&quot;, &quot;lib&quot;: [&quot;dom&quot;, &quot;dom.iterable&quot;, &quot;esnext&quot;],<br>    &quot;allowJs&quot;: true, &quot;skipLibCheck&quot;: true, &quot;esModuleInterop&quot;: true,<br>    &quot;allowSyntheticDefaultImports&quot;: true, &quot;strict&quot;: false,<br>    &quot;forceConsistentCasingInFileNames&quot;: true, &quot;noFallthroughCasesInSwitch&quot;: true,<br>    &quot;module&quot;: &quot;esnext&quot;, &quot;moduleResolution&quot;: &quot;node&quot;, &quot;resolveJsonModule&quot;: true,<br>    &quot;isolatedModules&quot;: true, &quot;noEmit&quot;: true, &quot;jsx&quot;: &quot;react-jsx&quot; },<br>  &quot;include&quot;: [&quot;src&quot;] }</pre><h4>Install the dependencies</h4><p>The proxy needs a handful of runtime packages. Pin the major versions shown below: the ‘<em>/*splat</em>’ wildcard in <em>proxy.js</em> is Express 5 syntax, and the ‘on: fixRequestBody’ option is http-proxy-middleware 3 syntax. Older majors will not work with the code in this article.</p><p><strong>npm install react@18 react-dom@18 express@5 http-proxy-middleware@3 axios node-cron dotenv</strong></p><p>Then the tooling: CRACO and the react-scripts it wraps, nodemon to restart the server when you edit it, concurrently to run both processes from one terminal, and TypeScript with type definitions for the .tsx files in Option A and Option B. Pin typescript to 4.9.5: react-scripts 5 only supports TypeScript 3 and 4, and a plain ‘<em>npm install typescript</em>’ installs version 7, after which the dev server fails with ‘<em>Cannot find module typescript</em>’.</p><p><strong>npm install — save-dev @craco/craco react-scripts@5 nodemon concurrently typescript@4.9.5 @types/react@18 @types/react-dom@18 @types/node</strong></p><h4>Add the scripts</h4><p>Open package.json and add <em>“type”: “module”</em> together with three scripts. The <em>“type”</em> field is required because the Express code uses import statements; without it Node fails with ‘Cannot use import statement outside a module’. It also explains why the CRACO config has the <em>.cjs</em> extension — that file uses <em>require()</em>, so it has to stay CommonJS.</p><pre>// package.json<br>{<br>  &quot;type&quot;: &quot;module&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;server&quot;: &quot;nodemon src/server/index.js&quot;,<br>    &quot;client&quot;: &quot;craco start&quot;,<br>    &quot;dev&quot;: &quot;concurrently \&quot;npm run server\&quot; \&quot;npm run client\&quot;&quot;<br>  }<br>}</pre><p>What each script does: server starts the Express proxy under nodemon, client starts the CRACO dev server, and dev uses concurrently to run both at once, with their log output interleaved in one terminal. Pressing Ctrl+C stops both.</p><p>By default nodemon watches the whole project and would restart the proxy (and drop its cached token) every time you edit a React file. Restrict it to the server folder by creating nodemon.json next to <em>package.json</em>:</p><pre>// nodemon.json<br>{ &quot;watch&quot;: [&quot;src/server/&quot;] }</pre><h4>Load the lineage stylesheet</h4><p><em>public/index.html</em> is the HTML template react-scripts serves. The lineage viewer relies on a global stylesheet that this page has to load: the <em>&lt;link&gt;</em> to <em>/lineage/css/common.css</em> in <em>&lt;head&gt;</em>. The request goes to your dev server first and is forwarded to watsonx by the <em>/lineage/css</em> proxy rule from Part 2 — this is the other half of the ‘no styles’ pitfall described below. A minimal file looks like this (there is no <em>&lt;script&gt;</em> tag; Webpack injects the bundle):</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot; /&gt;<br>    &lt;title&gt;My lineage app&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;/lineage/css/common.css&quot;&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;&lt;div id=&quot;root&quot;&gt;&lt;/div&gt;&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Start everything</h3><p><strong>npm run dev</strong></p><p>Open <a href="http://localhost:3001.">http://localhost:3001.</a> The Webpack dev server forwards <em>/lineage/*</em> to Cloud Pak and <em>/proxit</em> to your Express server. Render your LineageViewer component with a valid assetId and containerId and you should see the IBM lineage graph appear inside your app.</p><h3>Summary</h3><p>Here is what you built:</p><p>1. An Express proxy server that fetches a bearer token from IBM, caches it, refreshes it every 59 minutes, and attaches it to every API request the lineage viewer makes.</p><p>2. A Webpack ModuleFederationPlugin host configuration that marks React as a shared singleton and routes lineage static assets through your dev-server proxy.</p><p>3. A LineageViewer React component — either using the <strong>@ibm/federated-component</strong> package (Option A, ~30 lines) or built from scratch with useDynamicScript, loadComponent, useFederatedComponent, and ErrorBoundary (Option B, ~80 lines).</p><p>4. A single npm run dev command that starts the Express proxy and the Webpack dev server together, with the dev server forwarding /proxit to Express so the browser only ever talks to one address.</p><p>The result is the full <strong>IBM watsonx lineage graph</strong> running live inside your own React application, with your credentials safely managed server-side.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820841874245" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>