Jacek builds a REST API with three layers: db, handler, and route

In Learn Reitit Pro, Jacek Schae has a three-layered approach to building a REST API. The three layers: db, handler, and route. For the db, he uses next.jdbc with a Heroku-hosted PostgreSQL instance. For the routing layer he uses Reitit and Ring (which uses Java-built’s Jetty). The second layer is just Clojure functions–simple. The routing layer is Ring powered with Jetty assisted with Reitit. Ring’s just a Clojure wrapper for the Java Jetty web server, which accepts http requests and returns http responses. Reitit figures out which function of the second layer to call with the request, and then formats the request suitably for the second layer. The second layer then asks the third layer to manipulate the db. It then returns a value, a message, or an error–always with a status code. Outside of these three responsibilities is setting up the dev environment, testing the API, and deploying it for the outside world (he uses Heroku).