# Cerveau: a future-proof web app for notes

I’d like to announce the public beta of Cerveau1, a web app for managing plain-text notes from a GitHub repository. Cerveau integrates directly with Neuron which supports Zettelkasten-style note-taking in Markdown. This very site you are reading is managed by Neuron and edited in Cerveau, and its Git repo is essentially a directory of Markdown files.

## Motivation

I created the open-source Neuron to scratch my own itch, wherein I wanted to maintain my notes for a lifetime, without being dependent on proprietory formats or systems. I still wasn’t totally satisfied however, because I did not want to give up on the convenience of managing notes from a web app on my mobile phone. I didn’t want to be tied to a desktop text editor. So, the idea behind Cerveau was born - which began to resolve that dissatifaction without compromising on future-proofness.

## How does it work?

All notes are written in Markdown, and stored in a Git repository. Cerveau directly modifies the contents of the repository using GitHub Apps API, while caching the latest revision of the repository on a PostgreSQL database. This allows me to edit my notes from a web browser (as well as from a mobile phone), while keeping the canonical version always on Git all the while allowing edits from elsewhere such as Emacs (i.e., two-way sync).

## Technology used

Both the backend and frontend components of Cerveau are written in Haskell. Haskell is my programming language of choice, because it gets a lot of things right (see Why Haskell matters). Software I write in Haskell tends to be reliable; and I can refactor with confidence without being unduly afraid of introducing bugs. This is especially important when dealing with otherwise brittle JavaScript code in frontend code.

### JavaScript is the new assembly language

Cerveau’s frontend too is written in Haskell. Wait, how is that possible? The GHCJS compiler compiles Haskell code to low-level JavaScript for running in the browser. Cerveau uses the Reflex FRP library, via the excellent Obelisk framework, which takes care of all the plumbing required to produce such full-stack Haskell apps, so that I as a developer can focus on the FRP application logic. FRP, and similar models of UI programming, is simpler to write and extend than callback based code. Anybody who writes Elm2 can attest to that; however unlike Elm or PureScript, GHCJS code can be shared with the backend. This is what enables Cerveau to directly reuse much of the Neuron source code, thus enabling neuron’s core features to work directly on the browser–for example, live HTML preview while editing the note.

The editor widget is based on CodeMirror, via reflex-codemirror.

### Real-time communication via WebSockets

WebSockets, via Rhyolite, is used for real-time communication between the backend and the frontend; if you have two windows open, then updating a note from one window will have the other window automatically update its view without an explicit refresh (this works even if you are viewing a different note that has the modified note in its backlinks).

### Nix

Nix is used for both developent and deployment; the production version in particular is deployed to a DigitalOcean droplet running NixOS. Nix makes reproducible development environments easy and possible. A testament to this is how easy it is to contribute to neuron (see CONTRIBUTING.md) - as with one command, nix-shell, you get the full development enviornment including Haskell IDE support starting from a pristine system with nothing but Nix installed.

### Full-Stack Haskell, from Prototype to Production

Much of these technology choices were informed by my working with the folks from Obsidian Systems, whose philosophy is captured in this talk.

## Towards perfecting future-proof note-taking

Making future-proof note-taking awesome is my current goal. LSP support, which facilitates improved note-taking experience in modern editors like VSCode, for Neuron is just one of the several things we can do to move towards that goal.

Where does Cerveau fit in all of this? Cerveau is a “luxury on top”, and a gift to those who help sponsor the open-source Neuron project to realize the aforementioned goal.

www.cerveau.app offers a Free account (limited notes) for anybody to try, as well as a Pro account (unlimited notes) for GitHub sponsors on the “Cerveau Pro Plan” tier or above.

## Will Cerveau be open-sourced?

Although nothing concrete has come up yet, depending on success, (see below) I’m entertaining the idea of eventually open-sourcing Cerveau after a certain level of sponsors.

## What’s next?

Two major features I’d like to see done myself next are:

• Auto-completion of links: typing [[ in the CodeMirror text editor should bring up an autocomplete popup of note titles. Update: pretty much done
• Auto-save: auto-save notes while editing, to provide a Google Docs like feel.

Special thanks goes to the recent sponsors, including Henri Maurer, Peter Iannone, zimbatm, Saif Elokour, Alexander Thaller, Rafael, Cody Goodman, Artyom Kazak and Abhas Abhinav; as well as to Sanjiv Sahayam, Jared Weakly, Alex Chapman and Domen Kožar for feedback on the draft version of this post.

💖

1. “Cerveau” is prounced with the “eau” sounding like the “o” in “Go”. See audio playback.

↩︎
2. Incidentally, the paper Explicitly Comprehensible Functional Reactive Programming compares The Elm Architecture and Reflex Ecosystem’s frameworks.

↩︎