Building a Multi-Interface DeFi Platform: Architecture Decisions

David JohnDavid John
3 min read

Every developer who wants to start a project from scratch knows that architecture and tech stack choices are critical because when you start the project, it can be almost impossible to make architectural changes anymore. It is similar to deciding on the architectural plan for building your dream home — you stick with what you chose, or you pay dearly… in code :)

So, the first step for me is always to decide on the core parts of my application; other decisions follow suit. Here are the things that I knew I wanted PoolMind to have:

  • Telegram integration: This makes Poolmind accessible to non-native web3 users. Also, a great way to send notifications to users

  • Core AI Agent: This would be the guy in charge of making us money

  • Smart contracts: For visibility, as a treasury, as a way of paying users

  • Orchestrator: A core API that interacts with each of the above services and coordinates things

If you notice, I had no intention of building a frontend for this application; my hopes are about to be shattered.

As per tech stacks, after a bit of time on Google and a lot of time on ChatGPT, I came up with this tech stack

Tech Stack

  • A Python application, running as a service. Its job is to find arbitrage opportunities, analyze them using LLMs (Claude Sonnet), and execute the trades.

  • An Express.js app that acts as the orchestrator. Its job is to communicate and perform actions across other services. I chose Express because it’s fast and asynchronous, which means it can serve many users at once, perfect for PoolMind!

  • A telegram bot that would act as the primary interface. I used the telegraf library to implement the bot interaction. This was also a Node.js app.

  • A Clarity smart contract that manages the pool and provides transparency. This smart contract also mints a custom PLMD token that represents shares in the pool.

Moment Of Clarity

I made many mistakes in this project because of my lack of experience. Here is what I thought the flow of the application would look like:

This flow had 3 major drawbacks, which made it impossible to implement:

  1. Users cannot directly send STX to smart contracts in Stacks

  2. We cannot track the transfer in our database if the user sends from his/her wallet to the smart contract

  3. We cannot guarantee that users will not make mistakes (remember that we are building for non-native crypto users)

To salvage this, I had to create a frontend that allowed users to connect their wallets, to deposit into the pool, and to withdraw from the pool.

But how do I add a React frontend to an Express.js app? 🤷


In conclusion, building a multi-interface DeFi platform like PoolMind involves making critical architectural and tech stack decisions that can significantly impact the project's success. The initial plan, which included Telegram integration, a core AI agent, smart contracts, and an orchestrator, laid a strong foundation. However, unforeseen challenges, such as the need for a user-friendly frontend, highlighted the importance of flexibility and adaptability in the development process. By addressing these challenges and learning from the experience, developers can create a more robust and user-friendly platform. Future posts will delve deeper into the solutions implemented and the valuable insights gained from this project, offering guidance for others embarking on similar endeavors.

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.