From Telegram Dreams to TurboRepo Reality: Building PoolMind’s Multi-Interface DeFi Architecture

David JohnDavid John
3 min read

At first, I wanted a clean, minimalist setup — just a Telegram bot and a backend. That was it. The dream was simple: users talk to the bot, the backend does all the magic, and everyone is happy.

But then reality came knocking. We needed wallet connections. We needed to call smart contracts. And here’s the kicker — you can’t do that directly from the backend in a smooth way for the user. You need an actual wallet connection from the client side, which meant… yep, a frontend.

The React Era
I knew React, so I reached for React. Felt challenged, but ready.
Of course, reality had more surprises for me.

I had to:

  • Sync environment variables between the frontend and backend (fun times).

  • Figure out how to build the frontend while building the backend.

  • Run both apps in development and still get them to talk nicely to each other.

  • Make Express serve the React app in dev without complaining.

Eventually, I got it working. The flow was simple: the user creates an account in Telegram, wants to connect a wallet, we send them a link with a JWT, frontend grabs it, authenticates to the backend, and links their wallet.

It worked… but the frontend? Ugly. Painfully ugly. The kind of ugly that stares back at you every time you open localhost.

Next.js to the Rescue (Sort of)
I wanted a proper framework. So I moved to Next.js. Added MongoDB, wallet connection, a landing page, NextAuth — the works. Finally, it felt like a “real” app.

Until I realized… You can’t run background jobs in Next.js. No Telegram bot. No long-running jobs. That’s when NestJS entered the chat.

Enter NestJS (and TurboRepo Madness)
I spun up a NestJS app for the backend jobs and bot logic, kept the Next.js frontend, and stuffed them both into a TurboRepo. My old Express app? Yeah… still there. Just chilling in the repo.

In the end, I had:

  • NestJS for orchestration and background jobs

  • Next.js for the frontend

  • Express from the early days (legacy, but still breathing)

  • A Telegram bot running alongside it all

Architecture Diagrams

BeforeOriginal vision: just Telegram bot + backend

User (Telegram)
     |
[Telegram Bot (Node.js, Telegraf)]
     |
[Express.js Orchestrator]
     |
[AI Agent (Python)] --- [Clarity Smart Contracts]

AfterCurrent multi-interface setup

User (Telegram)                     User (Web)
     |                                  |
[Telegram Bot]                   [Next.js Frontend]
     |                                  |
     +--------> [NestJS Backend] <------+
                       |
              [AI Agent (Python)]
                       |
              [Clarity Smart Contracts]
                       |
                   [MongoDB]

Lessons Learned
I won’t lie — the architecture got messy. But with each pivot, I learned what works, what doesn’t, and what definitely shouldn’t be in the same repo.

If I could go back, I’d spend more time upfront thinking about the architecture instead of patching things together mid-flight. But hey, sometimes you have to build the wrong house before you learn how to lay the right foundation.

0
Subscribe to my newsletter

Read articles from David John directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

David John
David John

Professional Biography: In the technology realm, others see code. I see art. My journey as a software engineer is fueled by a steadfast conviction in the power of creativity to transform our world and the ability of technology to unleash human potential. As a self-taught developer from Nigeria, I have taken a unique route fueled by a constant inquiry and an insatiable thirst for invention. I spent my five years as a developer growing from a lone learner to a versatile full-stack developer and enthusiast for artificial intelligence. Today, my technological landscape spans web development, artificial intelligence, and blockchain technologies, each established through learning about multiple frameworks. Technical Skills: In terms of technical skills, I possess a broad breadth and depth. I know multiple programming languages - Python, JavaScript, Ruby, and C - and possess exceptional knowledge of multiple web technologies - React, Next.js, Node.js, Django, and upcoming frameworks. When I approach code development, I don't just think of it as code. I think of it as compositions. Each line of code is like a musical note bringing functionality together to create a symphony. Professional Philosophy: More than skills, I have a vision to create opportunities. Having seen dauntless ambition and unmet creativity in uninviting environments, I believe technology has the possibility of leveling the playing field. I find coding far more relevant than code; to me, it's about giving people a chance to unearth their expression and potential. Current Frontiers: I'm currently digging deep into the intersections of AI, web development and blockchain technologies. My excitement surrounding cryptocurrencies and programmable assets stems from a mindset I have toward a more fluid, easier to access digital ecosystem. I view these technologies as tools for innovation rather than things that are far off in the future.