How reagent-project/reagent works
Project Type and Purpose
• This is an open-source Clojure/ClojureScript library called Reagent that provides a minimal interface between ClojureScript and React.
• It’s structured as a component library (not a standalone application) with example apps, documentation, test harnesses, and build tool integrations.
Top-Level Component Analysis
• Core library modules (src/reagent, src/clj-kondo): ClojureScript and Clojure namespaces implementing:
• reagent.core – public API
• reagent.dom – renderer bindings
• impl/* – batching, component lifecycle, template processing, utilities
• interop – raw JS interop
• ratom – reactive atom implementation
• Build and configuration:
• project.clj, deps.edn, bb.edn – Clojure build tools
• shadow-cljs.edn, package.json – ClojureScript bundler and npm dependencies
• .github/workflows, CI scripts (run-tests.sh, prepare-tests.sh)
• Documentation and examples:
• doc/, README.md, ROADMAP.md, CHANGELOG.md
• demo/, examples/ – live demos and sample apps built with Reagent
• Pre-rendering and site generation:
• prerender/ and outsite/, site/ – scripts and static assets for documentation site
• Testing environments: test-environments/ and test/ folders – various CLJS/JS runners and Karma setups
Key Architectural Patterns and Relationships
• Library core → React renderer:
• The core namespace defines Hiccup-style syntax and component lifecycle abstractions that compile to React.createElement calls.
• dom namespace connects to ReactDOM (client/server).
• Reactive data flow:
• ratom implements reactive atoms that, upon swap! or reset!, enqueue updates in impl/batching → trigger component re-render.
• Build pipeline:
• Source → shadow-cljs/Lein/CLI build → npm/CLJSJS React dependency → produced JS bundle → examples or docs site
• Extensibility:
• The impl and interop namespaces expose hooks for adding custom renderers or integrations (see doc/ReactRenderers.md).
Detail Level
• Every top-level directory as a component or sub-component.
• Relationships between:
• src/ → build → examples/
• src/ → tests/ → CI
• src/ → prerender/site generation
• Avoid overgeneralization: explicitly label ratom, impl, core, dom, interop.