The tech to go from zero to shipping in just 3 months
Tags: clojure, fulcro, react, javascript
Published: 2020-07-30 01:23:44

As we all know, there are two things no startup ever has enough of: time and money. The constraints are even tighter when you are doing a spin-off as a startup, having to maintain the existing project *and* starting a new one. We are a team of three people, with me as the sole developer, and we started three months ago completely from scratch. On the tech side, I could mainly rely on almost a decade of Clojure experience, and on a framework I haven't used before called Fulcro. Here is what we used:

## Hosting: Google Cloud Services and Cloudinary
I am generally not that much of a fan of clouds, but as a startup, we have a lot of free credits available for Google Cloud, so we opted to just spin up a few machines. I provisioned three [FreeBSD](https://www.freebsd.org) machines using [Ansible](https://www.ansible.com), a build server, a dev server and a production server, and created a managed [PostgreSQL](https://www.postgresql.org) instance. The deployment from the build to the dev and production servers is being done using the gcloud command line tools, as I didn't want to rely on IP addresses. It was quick and hassle-free to set all this up.

Apart from that, we use [Cloudinary](https://cloudinary.com) as our binary storage for PDF and image files used in our product.

## Database: Datomic on PostgreSQL
[Datomic](https://www.datomic.com) is a sophisticated database that handles structuring the data with flexible schemas, uses a [Datalog](http://www.learndatalogtoday.org/) flavour as query language, is tightly coupled with Clojure, and stores the data in time-key-value-action tuples. It marks entries as retracted instead of deleting and keeps track of every change, timestamping it, allowing for "time travel" without any additional software or logic. It is available as a cloud offering on AWS, or as an On-Prem offering for you to self-host. We went with the free single-server license for Datomic Pro for self hosting, using PostgreSQL as storage backend.

## Programming Language: Clojure
[Clojure](https://www.clojure.org), and its sibling ClojureScript, is a modern, functional Lisp. It provides concise code, minimal syntax, and immutable and flexible data structures. The macro system allows for extensibility, and since it compiles to both the JVM and JavaScript, it is possible to write pure-Clojure full-stack programs that even share code between frontend and backend. Dependency handling and compilation is handled using the excellent [Shadow-CLJS](https://shadow-cljs.org/) tool that also supports NPM packages for the frontend.

## Framework: Fulcro
If you have spent any amount of time in the Clojure world, you know that Clojurians usually dislike using frameworks, instead insisting on mixing-and-matching libraries to form the application. Frameworks tend to feel constraining and lock you into a cage. But [Fulcro](http://www.fulcrologic.com) and its [Rapid Application Development](https://github.com/fulcrologic/fulcro-rad) addon is a quite different beast. While there is a certain core you'll want to use in every project, almost everything about it is optional. For example, you can write your frontend in something completely different. But we went with full-stack Fulcro, which is using React underneath to keep data in sync and allows us to use React components whenever we want to. 

RAD comes with powerful functionalities to validate and even generate the database schema (currently, Datomic and SQL backends are available), and based on that is able to generate reports and forms even with subforms to quickly have a way to manage all the data. 

To top it all off, there is an addon for Chromium called [Fulcro Inspect](https://chrome.google.com/webstore/detail/fulcro-inspect/meeijplnfjcihnhkpanepcaffklobaal) that allows you to see the entire normalized in-browser database that keeps the program state, the transactions made and even allows you to run queries.

## Planning: Trello and GitLab Issues
We kept and keep track of what is going on and what we are doing using [Trello](https://trello.com) and [GitLab](https://gitlab.com) Issues. 

For that we made two Trello boards: one for the product planning that is mostly for the higher-level picture and groups features the way it makes sense for the business side of things, and a development board using [the Kanban Template](https://trello.com/templates/engineering/kanban-template-LGHXvZNL) where I create smaller tasks in a way that makes sense to me as a developer, and I link the cards on the development board to the ones on the product board so we don't lose track of each other.

And finally, we are using GitLab Issues for exactly what you'd expect - to keep track of and fix bugs in features that are already developed.

## Development: Spacemacs ;)
At least for now, all code so far of this project has been written in Emacs using the cutting-edge branch of [Spacemacs](https://develop.spacemacs.org/). It provides an excellent Clojure environment thanks to [CIDER](https://cider.mx/), and has ways to integrate GitLab (using the Magit-extension Forge) and Trello (using org-trello). After years of keeping my own Emacs configuration up-to-date I finally made the actually quite small step over to Spacemacs-land, because my config already gravitated towards it anyway, and so far I enjoyed every second with it.

This last thing probably didn't make it significantly faster, and there are great Clojure addons for Vim (Fireplace), IntelliJ (Cursive-Clojure) and VSCodium (Calva), but you know Emacs people - they just have to mention they're using Emacs. :)