03 / 26Beginner
Rell project structure
Chromia applications are written in Rell, a language built for decentralized applications (dapps). Rell works directly with relational data models, so you can build reliable blockchain applications in a way that feels familiar and efficient. The Rell introduction covers the language in more depth.
Organizing your project
You will split the code across dedicated files inside one folder. This keeps the project readable, easy to maintain, and ready to grow.
Project setup
-
Add a folder for the main module:
- The project has only one module, so create a folder called
mainunder thesrcdirectory. Every file belonging to the module goes here.
- The project has only one module, so create a folder called
-
Create the module files:
- Add these files to the
mainfolder:module.rellentities.rellfunctions.relloperations.rellqueries.rell
You describe your data model in
entities.rell. Eachentityin Rell maps to a SQL table, and keywords likekey,index, andmutablecontrol how that table is stored and queried. See Entity for the full reference. - Add these files to the
-
Declare the module in
module.rell:- Put this code in
module.rell:
src/main/module.rell module;- The
module;declaration marks this file as the module's main file. It marks the folder as a module, so Rell treats all files in it as one unit, which keeps your code organized and easier to manage.
- Put this code in
-
Remove the old
main.rellfile:- The
srcfolder already containsmain.rell. You could keep all your code in that single file, but separate files make the structure easier to follow. Deletemain.rellto complete the reorganization.
- The
The project should now have this layout:
book-review/├── src/│ ├── main/│ │ ├── entities.rell│ │ ├── functions.rell│ │ ├── module.rell│ │ ├── operations.rell│ │ └── queries.rell│ └── test/│ └── book_review_test.rell├── .gitignore└── chromia.ymlEach file has a single responsibility, which keeps the codebase manageable as the application grows. The next sections go through these files one at a time, beginning with entity definitions and building up to a complete decentralized application.