Clojure Hexagonal Architecture Example.
- Basic components/system setup
- Functions to start/stop/restart system
- Pedestal interceptor to add components in request
- Dev/test system
- Create test structure
- Parse request body
- schema route validation (dev)
- InMemory storage
- Database layer
- Controller layer
- Adapter layer
- Logic layer
- Start the application:
lein run
- Go to localhost:8080 to see:
Hello World!
- Read your app's source code at src/dodecagon/service.clj. Explore the docs of functions that define routes and responses.
- Run your app's tests with
lein test
. Read the tests at test/dodecagon/service_test.clj. - Learn more! See the Links section below.
To configure logging see config/logback.xml. By default, the app logs to stdout and logs/. To learn more about configuring Logback, read its documentation.
- Start a new REPL:
lein repl
- Start your service in dev-mode:
(def dev-serv (run-dev))
- Connect your editor to the running REPL session. Re-evaluated code will be seen immediately in the service.
Docker container support
- Configure your service to accept incoming connections (edit service.clj and add ::http/host "0.0.0.0" )
- Build an uberjar of your service:
lein uberjar
- Build a Docker image:
sudo docker build -t dodecagon .
- Run your Docker image:
docker run -p 8080:8080 dodecagon
- Build and run your image:
capstan run -f "8080:8080"
Once the image it built, it's cached. To delete the image and build a new one:
capstan rmi dodecagon; capstan build