Why I use a monorepo + circleci for Cryptovoxels

Ben Nolan
2 min readMay 21, 2018

--

Cryptovoxels is my ethereum virtual world project, and I built it using largely node.js and typescript.

Cryptovoxels near the origin (0,0) of the world

When I first started working on it, I split it into two git repos:

  • Client: Virtual world client + multiplayer server
  • Website: Website + API server

These felt like quite seperate components to me, but as time went on, I added a bunch of extra functionality to the client repo:

  • Procedural city generator
  • Database migrations
  • Scene serving API

I also ended up duplicating typescript classes between the website and client repos (for example, the Property and Street classes), so pretty soon I was copying code back and forth, and things were getting out of sync.

Babel uses a monorepo, and google famously has some massive monorepos, so I decided to merge my two repos (using git subtree add), and it worked great, now I’ve got one repo, with multiple node.js projects in it, and I can share typescript or javascript modules between the projects.

The next problem was deploying. I had four stages of deployment:

  • Push multiplayer server to heroku
  • Deploy to lambda using serverless
  • Build javascript bundle for webgl client and upload to S3
  • Build javascript bundle for preact website and upload to S3

So the next step was to move to circleci. Circle is a great continuous integration service, so that every time you push to your git repo, it checks out your project and runs your tests.

Setting up the environment for tests on CircleCI

So I set up circle with a postgres and node.js image, run the the tests, and then if the tests pass, and we’re on the master branch, it runs the deployment steps (using an amazon IAM role with specific permissions), so that whenever I merge a feature branch into master and push to github, it is automatically deployed to all the services I use.

I still think the setup that I’ve made for Cryptovoxels is too complex, I’d much prefer it was just a single heroku project instead of lambda + cloudfront + heroku dynos, but for now, I’ve made the deploy simpler and reduced the amount of work I have to do from adding a feature to having it in front of my friends and beta testers.

If you’re interested in virtual worlds and crypto, land sales start in early June.

--

--