A server-side framework for Clojure
Define the structure of your application as pure data
Instead of a prescribed file tree, Duct uses a Clojure data structure
in a duct.edn
file to describe how the components of your
application are connected and configured.
{:system
{:duct.module/logging {}
:duct.module/sql {:migrations #duct/include "db/migrations.edn"}
:duct.module/web {:features #{:api}
:routes [["/items" #ig/ref :demo.routes/items]]}
:demo.routes/items {:db #ig/ref :duct.database/sql}}}
Factor out common configuration with modules.
Modules expand out into extra configuration that you can inspect and optionally override. These fulfil a similar role to templates and generators in frameworks based around a file tree.
{:duct.module/logging {}}
{:duct.logger/simple
{:appenders
[{:type :stdout
:brief? true
:levels #{:report}}
{:type :file
:path "logs/repl.log"}]}}
Write the rest of your code in idiomatic Clojure
The top-level keywords in duct.edn
are linked to normal
Clojure functions or multimethods. This code is simpler as it
doesn't need to know how it's connected to the rest of the system.
(ns demo.routes
(:require [next.jdbc :as jdbc]))
(defn items [{:keys [db]}]
(fn handler [_request]
{:body {:items (jdbc/execute! db ["SELECT * FROM items"])}}))
Get a Duct project started in only a few commands
Duct makes it easy to get going. All you need is the
clojure
command-line tool installed.
Once you're set up, read the extensive
documentation to learn how to use this framework.
$ mkdir demo && cd demo
$ curl -Os duct.now/deps.edn
$ clojure -M:duct --setup :duct:git