So, if you've been following my Flow Journey, you know that I've been learning how to build a Decentralized App (dApp) or sometimes called a Blockchain App or Web3 app. I've spent years as a web developer, and sometimes making the leap to a new technology like this is quite hard. You start formulating how you think it works, but you're not quite sure you have it right until you get confirmation from a seasoned developer.
So I thought I would write an article based on my current understanding (which is still in its infancy) of how blockchain app development works. Remember, I'm explaining this from the perspective of a web developer.
Web Development today
So when we look at web development today, there are a lot of options in terms of how your architect your applications, but ultimately, it comes down to 2 main parts: client and server. In web development, the client side is the browser and any code that runs in the browser. We're talking HTML, CSS, and JS (along with any HTML, CSS, and JS frameworks). On the server side, we're talking about server side code that runs to do things like persist data, serve up the client side code, and run processes. When we choose our architecture, there are two popular ways to structure our code:
- Single full-stack application
- Front-End Web App connection to a Server API App
When we talk about a single full stack application, we're talking about a single code base with all our our server side code, database code, HTML, CSS, and JS. An example of this is a full-stack Ruby on Rails application.
When we talk about the second option, we're talking about 2 or more code bases. You have one code base to house all your client side code and another code base to house all your server side code. The client side code only contains HTML, CSS, and JS and maybe some code to actually serve that code up to the user's browser. That client side code then talks to the server code base through a provided API. In this situation, your server code and client code are completely separated.
In this latter case, it's so separate in fact that an entire other company might house your server code and provide fancy services to make it easier to deal with. Firebase is a good example of this. Essentially, Firebase replaces your backend - and gives you fancy ways to control the behaviour of the backend. Need some really custom code to run on Firebase? No problem, they provide Cloud Functions - which is basically code that you provide that will run on the server.
This web app architecture is a good analogy to how blockchain development works.
With Blockchain development, picture that your entire Backend is replaced by a Blockchain. Now there are many blockchain's outthere, but this abstraction generally works for all of them.
As a web developer, you can think of the Blockchain as a backend to a web application. So when you think about storing data in a database in a web application, think about storing that on the Blockchain in a blockchain application. In fact, you can kind of make this analogy for most things in web development:
|Traditional Web Application||Blockchain Web Application|
|Client Side code in HTML, CSS, JS||Client Side code in HTML, CSS, JS|
|Store Persistent Data in Database||Store Persistent Data on the Blockchain|
|Run Backend Code through Server Code/Serverless Functions||Run Backend Code through Smart Contracts|
So, I think the best way to think about blockchain development (if you're a web developer), is that the Blockchain effectively replaces your backend. If you want to store anything in the backend, you're storing it on the blockchain. If you want to interact with any of that data, you need to write Smart Contracts - which is really nothing more than code that runs on the blockchain.
Now, as with everything web related, there are so many other ways to structure this. You can have hybrid apps where your client code makes calls to the blockchain, but that also makes calls to a traditional web app backend. In this case, you're storing some data on the blockchain and some in your own database. But this is true for traditional web apps - you can technically have a front end that connects to many different backends. Either way, blockchain can act as ONE backend if you have many. It's not an all or nothing game.
Another thing to be careful of here, is when I say "Blockchain Development", I'm talking about developing apps that use the blockchain. There is a whole other set of developers who develop the blockchain itself. That is not what I'm talking about.
When I was first navigating Blockchain development, so many concepts alluded me. However, now it's starting to get more concrete and as a web developer, it's comforting to know that your front end skills translate completely. Learning Blockchain App Development is basically like learning a new server side/back end language framework. I would almost liken it to going from a Ruby on Rails Web App with a SQL Backend to developing a React App with a AWS Lambda and NoSQL backend. In that case, all your HTML, CSS, JS knowledge still apply, you just need to learn a new storage and backend code framework.
Hope that clears thing up for some peeps!