It is best to use a Unix-like (*Nix) OS for Blaze development because the whole workflow depends on tools that are not as easily installed on Windows (like GNU Make etc.). If, for some reason, you have to use Windows, it is recommended that you install WSL i.e. Windows Subsystem for Linux. Please check the article How to install Linux on Windows with WSL, if you are new to WSL.
The default Linux distribution (on WSL) is Ubuntu (though it can be changed). If you are familiar with Ubuntu commands on how to install additional packages using sudo apt-get or sudo apt commands, then the same commands work in WSL too.
Since Windows and Linux / macOS handle line endings differently, it's better to follow a consistent line ending approach. Windows uses a combination of a carriage return and a line feed (CR+LF) characters to represent a new line, whereas, Linux / macOS use a single line feed (LF) character to represent a new line. Please check the article How to verify the line ending configuration in a Git repository to configure the correct line endings. Otherwise, everytime you try to commit a file, you'll see unnecessary differences in line endings.
Note: In IntelliJ Idea, you'll notice either LF (which is correct) or CRLF (for Windows, which is incorrect) in the status bar (which shows the Line Separator for the current file).
It is best to globally ignore certain files from Git e.g. IDE specific files or directories. Hence, please create a ~/.gitignore file with the following contents -
.calva
.idea
.vscode
*.imlNow, we need to register this global gitignore file with git, using -
git config --global core.excludesfile ~/.gitignoreBlaze needs at least Java 21. We test with Java versions 21 and 25 in CI. So those are the only two Java versions a developer should use, i.e. Java 21 or 25.
Although any Clojure-aware IDE (Emacs, IntelliJ Idea with Cursive plugin, VS Code with Calva plugin, Vim, VSCodium...) is fine, please make sure that you know how to run module level REPLs using your favorite IDE. If you are not sure of this, then it's best to default to using IntelliJ Idea. You may refer Installing IntelliJ IDEA on Ubuntu if you have any doubts.
The latest LTS/stable releases of:
- nodejs
- GNU Make
- Clojure, with CLI tools
- clj-kondo
- cljfmt:
clj -Ttools install io.github.weavejester/cljfmt '{:git/tag "<latest-stable-release>"}' :as cljfmt - actionlint
- dashboard-linter, only needed to run
make -C modules/monitoring lint-dashboard - Ruby with Bundler, only needed to render the Implementation Guide via
make -C modules/ig publish. The FHIR IG Publisher shells out to Jekyll to assemble the HTML site, and the Makefile installs the Jekyll pinned inmodules/ig/Gemfile.lockon first use. The publisher itself is installed byIG_PUBLISHER_VERSION=<version> IG_PUBLISHER_CHECKSUM=<sha256> .github/scripts/install-ig-publisher.sh, run from the repository root with the version and the checksum pinned in.github/actions/setup-ig-render/action.yml. Building and validating the guide (make -C modules/ig test) needs neither.
Blaze is built as a single Docker image, along with a separate frontend image. There is also an uberjar for standalone use.
The most reliable way to build Blaze is through GitHub CI. When you create a pull request (PR), a Docker image with the label pr-<num> is built. You can use this image after the pipeline completes successfully.
Blaze is written in Clojure, a modern LISP for the JVM.
-
Install SUSHI:
make build-ig
-
Create the uberjar in the
targetdirectory:make uberjar
-
Build the Blaze Docker image:
docker build -t blaze:latest . -
Build the frontend Docker image:
make build-frontend
As for writing code in any LISP in general, the recommended way to hack on Blaze is to use REPL-Driven Development (RDD). This is, to fire up a REPL, connect to it, and evaluate the running system within your IDE as you change it. More information about RDD.
Since Blaze is organized into modules, you can fire up a REPL in either of two ways: from the root directory ("a global REPL") or from the specific module you are currently working on ("a local REPL"). A global REPL is better suited for local end-to-end (E2E) testing, running and exploration - it loads the entire system. In contrast, a local REPL is better suited for focused work on a particular module - it only loads the bare minimum amount of namespaces required to make that module function in isolation. Moreover, local REPLs provide you with a faster feedback loop, since they enable you to eval the module's (unit) tests - something you simply cannot do from a global REPL, since they are not included in its classpath.
You can run a REPL to run Blaze as a system using the following Makefile alias:
make emacs-repl
For more details, see the Makefile, deps.edn, and dev/blaze/dev.clj files.
- add
-Dclojure.server.repl='{:address,\"0.0.0.0\",:port,5555,:accept,clojure.core.server/repl}'to theJAVA_TOOL_OPTIONSenv var - bind port 5555
- create the remote REPL in your IDE, and connect to it.
Developing a new feature will always include writing the corresponding unit and/or integration tests. Whether you write them upfront or after the fact is up to you. That being said, writing them before/while you actually implement a new feature may make it easier to reason about and assess the feature in the works. Whatever the case, the tests will make it easier to ensure that the new feature is implemented correctly, both at module and system level.
This project uses a CI pipeline, which checks:
- unit tests,
- integration tests, and
- code coverage (which should only increase on each commit).
For more details, see the
.github/directory.
The configuration of the development system is done with the same environment variables used in the production system. Documentation: Environment Variables.
- Create a release branch named
release-v<version>, e.g.,release-v0.29.0. - Update all occurrences of the old version (e.g.,
0.28.0) to the new version (e.g.,0.29.0). - Update
unreleasedbadges in the documentation. - Update the
CHANGELOG.mdbased on the milestone. - Create a commit with the title
Release v<version>. - Create a PR from the release branch to
main. - Merge the PR.
- Create and push a tag named
v<version>, e.g.,v0.13.1, onmainat the merge commit. - Copy the release notes from the
CHANGELOG.mdinto the GitHub release.
Follow the Clojure Style Guide, enforced by cljfmt. For more details, check the cljfmt.edn file.
Blaze is primarily implemented using pure functions. Pure functions depend only on their arguments and produce an output without side effects. This makes them referentially transparent, meaning their behavior does not change based on when or how often they are called.
Blaze uses anomalies for error handling, instead of exceptions. Anomalies separate the error context from the error itself without interrupting the execution flow. For more information, see the anomaly module.
Components are entities within Blaze and may have state.
An example of a stateful component is the local database node.
Components reside in a namespace with a constructor function called new-<component-name>.
In production, we use the integrant library to wire all of Blaze components together.
(ns blaze.db.node
(:require
[blaze.module :as m]
[clojure.spec.alpha :as s]
[integrant.core :as ig])
(:import
[java.lang AutoCloseable]))
(defn new-node
"Creates a new local database node."
[dep-a dep-b])
(defmethod m/pre-init-spec :blaze.db/node [_]
(s/keys :req-un [dep-a dep-b]))
(defmethod ig/init-key :blaze.db/node
[_ {:keys [dep-a dep-b]}]
(log/info "Open local database node")
(new-node dep-a dep-b))
(defmethod ig/halt-key! :blaze.db/node
[_ node]
(log/info "Close local database node")
(.close ^AutoCloseable node))new-nodecreates a new local database node with dependenciesdep-aanddep-b.halt-key!`` implementsAutoCloseable` to ensure resources are properly released when the node is closed.m/pre-init-specprovides a spec for the dependency map to ensure correct configuration.ig/init-keyinitializes the node and logs a meaningful message at info level.ig/halt-key!closes the node and releases any held resources.
Every public function should have a spec. Function specs are declared in a namespace with the suffix -spec appended to the function's namespace. Public module-level function specs reside in the src folder, while inner-module public function specs reside in the test folder. This ensures that specs are used in tests but not included in the global classpath, reducing the uberjar and memory footprint.
Avoid using reflection. To enable reflection warnings, add (set! *warn-on-reflection* true) to each namespace with Java interop.