Last used to bootstrap a Metosin project: 2024-11
Confidence level explanation:
- Very high, high: I strongly believe this is the best choice nearly always
- Medium: Should be a good choice, there could be cases where other choices are better
- Low: I'm not sure if this is a good choice, but it solves something
| Lib/feature | Confidence level | Comments |
|---|---|---|
| Integrant | Very high | |
| Reitit | Very high | |
| Malli | Very high | |
| OpenAPI 3 (reitit-openapi) | High | API docs at /api/openapi.json, Swagger UI at /api/docs/. Use OpenAPI 3 instead of Swagger 2 (reitit-swagger). |
| Next.jdbc | Very high | |
| Honeysql v2 | High | Can be useful to generate dynamic SQL queries |
| HugSQL | High | Can be useful when writing SQL by hand |
| hikari-cp | High | |
| Log4j2/Logback | Medium | Current favorite is Log4j2. Logback is also great (and is used in most projects already,) |
| ring-jetty-adapter | ring/ring-jetty-adapter should be good now or http-kit? | |
| Migratus/Flyway | High | Migratus is a good choice. Flyway has been used in many projects so there might be more experience of using it at Metosin. |
| Java.time | High | No need for joda-time |
| Kaocha | Medium | Kaocha for Clj test runner |
| Lib/feature | Confidence level | Comments |
|---|---|---|
| UIx | High | Simple React wrapper makes it easier to use modern React and libs |
| Re-frame | Medium | Even though Re-frame is for Reagent, it is usable with UIx and we have considerable experience using it |
| MUI | Medium? | One solution to writing styles inline in the Cljs components, seems to work relatively well with Cljs |
| Icons | Use JS libs and svg files (for custom icons) | |
| Reitit-frontend | Medium? | Good enough? It is used in most projects already. |
| Malli | High | If/when needed for FE route parameter validation or any other schema validations. |
| Date-fns | Medium | Moment is kind of old now. Closure Library is deprecated. Date-fns is a good choice: much lighter than JS-Joda (~4 kB vs. ~195 kB in the release build when only parsing dates), locales and formatting seem good, works on plain JS Date (millisecond precision). IF the frontend needs the same date types as the backend (LocalDate etc.), JS-Joda is better. This example still uses JS-Joda. |
| MAYBE: TanStack Query | Low? Medium? | Useful abstraction for making calls to backend. Some challenges on using this together with Re-frame (and some with Cljs, but mostly solved.) |
| Test runner | Medium | Shadow-cljs can build unit test artifact, run in browser or with Karma |
| Async helpers: Promesa | High | IF you need lots of async code, Promesa provides nice abstracting and helpers. Avoid core.async. |
Open questions?
- Forms
- Alternative component libs, no experience. Both use Emotion like MUI? So similar
sxprops.- Chakra UI
- Theme UI
- Java 21+ is needed for development and the build (shadow-cljs 3); the backend itself runs on Java 17+ (Ring's Jetty 12 adapter)
- Editors
- Clj-kondo config
- Clojure-LSP config
- cljfmt config: cljfmt defaults (community style
indentation) and
:indent-line-comments? true, plus:extra-indentsfor macros that take a body and for re-frame'sreg-*functions (handler indented like adefnbody).bb formatformats the git-tracked Clojure files,bb format-checkchecks them. Clojure-LSP reads the same config, so formatting from the editor matches. - CI (GitHub Actions): clj-kondo, cljfmt check, Clojure tests against Postgres, ClojureScript tests with Karma, uberjar build
- Dependency submission:
pom.xmlgenerated fromdeps.ednis submitted to GitHub's dependency graph, so Dependabot alerts cover the Clojure deps (npm deps are read frompackage-lock.jsondirectly). Dependabot alerts need to be enabled in the repository settings. The pom is resolved Maven-style (nearest wins), not like tools.deps (newest wins), sodeps.ednlists some transitive deps (e.g. ring-core) directly to keep the graph matching the real classpath.
Branches and pull requests can be used to provide some additional examples for cases we don't want to merge to the master branch. The diff should be kept as simple as possible, so it is easy to merge master changes back the branch.
- Native image
- Example to build a native image of the app
-
Create uberjar:
bb build -
Create docker image:
docker build . -
NOTE: Run uberjar with
java -cp app.jar clojure.main -m backend.main -
AOT compilation of the app code is not enabled, so backend.main class isn't available on the classpath