Chromia dapp overview
Before we start with code examples, let's take a quick look at the architecture of Chromia and talk a bit about the programming language Rell.
This diagram shows the different layers of a dapp on the Chromia platform:
- Backend: Written in the Rell programming language and deployed on the Chromia platform. It runs on nodes hosted by a decentralized network of system providers.
- State Management: Dapp state is stored in a database managed by the Chromia core software and duplicated across multiple nodes.
- Blockchain: Transactions, when finalized, are stored on the blockchain, which is also duplicated across multiple nodes.
Rell, Chromia's relational programming language, is designed to be easy to learn and convenient to use for any developer. It has many similarities to modern programming languages and uses a relational approach with an efficient and developer-friendly query language.
Rell code is compiled and deployed to a container on the Chromia platform. Each dapp has its own blockchain managed by the Chromia network. When a dapp is deployed, you can send transactions and query data from your dapp frontend. Deploying Rell code automatically creates the necessary tables and relations to hold a dapp's state in a PostgreSQL database, which is automatically managed and duplicated across multiple Chromia nodes. Chromia nodes translate queries and operations in your deployed Rell code into SQL and execute the code as needed using an interpreter or compiler.
You can learn more about the structure of a decentralized app built with Rell here.
Interacting with a Chromia dapp
On Chromia, you interact with your dapp using standard web requests. This approach allows for a familiar and straightforward way to communicate with the blockchain and manage app state. There are libraries, like Postchain Client, to make this even easier by providing functions for dapp interactions. You send signed transactions or read-only queries to a node to either mutate the state or fetch data.
A Chromia node receives your transaction and begins a round of communication among the other Chromia nodes running your dapp (also known as validators). Together, they ensure that a "supermajority" agrees on the transaction's validity before it is executed. When two-thirds of validator nodes agree that the transaction is valid, a consensus is reached, and the transaction is executed. Executing a transaction means that the operations contained in it are performed, which can result in state changes that are applied to the dapp's state database. The transaction is also recorded on the blockchain, ensuring that it is immutable and reflected across all nodes.
This concludes our overview of Chromia's architecture. To learn more, visit here. Next, we will explore some core concepts of Solidity and translate them into Chromia and Rell code.