{"id":17869457,"url":"https://github.com/mrgravity817/cosmic-clojure","last_synced_at":"2025-04-02T22:44:03.397Z","repository":{"id":259641721,"uuid":"860923084","full_name":"MRGRAVITY817/cosmic-clojure","owner":"MRGRAVITY817","description":"Learn how to build your Clojure application using TDD, DDD techniques. ","archived":false,"fork":false,"pushed_at":"2024-10-27T02:16:54.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T22:44:02.011Z","etag":null,"topics":["clojure","domain-driven-design","test-driven-development"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MRGRAVITY817.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-21T14:27:13.000Z","updated_at":"2024-10-27T02:16:57.000Z","dependencies_parsed_at":"2024-10-27T03:22:19.148Z","dependency_job_id":"0c464e84-99e3-4aef-836f-c9ab42b28568","html_url":"https://github.com/MRGRAVITY817/cosmic-clojure","commit_stats":null,"previous_names":["mrgravity817/cosmic-clojure"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MRGRAVITY817%2Fcosmic-clojure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MRGRAVITY817%2Fcosmic-clojure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MRGRAVITY817%2Fcosmic-clojure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MRGRAVITY817%2Fcosmic-clojure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MRGRAVITY817","download_url":"https://codeload.github.com/MRGRAVITY817/cosmic-clojure/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246905830,"owners_count":20852818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","domain-driven-design","test-driven-development"],"created_at":"2024-10-28T10:05:28.645Z","updated_at":"2025-04-02T22:44:03.380Z","avatar_url":"https://github.com/MRGRAVITY817.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cosmic Clojure\n\nHere we learn how to build your Clojure application using TDD, DDD techniques.  \n\nThis repo follows the learning path of the book [Cosmic Python](https://www.cosmicpython.com/) by Harry J.W. Percival and Bob Gregory. The difference is that unlike the book, I've writted the code in Clojure, not in Python.\n\n## Chapter 1: Domain modeling\n\n### Setup\n\nCreate a new Clojure project with the following command:\n\n```bash\n$ mkdir cosmic-clojure\n$ cd cosmic-clojure\n$ touch deps.edn\n```\n\nThe chapter needs some basic libraries:\n- to write \u0026 run tests: `cognitect.test-runner` \n- to modeling the domain data: `malli`  \n\nCopy and paste the following code to `deps.edn`:\n\n```clojure\n{:aliases {:test {:exec-fn     cognitect.test-runner.api/test,\n                  :extra-deps  {io.github.cognitect-labs/test-runner\n                                  {:git/sha \"dfb30dd\", :git/tag \"v0.5.1\"}},\n                  :extra-paths [\"test\"],\n                  :main-opts   [\"-m\" \"cognitect.test-runner\"]}},\n :deps    {metosin/malli       {:mvn/version \"0.16.4\"},\n           org.clojure/clojure {:mvn/version \"1.12.0\"}},\n :paths   [\"src\"]}\n```\n\nNow you're good to go!\n\n### Summaries\n\n- **Domain** is the problem you're trying to solve. Hence the **domain model** is the structure of the data that would be used to solve the problem.\n- In Clojure you can use any schema libraries to build value objects - e.g. malli, schema, etc - since the data is immutable by default.\n- When it comes to entities, it might be tempting to override default operators like `==` (for equality checking) and `\u003e` (for comparison and sorting). \n  But operator overriding is not a good idea in Clojure - just create a simple function for each case like `batch-eq?` or `batch-gt?`.\n\n## Chapter 2: Repository Pattern\n\n### Setup\n\nFrom this chapter, we'll need some kind of database to store our data. I've chosed the [XTDB](https://github.com/xtdb/xtdb), for the sake of it being well adopted among Clojure ecosystem.  \n\nFor using XTDB within our project, add those dependencies to `deps.edn`:\n\n```clojure\n{:deps {;; ...\n        ;; xtdb-api for the main public API, for both remote-client and in-process nodes\n        com.xtdb/xtdb-api {:mvn/version \"2.0.0-b1\"}\n        ;; xtdb-http-client-jvm for connecting to a remote server\n        com.xtdb/xtdb-http-client-jvm {:mvn/version \"2.0.0-b1\"}\n        ;; xtdb-core for running an in-process (test) node (JDK 21+)\n        com.xtdb/xtdb-core {:mvn/version \"2.0.0-b1\"}}\n\n ;; JVM options required for in-process node\n :aliases {;; ...\n           :dev {:jvm-opts [\"--add-opens=java.base/java.nio=ALL-UNNAMED\"\n                            \"-Dio.netty.tryReflectionSetAccessible=true\"]}}}\n```\n\nWe'll use `dev` alias to run our dev repl, running with in-process XTDB node. Run it with the following command:\n\n```bash\n$ clj -A:dev\n```\n\nThen you can now jack into this repl from your IDE. \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrgravity817%2Fcosmic-clojure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrgravity817%2Fcosmic-clojure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrgravity817%2Fcosmic-clojure/lists"}