The restaurant management application as described in Code that fits in your head, but with my personal biases, including being written in Clojure.
- Clone the repo
git clone git@github.com:HughPowell/restaurant.git- Start your REPL
- Use the rich comment block in the
restaurantnamespace to start the service.
Ideally all the following linters and code formatters should be integrated into your development environment for the fastest possible feedback. If that isn't the case then you can run them from the command line.
3 linters are used to check the code of this project clj-kondo,
eastwood
and splint (the successor to kibit). For maximum speed it is assumed the
clj-kondo
pre-built binary
is installed on the system and accessible to your user.
clj-kondo --lint deps.edn src dev infraeastwood and splint don't have pre-built binaries and are therefore run using aliases
clojure -M:dev:test:linters -m eastwood.lintclojure -M:dev:test:linters -m noahtheduke.splintTo lint the infrastructure replace the dev and test aliases with the build or upgade.
The code formatter of choice is cljfmt. This also comes with a pre-built binary which is expected to be installed on the system and accessible to your user.
cljfmt check deps.edn src dev infraTo build the application as an uberjar run
clojure -X:build uberTo run the uberjar
java -jar target/restaurant.jarTo run the uberjar with the OpenTelemetry agent
sudo wget -O /usr/local/lib/opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
java \
-Djdk.tracePinnedThreads=full \
-javaagent:/usr/local/lib/opentelemetry-javaagent.jar \
-Dotel.resource.attributes=service.name=restaurant-dev \
-jar \
target/restaurant.jarTo build the application in a docker container run
docker build --file infra/Dockerfile --network host --tag restaurant:dev .To run the container
docker run --publish 3000:3000 restaurant:devAs much as possible this project follows Vertical Slice Architecture. This means
- all the business logic lives in the
restaurantnamespace and sub-namespaces. - the system itself is defined in the
systemnamespace and sub-namespaces. - any code that is generic enough that it doesn't fit in either of the above lives in the
libsub-namespaces.