{"id":32184661,"url":"https://github.com/ferdinand-beyer/init","last_synced_at":"2025-10-21T23:55:22.791Z","repository":{"id":46321566,"uuid":"494761631","full_name":"ferdinand-beyer/init","owner":"ferdinand-beyer","description":"Dependency injection a la carte","archived":false,"fork":false,"pushed_at":"2023-08-07T16:05:26.000Z","size":201,"stargazers_count":57,"open_issues_count":16,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-21T23:55:18.512Z","etag":null,"topics":["clojure","dependency-injection","initialization"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ferdinand-beyer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-21T11:17:24.000Z","updated_at":"2025-01-22T01:24:29.000Z","dependencies_parsed_at":"2023-02-12T02:46:50.697Z","dependency_job_id":null,"html_url":"https://github.com/ferdinand-beyer/init","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ferdinand-beyer/init","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferdinand-beyer%2Finit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferdinand-beyer%2Finit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferdinand-beyer%2Finit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferdinand-beyer%2Finit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ferdinand-beyer","download_url":"https://codeload.github.com/ferdinand-beyer/init/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferdinand-beyer%2Finit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280354180,"owners_count":26316400,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","dependency-injection","initialization"],"created_at":"2025-10-21T23:55:21.616Z","updated_at":"2025-10-21T23:55:22.785Z","avatar_url":"https://github.com/ferdinand-beyer.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# init\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/ferdinand-beyer/init/main.yml?branch=main)](https://github.com/ferdinand-beyer/init/actions)\n[![cljdoc](https://cljdoc.org/badge/com.fbeyer/init)][cljdoc]\n[![Clojars](https://img.shields.io/clojars/v/com.fbeyer/init.svg)][clojars]\n\nInit is a small Clojure framework for **application initialization** and\n**dependency injection**.  It is heavily inspired by [Integrant][integrant]\nand similar to [Component][component], but also draws ideas from popular\nJava projects like [Dagger 2][dagger], [Guice][guice], [Spring][spring]\nand [CDI][cdi].\n\n* [Configuration as data](./doc/README.md#configuration-as-data)\n* [Vars are components](./doc/README.md#vars-are-components)\n* Configuration via [metadata](./doc/README.md#configuration-via-metadata)\n* [Declarative injection specification](./doc/README.md#declarative-injection-mini-language)\n* Runtime and compile-time [classpath scanning](./doc/README.md#classpath-scanning)\n* Component selection via [tags](./doc/README.md#component-selection-via-tags)\n* [Tag hierarchy](./doc/README.md#tag-hierarchy)\n* [Start and stop components](./doc/README.md#start-and-stop-components-in-dependency-order)\n  in dependency order\n* [Small footprint](./doc/README.md#small-footprint)\n* [Modular design](./doc/design.md), pick what you need\n\n**Status**: Alpha.  The concepts should be pretty stable, but API details might\nstill change.\n\n## Rationale\n\nI developed Init because I was unhappy with available solutions in Clojure.\n\n* [Component][component] relies on records and protocols, and has some\n  constraints on what can have dependencies.\n* [Mount][mount] encourages global state with hidden dependencies, and does not\n  support dependency _inversion_ at all.\n* [Integrant][integrant] separates configuration from implementation, which\n  sounds like a good idea at first, but adds complexity in practice.\n\nInit borrows many ideas from Integrant, such as configuration as data, keys\nthat support hierarchy, and system maps, while offering an alternative to derive\nconfiguration from code via metadata.\n\nIn the Java community, there has been a clear transition from file based\nconfiguration (like early Spring's XML configuration) towards annotation-based\nconfiguration, directly in code.  Init suggests that this has proven useful,\nand offers a similar programming experience to Clojure programmers.\n\n## Usage\n\nInit allows you to define components and their dependencies using Metadata on\nvars, and provides a mini-language to customize injected values:\n\n```clojure\n(defn read-config\n  {:init/name ::config}\n  []\n  (edn/read-string (slurp \"config.edn\")))\n\n(defn database\n  {:init/inject [[:get ::config :db-uri]]}\n  [uri]\n  (db/connect uri))\n\n(defn handler\n  {:init/inject [:into-first {:db ::database}]}\n  [{:keys [db] :as request}]\n  (resp/response (query-status db)))\n\n(defn start-server\n  {:init/inject [::handler [:get ::config :port]]}\n  [handler port]\n  (jetty/run-jetty handler {:port port}))\n\n(defn -main []\n  (-\u003e (discovery/from-namespaces [*ns*])\n      (init/start)\n      (init/stop-on-shutdown)))\n```\n\nWhile [configuration via metadata](./doc/metadata.md) is preferred and\ndistinguishes Init from other solutions, it is completely optional.\nInit has a [modular design](./doc/design.md), and allows you to mix and\nmatch different approaches for configuration, discovery and component\nlifecycle.\n\nHave a look at [Init's design](./doc/design.md) to find out more.\n\n## Installation\n\nReleases are available from [Clojars][clojars].\n\ndeps.edn:\n\n```\ncom.fbeyer/init {:mvn/version \"0.2.96\"}\n```\n\nLeiningen/Boot:\n\n```\n[com.fbeyer/init \"0.2.96\"]\n```\n\n## Documentation\n\n* [Articles and API Docs][cljdoc] are hosted on **cljdoc**\n* [Example projects](./examples/)\n* [Changelog](./CHANGELOG.md)\n* You can also browse the [`doc/`](./doc/) folder\n\n## License\n\nDistributed under the [MIT License].  \nCopyright \u0026copy; 2022 [Ferdinand Beyer]\n\n[cdi]: https://www.cdi-spec.org/\n[cljdoc]: https://cljdoc.org/jump/release/com.fbeyer/init\n[clojars]: https://clojars.org/com.fbeyer/init\n[component]: https://github.com/stuartsierra/component\n[dagger]: https://dagger.dev/\n[guice]: https://github.com/google/guice\n[integrant]: https://github.com/weavejester/integrant\n[mount]: https://github.com/tolitius/mount\n[spring]: https://spring.io/\n\n[Ferdinand Beyer]: https://fbeyer.com\n[MIT License]: https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferdinand-beyer%2Finit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fferdinand-beyer%2Finit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferdinand-beyer%2Finit/lists"}