Wanted to know architecture of how dapp works that uses NodeJs server and frontend. How the whole flow goes?
-
Could you give a specific example?– Jacob Creech ♦Commented Mar 6, 2023 at 3:15
-
Is there any specific architecture for blockchain driven applications which involves different entities ? .....So any specific architecture I can follow– Harry ChoudharyCommented Mar 20, 2023 at 3:58
1 Answer
I came across your post while searching for any new visual Solana dapp reference architectures (there are not many).
I don't know if it helps, I'll give some more info and an example below, somebody might find this useful if it comes up...
Many Solana fullstack (with UI) projects start on a Next.js app and host on Vercel for a front/backend javascript solution. At least in hackathons and startup projects. You can look at Next.js docs if you are unfamiliar with it.
Frontend/backend app - Next.js includes setup for React, view/page routing, server-side API routes, various front/server architectures, and deploying to Vercel in various environments and with serverside secrets. This is usually perfect for Solana UI/API type apps that have up to medium-level (non-webscale) traffic.
Separately, you can create Rust programs (smart contracts) with Anchor and deploy programs to Solana chains (devnet,mainnet-beta etc.).
Connect Fullstack app and Solana chain - You interact and connect the UI with the Solana chain and programs with the Next.js app. Npm install the solana js sdk and solana wallet adapter to interact with the contracts. @solana/web3.js and @solana/wallet-adapter-react - there are a bunch of methods on those you use to connect to the chain, programs and accounts.
There are Solana starter dapps - I used this for Solana Pay and it worked well: https://github.com/pointer-gg/solana-pay-tutorial (see various branches and the webpage for the tutorial) and my walkthrough (I did not write the tutorial, just made notes): https://github.com/csjcode/solana-pay-experiments