No description
  • Nix 52.1%
  • Scala 47.9%
Find a file
2026-07-05 10:39:26 -07:00
.github/workflows Use a Nix derivation to build (#89) 2026-07-05 10:23:14 -07:00
modules Extract the common test suite implementation 2025-06-06 16:24:36 -07:00
project sbt: 1.12.13 -> 2.0.1 (#88) 2026-07-05 07:41:38 -07:00
.scalafix.conf Initial commit 2024-10-14 10:22:18 -07:00
.scalafmt.conf scalafmt: 3.11.0 -> 3.11.1 (#84) 2026-05-16 07:52:14 -07:00
build.sbt scala: 3.8.3 -> 3.8.4 (#85) 2026-06-06 06:27:21 -07:00
default.nix Move test to deps warmup; add package to build (#90) 2026-07-05 10:39:26 -07:00
LICENSE Use a Nix derivation to build (#89) 2026-07-05 10:23:14 -07:00
README.md Add usage docs 2025-06-06 16:33:03 -07:00
sbt.nix Use a Nix derivation to build (#89) 2026-07-05 10:23:14 -07:00
shell.nix scala: 3.7.4 -> 3.8.1 (#63) 2026-02-01 13:56:13 -07:00

Let's build a hit counter using a functional domain model based on the Tagless-Final style and The Clean Architecture.

This project is based on the post F[unctional] Core, IO[mperative] Shell.

Usage

Running the tests

$ sbt test
drivers.mem.MemSuite:
  + example test that succeeds 0.07s
drivers.db.DbSuite:
  + example test that succeeds 0.06s
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2

Running the HTTP server

$ sbt l4_runners/run
[info] running (fork) http.Main 
$ curl localhost:8080/count
1
$ curl localhost:8080/count
2
$ curl localhost:8080/count
3

Layers

The domain is the lowest layer. Each additional layer may access any of the layers beneath it.

.-------------------------------------------.
| LAYER 4: RUNNERS                        o |
|-----------------------------------------|-|
| * Main method with an http server       | |
'-----------------------------------------|-'
                                          |
.-----------------------------------------|-.
| LAYER 3: DRIVERS                     o  v |
|--------------------------------------|--|-|
| * In-memory data store               |  | |
| * RDBMS/JDBC data store              |  | |
'--------------------------------------|--|-'
                                       |  |
impure                                 |  |
=======================================|==|==
pure                                   |  |
                                       |  |
.--------------------------------------|--|-.
| LAYER 2: USE CASES                o  v  v |
|-----------------------------------|--|--|-|
| * Increment and get the count     |  |  | |
'-----------------------------------|--|--|-'
                                    |  |  |
.-----------------------------------|--|--|-.
| LAYER 1: DOMAIN                   v  v  v |
|-------------------------------------------|
| * Entities                                |
|     * Count                               |
| * Operations                              |
|     * Increment the count                 |
|     * Get the count                       |
'-------------------------------------------'