---
# System prepended metadata

title: Rif Relay MonoRepo -> MultiRepo Proposal

---

# Rif Relay MonoRepo -> MultiRepo Proposal

### Introduction

This document aims to propose a way to change the current Rif Relay project structure from mono-repo to multi-repo. To do so we need to analize the current structure in order to define all the sub-modules and the future repositories.

#### Current project structure

The current structure looks similar to this image

![](https://i.imgur.com/UoJBZpJ.png)

As we can see we have several folders there, but we need to understand the content of these, here is the detail:

* **.cirlceci**: contains the configuration for cloud CI
* **.github**: contains the github configuration
* **build:**: inside are the compiled contracts
* **contracts**: this folder has the contract definitions on solidity
* **dist**: here we have the distributable of the entire project
* **dockers**: contains deprecated docker configurations
* **docs**: it has all the documentation for the relay project
* **jsrelay**: inside this folder we have the compiled relay server ready to be used
* **migrations**: this folder contains all the truffle migrations
* **node_modules**: the default dependencies folder for node
* **patches**: here have all the patches for the truffle and web3 libraries
* **rsknode**: contains the docker files for the rsk node used to test the relay project.
* **scripts**: this folder has all the scripts to interact with the rif relay project
* **src/cli**: here we found all the command line functions (it uses the [commander](https://tj.github.io/commander.js/) library)
* **src/common**: the common folder contains all the shared (between relayclient, relayserver and cli)
* **src/relayclient**: it contains all the client logic to interact with the relay server and the contracts
* **src/relayserver**: it has all the server logic to interact with the contracts
* **src/test**: contains all the tests (client, server, contracts, cli, etc)
* **types**: contains all the typescript custom typing for the project

From all that list we found resources that could be in separated repositories, basically we focus on these:

**contracts**
**src/cli**
**src/common**
**src/relayclient**
**src/relayserver**

The other folders are common to any typescript or javascript project. 

From here we have a few options to separate the project into different repositories.

### First Proposal

This one is strict and it's the best way to manage all the code separately in different repositories and from the perspective of long-term maintenance is a good way to have everything in place from now on. The downside of this is that it takes a lot of work to separate everything right now and the final result could be hard to manage since the amount of repositories.

This proposal is basically to separate all in 5 repositories:

* **rif-relay-contracts**: for the contracts directory, it should have all the contracts, tests and exported members to use from other dependencies.
* **rif-relay-cli**: for the src/cli folder and it will contain all the cli commands logic
* **rif-relay-common**: to contain all the content of the src/common folder, it should also have all the members exported since it's used from other modules.
* **rif-relay-client**: that will contain all the src/relayclient resources and it will act as a library to use to interact with the relay server, it should have all the needed members to interact exported as a library to use externally.
* **rif-relay-server**: that contains all the core/server logic.


## Second Proposal

This one is like the first one but a little more flexible, basically is the same but without **rif-relay-cli** (that could be removed since is not necessary) and **rif-relay-common** (for this one we should duplicate code in the **rif-relay-client** and **rif-relay-server** projects).

This proposal is flexible but it has some downsides, for example we duplicate code and that could be hard to maintain.

Here the repositories are 3:

* **rif-relay-contracts**: for the contracts directory, it should have all the contracts, tests and exported members to use from other dependencies.
* **rif-relay-client**: that will contain all the src/relayclient resources and it will act as a library to use to interact with the relay server, it should have all the needed members to interact exported as a library to use externally.
* **rif-relay-server**: that contains all the core/server logic.

## Third proposal

This proposal is something between the above, here we could have 4 repositories:

* **rif-relay-contracts**: for the contracts directory, it should have all the contracts, tests and exported members to use from other dependencies.
* **rif-relay-common**: to contain all the content of the src/common folder, it should also have all the members exported since it's used from other modules.
* **rif-relay-client**: that will contain all the src/relayclient resources and it will act as a library to use to interact with the relay server, it should have all the needed members to interact exported as a library to use externally.
* **rif-relay-server**: that contains all the core/server logic.

Where we remove the `rif-relay-cli` since is not really necessary in order to make the relay work.

This proposal has the downside that we remove the cli commands but it has only 4 repositories to maintain and it doesn't have any duplicated code.

## Procedure

Regardless which proposal is chosen, we should proceed similar to this:

1. Create the repositories and define the naming
2. Split rif relay code into the created repositories
3. Remove circular dependencies between `relayclient`, `relayserver`, `cli` and `common`.
4. Leave on `common` repository only what's common used by more than 1 module, right now we have a few examples of things on common that are being used only on 1 module.
5. Make sure that all the repositories are usable and are well exported (from typescript perspective).
6. Add linters for each repository and fix the current rules.
7. Make sure that after the split all the repositories work separately and also wired up. The system should work properly after wiring up all the different modules.
8. Take the tests and split them into the different repositories. Right now this could take some work since we have tests for everything (contract, client, server) in the same place.


## What we already have

We started to work on this some time ago and we created the contracts repository, [here](https://github.com/JONAF2103/enveloping-contracts) is the link. There we have the contracts code exported to be used as an interface, we need to do something like that probably but with some improvements (solidity and typescript linters, tests, etc)

### Estimation

This could take 3 weeks.