# Add modules to your dapp · Tic Tac Toe on Chromia with Rell and Unity · Learn Chromia

> Start applying this by splitting your code into smaller modules. Create a folder at Tic_tac_toe_Rell/src/tic_tac_toe and add a module.rell file to it:

Source: https://chromia.com/learn/tic-tac-toe/module-one/project-structure/incorporate-modules/

Tic Tac Toe on Chromia with Rell and UnityLesson 14 of 20

1. [01Tic Tac Toe on Chromia with Rell and Unity](https://chromia.com/learn/tic-tac-toe/introduction/)
2. [02Set up your project](https://chromia.com/learn/tic-tac-toe/setup/)

Module 1: A Rell backend with FT4 accounts

1. [03Overview](https://chromia.com/learn/tic-tac-toe/module-one/)
2. [04Part 1: Database design, operations and queries](https://chromia.com/learn/tic-tac-toe/module-one/data-modeling/)
3. [05Design the data model](https://chromia.com/learn/tic-tac-toe/module-one/data-modeling/tables/)
4. [06Perform basic operations](https://chromia.com/learn/tic-tac-toe/module-one/data-modeling/basic-operations/)
5. [07Write basic queries](https://chromia.com/learn/tic-tac-toe/module-one/data-modeling/write-queries/)
6. [08Part 2: Set up accounts](https://chromia.com/learn/tic-tac-toe/module-one/create-accounts/)
7. [09Configure FT4 accounts](https://chromia.com/learn/tic-tac-toe/module-one/create-accounts/install-configure-ft4/)
8. [10Authentication with FT4 accounts](https://chromia.com/learn/tic-tac-toe/module-one/create-accounts/authentication/)
9. [11Update tests](https://chromia.com/learn/tic-tac-toe/module-one/create-accounts/update-tests/)
10. [12Part 3: How the dapp project is organized](https://chromia.com/learn/tic-tac-toe/module-one/project-structure/)
11. [13Work with Rell modules](https://chromia.com/learn/tic-tac-toe/module-one/project-structure/modules/)
12. [14Add modules to your dapp](https://chromia.com/learn/tic-tac-toe/module-one/project-structure/incorporate-modules/)

Module 2: The Unity project

1. [15Overview](https://chromia.com/learn/tic-tac-toe/module-two/)
2. [16Set up the project](https://chromia.com/learn/tic-tac-toe/module-two/setup/)
3. [17Project scaffold](https://chromia.com/learn/tic-tac-toe/module-two/scaffold/)
4. [18Link the client to the blockchain](https://chromia.com/learn/tic-tac-toe/module-two/connecting-the-client/)
5. [19Summary and manual testing](https://chromia.com/learn/tic-tac-toe/module-two/summary-and-tests/)

1. [20What next?](https://chromia.com/learn/tic-tac-toe/what-next/)

[Learn](https://chromia.com/learn/)[Tic Tac Toe on Chromia with Rell and Unity](https://chromia.com/learn/tic-tac-toe/)

14 / 20Module 1: A Rell backend with FT4 accounts

# Add modules to your dapp

Start applying this by splitting your code into smaller modules. Create a folder at `Tic_tac_toe_Rell/src/tic_tac_toe` and add a `module.rell` file to it:

src/news\_feed/module.rell

```nolines
module;
```

Then add a file at `src/tic_tac_toe/entities.rell` and move your entity definitions there.

src/main/entities.rell

```
entity game {
    created_by: account;
    created_at: timestamp = get_last_block_time();
    mutable player2_account_rowid: rowid = rowid(0);
    mutable last_step_by: rowid;
    mutable last_step_at: timestamp = get_last_block_time();
    mutable winner: rowid = rowid(0);
    mutable status: game_status = game_status.created;
    mutable slot_1: slot_states = slot_states.free;
    mutable slot_2: slot_states = slot_states.free;
    mutable slot_3: slot_states = slot_states.free;
    mutable slot_4: slot_states = slot_states.free;
    mutable slot_5: slot_states = slot_states.free;
    mutable slot_6: slot_states = slot_states.free;
    mutable slot_7: slot_states = slot_states.free;
    mutable slot_8: slot_states = slot_states.free;
    mutable slot_9: slot_states = slot_states.free;
}
```

Move the import of the `account` entity from the `ft4-library` into `module.rell` as well. Placing it there gives every file in the module access to it.

src/news\_feed/module.rell

```
module;
import lib.ft4.accounts.{ account: account };
import ft4_auth: lib.ft4.auth;
```

Next, add a file in the `src/test/tic_tac_toe` folder and declare it as a module, which creates a new module called `module`:



src/test/tic\_tac\_toe/module.rell

```
@test module;

import tic_tac_toe.{ game, game_status, slot_states };
import tic_tac_toe.external.{ create_game, get_games_by_status, join_game, make_move, get_game_by_id };
import lib.ft4.accounts.{ account: account, auth_descriptor };
import lib.ft4.core.accounts.strategies.open.{ ras_open };
import lib.ft4.test.core. { create_auth_descriptor, ft_auth_operation_for };
import lib.ft4.external.accounts.strategies.{ register_account };
```

To switch your dapp's entry point between the `main` module and the `development` module, change the `module:` tag in the `blockchains` definition of your `chromia.yml` file:

chromia.yml

```
blockchains:
  tic_tac_toe:
    module: main
    moduleArgs:
        lib.ft4.core.admin:
          admin_pubkey: x"023BEE5A479CE5AF31F6F64EDE7BEAD394E92E4D973E1727782DB577A55E878563" # It can be completely random for learning purposes.
compile:
  rellVersion: 0.14.9
database:
  schema: schema_tic_tac_toe
test:
  modules:
    - test.tic_tac_toe
  moduleArgs:
      lib.ft4.core.admin:
        admin_pubkey: x"023BEE5A479CE5AF31F6F64EDE7BEAD394E92E4D973E1727782DB577A55E878563" # It can be completely random for learning purposes.
libs:
  ft4:
    registry: https://gitlab.com/chromaway/ft4-lib.git
    path: rell/src/lib/ft4
    tagOrBranch: v1.2.0r
    rid: x"E96915FD7C9A5DD4E183D86F4A5B4BB5083A7CC1EDEB1465EDFFC926E67C93F6"
    insecure: false
  iccf:
    registry: https://gitlab.com/chromaway/core/directory-chain
    path: src/lib/iccf
    tagOrBranch: 1.87.0
    rid: x"9C359787B75927733034EA1CEE74EEC8829D2907E4FC94790B5E9ABE4396575D"
    insecure: false
```

Your project is now organized with Rell modules. The file structure should look similar to this:

text

```
├── main.rell
├── tic_tac_toe
│   ├── auth.rell
│   ├── entities.rell
│   ├── enums.rell
│   ├── functions.rell
│   ├── mappers.rell
│   ├── module.rell
│   ├── utils.rell
│   ├── require.rell
│   └── external
│    	├── module.rell
│    	├── operations.rell
│    	├── queries.rell
└── test/tic_tac_toe
    ├── create_account_test.rell
    ├── create_full_game.rell
    ├── create_game_test.rell   
    ├── helpers.rell
    ├── join_game_test.rell
    ├── make_move_test.rell
    └── module.rell
```

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Work with Rell modules**](https://chromia.com/learn/tic-tac-toe/module-one/project-structure/modules/)[Next →**Module 2: The Unity project**](https://chromia.com/learn/tic-tac-toe/module-two/)
