<?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 Yash Joshi on Medium]]></title>
        <description><![CDATA[Stories by Yash Joshi on Medium]]></description>
        <link>https://medium.com/@injose.joshi?source=rss-8cb21e979c62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eG6YxceJxNsef-VGaoezMg.jpeg</url>
            <title>Stories by Yash Joshi on Medium</title>
            <link>https://medium.com/@injose.joshi?source=rss-8cb21e979c62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:24:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@injose.joshi/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[The Benchmark Failed Before the Model Did]]></title>
            <link>https://medium.com/@injose.joshi/the-benchmark-failed-before-the-model-did-b0c5b9ec6eff?source=rss-8cb21e979c62------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0c5b9ec6eff</guid>
            <category><![CDATA[benchmarking]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Yash Joshi]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 11:55:38 GMT</pubDate>
            <atom:updated>2026-07-17T14:32:26.103Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFdk9Xl8AYBOVOshcqDicw.png" /></figure><h4>Building trustworthy LLM benchmarks turned out to be harder than breaking frontier coding models.</h4><p>I spent the last few weeks trying to build a benchmark task that a frontier coding model would fail consistently.</p><p>Not a trick question.</p><p>Not a CAPTCHA for LLMs.</p><p>The goal was simple: create tasks that looked like actual engineering work and measure where modern coding agents still struggle.</p><p>The result was not what I expected.</p><p>The benchmark failed four times before the model did.</p><h3>The Goal</h3><p>I wasn’t interested in obscure algorithms or puzzle problems.</p><p>I wanted realistic engineering tasks:</p><ul><li>Backend performance bottlenecks</li><li>Architectural refactors</li><li>Semantic correctness constraints</li><li>Frontend integration complexity</li></ul><p>The benchmark should fail because the model couldn’t solve the task.</p><p>Not because the task was poorly designed.</p><p>Not because the infrastructure leaked information.</p><p>Not because the scoring pipeline was broken.</p><p>That distinction turned out to matter a lot more than I expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBNbDpMJ1ovKhVbZ_EYPLg.png" /></figure><h3>Attempt #1: The Benchmark Lied</h3><p>The first benchmark looked almost perfect.</p><p>A backend performance problem involving repeated database lookups inside a hot path.</p><p>Easy to score.</p><p>Easy to verify.</p><p>Deterministic outputs.</p><p>The model scored <strong>1.0</strong>.</p><p>For a second, I wondered if frontier models had simply gotten better than I expected.</p><p>Then I remembered something I’ve learned the hard way:</p><p><strong>Perfect results deserve suspicion.</strong></p><p>The task wasn’t supposed to be that easy.</p><p>So instead of auditing the model output, I started auditing the benchmark infrastructure.</p><p>The setup was fairly standard:</p><ul><li>An agent container</li><li>An application container</li><li>A shared bind-mounted workspace</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4m12yny08LoBOtuvAZq6lw.png" /></figure><p>When I ran the oracle solution to validate the scoring pipeline, it wrote the reference implementation into the container workspace.</p><p>The bind mount faithfully propagated those writes back onto the host filesystem.</p><p>The next trial started from a “fresh” container that already contained the answer.</p><p>The model wasn’t earning the score.</p><p>It was inheriting it.</p><p>Apparently, my oracle solution had decided to become a very enthusiastic teammate.</p><p>The benchmark wasn’t measuring capability.</p><p>It was measuring contamination.</p><p>The fix was straightforward:</p><ul><li>Bake the workspace into the image</li><li>Remove shared writable volumes</li><li>Destroy the container after every trial</li></ul><p>The lesson was not.</p><p>Docker did exactly what I asked it to do.</p><p>Which, unfortunately, wasn’t what I meant.</p><p>As anyone who’s ever written infrastructure knows, those are two very different things.</p><p>Containerization is not isolation.</p><p>If your benchmark relies on Docker volumes, verify that state cannot escape between trials before trusting any numbers.</p><h3>Attempt #2: I Wrote the Answer Into the Prompt</h3><p>The contamination bug was fixed.</p><p>I reran the benchmark.</p><p>The model still scored 0.95.</p><p>That felt wrong.</p><p>I reread the prompt.</p><p>Nothing.</p><p>I read it again.</p><p>Still nothing.</p><p>Then I had one of those debugging moments.</p><p>You stop looking for the bug…</p><p>and realize <strong><em>you are the bug</em>.</strong></p><p>Eventually I found this sentence:</p><blockquote><em>“The fix belongs in the query layer — a batched SQL shape, and/or a supporting index.”</em></blockquote><p>I stared at it for a second.</p><p>Then it hit me.</p><p>I had written the solution directly into the prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvYy16oRoEcjvPWwJ-0R-A.png" /></figure><p>The model wasn’t solving the problem.</p><p>It was following instructions.</p><p>Which, to be fair, is exactly what language models are supposed to do.</p><p>I stripped the prompt back to symptoms:</p><blockquote><em>The calculator performs repeated queries and has become slow.</em></blockquote><blockquote><em>Improve performance without changing behaviour.</em></blockquote><p>The benchmark immediately became less predictable.</p><p>Some runs failed.</p><p>Others passed.</p><p>The score distribution widened dramatically.</p><p>Oddly enough, that was progress.</p><p>That was the second lesson:</p><blockquote>Most benchmark leakage doesn’t look like leakage.</blockquote><p>It hides in:</p><ul><li>constraints</li><li>hints</li><li>implementation guidance</li><li>success criteria</li><li>“helpful starting points”</li></ul><p>If the prompt describes the shape of the solution, it is probably leaking more than you think.</p><h3>Attempt #3: The Wrong Kind of Difficulty</h3><p>By this point I had fixed contamination and prompt leakage.</p><p>The model was still solving my benchmarks surprisingly often.</p><p>So I tried making them harder.</p><p>First came a clinical quality measure involving medication counts.</p><p>The obvious optimization silently produced incorrect results.</p><p>The model solved it.</p><p>Then came a reference-data caching retrofit involving batching, cache invalidation, and bypass paths.</p><p>The model still got there roughly half the time.</p><p>Then came a clinical reminder engine performing repeated evaluations across nested loops.</p><p>The model solved that too.</p><p>That was when something clicked.</p><p>I had been optimizing for the wrong thing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ejlf3iK2d1XhWfyqTMxNBA.png" /></figure><p>I kept asking:</p><p><strong>Would this be difficult for an experienced engineer?</strong></p><p>The model was asking:</p><p><strong>Have I seen this shape of problem before?</strong></p><p>That realization completely changed how I designed the next benchmark.</p><p>Backend performance tasks have a problem.</p><p>They advertise their own solution.</p><blockquote><em>N+1 problems have a shape.</em></blockquote><blockquote><em>Cache invalidation has a shape.</em></blockquote><blockquote>Cross-loop restructures have a shape.</blockquote><p><em>Apparently my benchmark collection had become a pattern-recognition practice exam.</em></p><p>Once the model recognizes the pattern, most of the search space disappears.</p><p>The implementation details change.</p><p>The solution strategy often doesn’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ou6BXH4OUdJfE1QgLvn6Jg.png" /></figure><h3>Attempt #4: What Finally Worked</h3><p>Eventually I changed problem classes entirely.</p><p>Instead of:</p><blockquote><em>Find the fix.</em></blockquote><p>I switched to:</p><blockquote><em>Apply the fix without breaking everything around it.</em></blockquote><p>The task was deceptively simple:</p><p>Virtualize a shared React DataTable containing roughly 2,000 rows.</p><p>The solution itself was obvious.</p><p>Render fewer rows.</p><p>Easy.</p><p>I believe the technical term for what happened next is:</p><p><em>“Well… that’s weird.”</em></p><p>The difficulty came from preserving the existing behaviour:</p><ul><li>Sticky columns</li><li>Row selection across the full dataset</li><li>Select-all semantics across the full dataset</li><li>Footer totals across the full dataset</li><li>Custom renderers and variable row heights with correct scrolling behaviour</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1onnkgK7OdKKZ7NbzFMlEA.png" /></figure><p>Across four independent runs, the score stayed remarkably consistent:</p><p><strong>0.32, 0.34, 0.35 and 0.37 (median: 0.345).</strong></p><p>The failure mode was remarkably consistent.</p><p>The model successfully virtualized the table.</p><p>But the virtualization container wasn’t made scrollable correctly.</p><p>Selection across the full dataset broke.</p><p>I fixed it.</p><p>Something else broke.</p><p>I fixed that.</p><p>Something else broke.</p><p>At that point I finally had the benchmark I’d been looking for.</p><p>For the first time, I had found a task where recognizing the solution wasn’t enough.</p><p>The challenge wasn’t discovering the fix.</p><p>The challenge was changing one thing without accidentally changing five others.</p><p>Which, in hindsight, sounds suspiciously like software engineering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_49c30v2aqdU-_JsFPX6jQ.png" /></figure><h3>What Changed My Mind</h3><p>Going into this project, I assumed that:</p><blockquote>Hard for humans = hard for models.</blockquote><p>Turns out that equation was about as accurate as my first benchmark.</p><p>Models are extremely good at:</p><ul><li>Recognizing patterns</li><li>Retrieving known solution classes</li><li>Applying familiar refactor strategies</li></ul><p>They are much less reliable when multiple independent constraints interact in subtle ways.</p><p>The failure mode wasn’t:</p><blockquote><em>I don’t know what to do.</em></blockquote><p>It was:</p><blockquote><em>I know exactly what to do and accidentally broke three things while doing it.</em></blockquote><p>That feels a lot closer to where frontier coding models still struggle.</p><h3>A Checklist for Benchmark Authors</h3><p>Before trusting a score, ask yourself:</p><h3>Infrastructure</h3><ul><li>Can state leak between trials?</li><li>Is the environment actually isolated?</li><li>Can the oracle contaminate future runs?</li></ul><h3>Prompt</h3><ul><li>Does the task describe symptoms or solutions?</li><li>Does it leak implementation details?</li><li>Does it accidentally suggest the algorithm?</li></ul><h3>Problem Design</h3><ul><li>Does the baseline code already reveal the fix?</li><li>Is the challenge discovery or integration?</li><li>Does the difficulty survive pattern recognition?</li></ul><h3>Evaluation</h3><ul><li>Is failure consistent?</li><li>Does the model fail for the same reason each time?</li><li>Are you measuring capability or variance?</li></ul><p>Looking back, I wasn’t spending those weeks evaluating models.</p><p>I was evaluating my own assumptions.</p><p>The infrastructure lied.</p><p>The prompt leaked.</p><p>The tasks advertised their own solutions.</p><p>Only after fixing all of that did the benchmark finally start telling the truth.</p><p><strong>The benchmark really did fail before the model did.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaPJ47pK50kvawYt7_RcgQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0c5b9ec6eff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Motivation Myth: How Discipline Outperforms Inspiration]]></title>
            <link>https://medium.com/@injose.joshi/kill-motivation-for-success-the-power-of-discipline-over-inspiration-d06e38fce664?source=rss-8cb21e979c62------2</link>
            <guid isPermaLink="false">https://medium.com/p/d06e38fce664</guid>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[discipline]]></category>
            <category><![CDATA[schedule]]></category>
            <category><![CDATA[consistency]]></category>
            <category><![CDATA[success]]></category>
            <dc:creator><![CDATA[Yash Joshi]]></dc:creator>
            <pubDate>Sat, 21 Sep 2024 16:22:33 GMT</pubDate>
            <atom:updated>2024-09-21T16:49:28.907Z</atom:updated>
            <content:encoded><![CDATA[<p>We live in a world where motivation is often glorified as the key to success. We’re bombarded with motivational videos, quotes, and self-help books designed to ignite that spark within us. But what happens when that spark fades? What happens when the fuel of motivation runs dry, and you’re left with nothing but your willpower? The truth is, that motivation is unreliable. One day, you’re full of energy; the next, you’re drained. So, how do you keep moving forward?</p><p><strong>The Problem with Motivation</strong></p><p>Motivation is a powerful feeling, it can propel you to take that first step. It’s like that adrenaline rush getting you through a marathon&#39;s first mile. But relying solely on motivation is like expecting adrenaline to carry you through the entire race. You’ll inevitably hit a wall.</p><p>Let’s be honest: life is unpredictable, and so is our level of motivation. One day, you wake up full of energy and passion, ready to tackle your goals. The next day, you feel drained and uninspired, and your motivation levels have dipped. So, what happens then?</p><p>This is where many people get stuck. They stop moving forward, waiting for motivation to return. But what if motivation doesn’t come back? This is the trap that countless individuals fall into, equating success with a constant need for motivation.</p><h4>A Conversation That Changed My Perspective</h4><p>Recently, I had an eye-opening conversation with a friend. I was expressing my struggle to stay consistent with certain tasks, attributing it to my dwindling motivation. Here’s how the conversation unfolded:</p><p><strong>Me</strong>: <em>” I am doing it, but to keep doing it continuously takes a different kind of motivation.”</em></p><p><strong>Friend</strong>: ”<em>What motivation? I killed motivation a long time back.</em>”</p><p><strong>Me</strong>: ”<em>What</em>?”</p><p><strong>Friend</strong>: <em>” What is motivation? Today, you’ll have 100% motivation, tomorrow 50%, and the day after 25%, then?”</em></p><p><strong>Me</strong>: <em>” Then what works?”</em></p><p><strong>Friend</strong>: <em>”Schedule. If you have to do it, you do it. You don’t stop because of a lack of motivation. When we learned software and built something, was it because of motivation, or because we just had to?”</em></p><p>This conversation hit me like a ton of bricks. It made me realize how often I had relied on motivation to carry me through projects, workouts, or learning new skills. When motivation waned, I’d procrastinate, waiting for the next wave of inspiration to strike. But that wave is not reliable, and over time, I started to see that this was not a sustainable path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hitXAKHgWv-fTqAn4qnbxQ.jpeg" /><figcaption>Success is built on routine, not motivation. A structured schedule is the key to consistent progress.</figcaption></figure><h4>The Case for Discipline</h4><p>While motivation fluctuates, discipline is steady and dependable. It’s about creating a schedule and sticking to it, regardless of how you feel. When you wake up in the morning and feel like doing nothing, discipline kicks in and reminds you: <em>You have a goal. You have a task. Get it done.</em></p><p>Successful people don’t rely on motivation. They rely on routine, structure, and a system. They understand that if something needs to be done, it gets done, whether they feel like doing it or not. This is the mindset shift that transforms good intentions into tangible achievements.</p><p>Take athletes, for example. They don’t always feel motivated to train every single day, but they do it because they have a goal in mind. They show up, even when they don’t feel like it. Writers, coders, entrepreneurs — they don’t wait for the perfect moment of inspiration. They rely on routine to carry them through when motivation is lacking.</p><h4>Embracing the Mundane</h4><p>Discipline teaches you to embrace the mundane, the repetitive, and sometimes the boring. Success is not glamorous all the time. The road to building anything meaningful — whether it’s a business, a career, or a personal project — is filled with mundane tasks that require you to show up every day.</p><p>When you stop waiting for motivation, you also stop giving yourself excuses. <em>“I’m not in the mood”</em> is no longer an option. Instead, you learn to find value in the process itself. It’s not about feeling excited every day; it’s about showing up and doing the work, even on the tough days.</p><p>If you’ve set a schedule, you’ll do what you planned. If you rely on motivation, you’ll be on an emotional roller coaster that’s impossible to predict.</p><h4>How to Cultivate Discipline Over Motivation</h4><p>1. <strong>Set Clear Goals</strong>: Your goals need to be clear, measurable, and achievable. Vague goals will leave you unstructured, and without structure, you’re more likely to fall into the motivation trap.</p><p>2. <strong>Create a Routine</strong>: Whether it’s working out, writing, or coding, create a daily or weekly routine. Break down tasks into manageable chunks and prioritize consistency over intensity.</p><p>3. <strong>Be Accountable</strong>: Find someone who holds you accountable. When you know someone is expecting you to follow through, you’re more likely to stay disciplined.</p><p>4. <strong>Celebrate Small Wins</strong>: Motivation is not entirely useless. It can provide a boost when you need it, so celebrate small victories to give yourself a psychological edge. However, don’t let motivation be your foundation.</p><p>5. <strong>Focus on Process, Not Results</strong>: Sometimes the result isn’t immediately gratifying. But by focusing on the process and becoming consistent, the results will follow.</p><p>6. <strong>Be Kind to Yourself</strong>: Discipline doesn’t mean you have to be harsh with yourself. It’s important to acknowledge that there will be tough days. The key is to not let those tough days derail you entirely.</p><h4>Why Killing Motivation Leads to Success</h4><p>By killing the need for constant motivation, you free yourself from the pressure of having to feel a certain way to be productive. You learn to trust the process and the systems you’ve put in place. Discipline becomes your guiding force, and as a result, your progress becomes inevitable.</p><p>If success is a car, motivation is the ignition that starts the journey, but discipline is the engine that keeps you moving forward. Master the engine, and reaching your destination is only a matter of time.</p><p>So, the next time you find yourself waiting for motivation, remember: that motivation is fleeting, but discipline is forever. If you want something, put it on your schedule, and do it whether you feel like it or not.</p><p>In the words of my friend: <strong><em>”Karna hai toh karna hai.”</em></strong> If you have to do it, just do it. That’s the real secret to success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d06e38fce664" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Plaid and Dwolla with a Next.js App]]></title>
            <link>https://medium.com/@injose.joshi/integrating-plaid-and-dwolla-with-a-next-js-app-329022a2cd75?source=rss-8cb21e979c62------2</link>
            <guid isPermaLink="false">https://medium.com/p/329022a2cd75</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[dwolla]]></category>
            <category><![CDATA[plaid]]></category>
            <dc:creator><![CDATA[Yash Joshi]]></dc:creator>
            <pubDate>Sun, 28 Jul 2024 10:17:25 GMT</pubDate>
            <atom:updated>2024-07-28T10:18:37.875Z</atom:updated>
            <content:encoded><![CDATA[<p>Integrating financial services like Plaid and Dwolla into a Next.js app can greatly enhance the app’s functionality, especially for handling account retrieval, transaction management, and fund transfers. This blog post will walk you through the setup and integration process.</p><h4>Setting Up Plaid and Dwolla</h4><p>First, ensure you have the necessary environment variables set up in your .env file:</p><pre>#PLAID<br>PLAID_CLIENT_ID=<br>PLAID_SECRET=<br>PLAID_ENV=<br>PLAID_PRODUCTS=<br>PLAID_COUNTRY_CODES=<br><br>#DWOLLA<br>DWOLLA_KEY=<br>DWOLLA_SECRET=<br>DWOLLA_BASE_URL=https://api-sandbox.dwolla.com<br>DWOLLA_ENV=sandbox</pre><p>You can find these keys on Plaid’s and Dwolla’s dashboard.</p><h4>Plaid Integration</h4><p>To start, let’s look at integrating Plaid. This involves setting up the client and creating functions to manage bank accounts and transactions.</p><pre>import { Configuration, PlaidApi, PlaidEnvironments } from &#39;plaid&#39;;<br><br>const configuration = new Configuration({<br>  basePath: PlaidEnvironments.sandbox,<br>  baseOptions: {<br>    headers: {<br>      &#39;PLAID-CLIENT-ID&#39;: process.env.PLAID_CLIENT_ID,<br>      &#39;PLAID-SECRET&#39;: process.env.PLAID_SECRET,<br>    },<br>  },<br>});<br><br>export const plaidClient = new PlaidApi(configuration);</pre><p>Here, we’re using the PlaidApi and Configuration classes from the plaid package. The Configuration class is set up with the necessary credentials and environment settings. The PlaidApi instance, plaidClient, will be used to make API calls.</p><h4><strong>Retrieving Accounts</strong></h4><p>To retrieve accounts from Plaid, create a function that fetches and processes account data.</p><pre>import { getBanks } from &quot;./user.actions&quot;;<br>import { plaidClient } from &quot;../plaid&quot;;<br><br>export const getAccounts = async ({ userId }) =&gt; {<br>  try {<br>    const banks = await getBanks({ userId });<br>    const accounts = await Promise.all(<br>      banks?.map(async (bank) =&gt; {<br>        const accountsResponse = await plaidClient.accountsGet({ access_token: bank.accessToken });<br>        const accountData = accountsResponse.data.accounts[0];<br><br>        // Additional processing...<br><br>        return account;<br>      })<br>    );<br><br>    return parseStringify({ data: accounts, totalBanks, totalCurrentBalance });<br>  } catch (error) {<br>    console.error(&quot;An error occurred while getting the accounts:&quot;, error);<br>  }<br>};</pre><p>In this function, getBanks fetches the user&#39;s linked banks. For each bank, the accountsGet method retrieves account details using the access token. The retrieved account data is processed and returned.</p><h4>Creating Transfers</h4><p>To create a transfer, you’ll need to authorize the transfer first and then create it using the authorized details.</p><pre>import {<br>  TransferAuthorizationCreateRequest,<br>  TransferCreateRequest,<br>} from &quot;plaid&quot;;<br><br>export const createTransfer = async () =&gt; {<br>  const transferAuthRequest: TransferAuthorizationCreateRequest = {<br>    access_token: &quot;your_access_token&quot;,<br>    account_id: &quot;your_account_id&quot;,<br>    funding_account_id: &quot;your_funding_account_id&quot;,<br>    type: &quot;credit&quot;,<br>    network: &quot;ach&quot;,<br>    amount: &quot;10.00&quot;,<br>    ach_class: &quot;ppd&quot;,<br>    user: {<br>      legal_name: &quot;Anne Charleston&quot;,<br>    },<br>  };<br>  try {<br>    const transferAuthResponse = await plaidClient.transferAuthorizationCreate(transferAuthRequest);<br>    const authorizationId = transferAuthResponse.data.authorization.id;<br><br>    const transferCreateRequest: TransferCreateRequest = {<br>      access_token: &quot;your_access_token&quot;,<br>      account_id: &quot;your_account_id&quot;,<br>      description: &quot;payment&quot;,<br>      authorization_id: authorizationId,<br>    };<br><br>    const responseCreateResponse = await plaidClient.transferCreate(transferCreateRequest);<br>    const transfer = responseCreateResponse.data.transfer;<br>    return parseStringify(transfer);<br>  } catch (error) {<br>    console.error(&quot;An error occurred while creating transfer authorization:&quot;, error);<br>  }<br>};</pre><p>Here, TransferAuthorizationCreateRequest and TransferCreateRequest are used to define the transfer authorization and creation requests. First, you create an authorization request and use its response to create the transfer.</p><h4>Dwolla Integration</h4><p>Next, set up the Dwolla client. This client will manage communication with Dwolla’s API.</p><pre>import { Client } from &quot;dwolla-v2&quot;;<br><br>const getEnvironment = () =&gt; {<br>  const environment = process.env.DWOLLA_ENV as string;<br><br>  switch (environment) {<br>    case &quot;sandbox&quot;:<br>      return &quot;sandbox&quot;;<br>    case &quot;production&quot;:<br>      return &quot;production&quot;;<br>    default:<br>      throw new Error(&quot;Dwolla environment should either be set to `sandbox` or `production`&quot;);<br>  }<br>};<br><br>const dwollaClient = new Client({<br>  environment: getEnvironment(),<br>  key: process.env.DWOLLA_KEY as string,<br>  secret: process.env.DWOLLA_SECRET as string,<br>});</pre><p>This code sets up the dwollaClient using the dwolla-v2 package. The getEnvironment function determines whether to use the sandbox or production environment based on the environment variable.</p><h4>Creating Funding Source</h4><p>To create a funding source in Dwolla using a Plaid Processor Token:</p><pre>export const createFundingSource = async (options) =&gt; {<br>  try {<br>    return await dwollaClient<br>      .post(`customers/${options.customerId}/funding-sources`, {<br>        name: options.fundingSourceName,<br>        plaidToken: options.plaidToken,<br>      })<br>      .then((res) =&gt; res.headers.get(&quot;location&quot;));<br>  } catch (err) {<br>    console.error(&quot;Creating a Funding Source Failed: &quot;, err);<br>  }<br>};</pre><p>In this function, the post method of the Dwolla client creates a new funding source for a customer using a Plaid processor token. The response includes the location of the newly created funding source.</p><h4>Creating Transfers</h4><p>To create a transfer between funding sources:</p><pre>export const createTransfer = async ({ sourceFundingSourceUrl, destinationFundingSourceUrl, amount }) =&gt; {<br>  try {<br>    const requestBody = {<br>      _links: {<br>        source: { href: sourceFundingSourceUrl },<br>        destination: { href: destinationFundingSourceUrl },<br>      },<br>      amount: {<br>        currency: &quot;USD&quot;,<br>        value: amount,<br>      },<br>    };<br>    return await dwollaClient.post(&quot;transfers&quot;, requestBody).then((res) =&gt; res.headers.get(&quot;location&quot;));<br>  } catch (err) {<br>    console.error(&quot;Transfer fund failed: &quot;, err);<br>  }<br>};</pre><p>This function creates a transfer by posting to the Dwolla API with the source and destination funding source URLs and the transfer amount.</p><h3>Integrating Everything</h3><p>Now, let’s bring these components together. This involves user authentication, bank account linking, and transaction handling.</p><pre>import { createAdminClient } from &quot;../appwrite&quot;;<br>import { getBanks } from &quot;./user.actions&quot;;<br>import { plaidClient } from &quot;../plaid&quot;;<br>import { dwollaClient } from &quot;./dwolla.actions&quot;;<br><br>export const exchangePublicToken = async ({ publicToken, user }) =&gt; {<br>  try {<br>    // Exchange the public token for an access token<br>    const response = await plaidClient.itemPublicTokenExchange({ public_token: publicToken });<br>    const accessToken = response.data.access_token;<br>    const itemId = response.data.item_id;<br><br>    // Get account data using the access token<br>    const accountsResponse = await plaidClient.accountsGet({ access_token: accessToken });<br>    const accountData = accountsResponse.data.accounts[0];<br><br>    // Create a Plaid processor token<br>    const request = {<br>      access_token: accessToken,<br>      account_id: accountData.account_id,<br>      processor: &quot;dwolla&quot;,<br>    };<br>    const processorTokenResponse = await plaidClient.processorTokenCreate(request);<br>    const processorToken = processorTokenResponse.data.processor_token;<br><br>    // Create a Dwolla funding source using the processor token<br>    const fundingSourceUrl = await createFundingSource({<br>      customerId: user.dwollaCustomerId,<br>      fundingSourceName: accountData.name,<br>      plaidToken: processorToken,<br>    });<br><br>    if (!fundingSourceUrl) throw Error;<br><br>    // Save the bank account details in the database<br>    await createBankAccount({<br>      userId: user.$id,<br>      bankId: itemId,<br>      accountId: accountData.account_id,<br>      accessToken,<br>      fundingSourceUrl,<br>      sharableId: encryptId(accountData.account_id),<br>    });<br><br>    // Revalidate the page path to reflect the changes<br>    revalidatePath(&quot;/&quot;);<br><br>    return parseStringify({ publicTokenExchange: &quot;complete&quot; });<br>  } catch (error) {<br>    console.log(&quot;An error occurred while exchanging the access token:&quot;, error);<br>  }<br>};</pre><p>Here’s a breakdown of this function:</p><ol><li><strong>Exchange the Public Token</strong>: Exchanges the public token from Plaid Link for an access token and item ID.</li><li><strong>Get Account Data</strong>: Retrieves account details using the access token.</li><li><strong>Create Processor Token</strong>: Generates a processor token for Dwolla.</li><li><strong>Create Dwolla Funding Source</strong>: Uses the processor token to create a funding source in Dwolla.</li><li><strong>Save Bank Account Details</strong>: Stores the bank account information in the database.</li><li><strong>Revalidate Path</strong>: Ensures the UI reflects the changes by revalidating the relevant path.</li></ol><p>With this integration, your Next.js app can now manage user authentication, link bank accounts, and handle transactions using Plaid and Dwolla. This setup provides a robust foundation for developing a comprehensive financial application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=329022a2cd75" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>