polylith

yaiba 2026-05-25T21:02:06.581509Z

Hi all, new to clojure and polylith. I saw the polylith example and I have a question, https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app/blob/master/components/user/src/clojure/realworld/user/store.clj, here the user component is using the jdbc, make it hard to switch the database implemtation, what's the best way to structure the database component so I can easily switch to another implementation, say a in-memory atom for testing? do I put the model operations in the database component like this python example did https://github.com/DavidVujic/python-polylith-example/blob/main/components/example/database/message/crud.py?

seancorfield 2026-05-25T21:27:00.463099Z

You can use H2 in-memory with JDBC. The Polylith variant of my usermanager example app uses H2 for tests (file-based, but could easily switch to in-memory): https://github.com/seancorfield/usermanager-example/blob/polylith/components/schema-fixture/src/usermanager/schema_fixture/core.clj while the regular app uses SQLite https://github.com/seancorfield/usermanager-example/blob/polylith/components/schema/src/usermanager/schema/core.clj

🙏 1
seancorfield 2026-05-25T21:28:56.876759Z

Using Component is a nice way of being able to both support a start/stop stateful resource and also being able to easily swap implementations for testing.

yaiba 2026-05-25T21:29:19.881249Z

oh didn't know I can do H2

yaiba 2026-05-25T21:30:32.372999Z

Just for excerise, what If I really want to switch to atom hh, does it mean I need to implement something like a user_repository protocol?

seancorfield 2026-05-25T21:30:42.871229Z

Even with PostgreSQL, there's a full in-memory implementation you can use for testing. See how next.jdbc handles that for an example of the test dependencies you need etc.

seancorfield 2026-05-25T21:31:35.437409Z

I don't think it's worth the overhead of trying to switch to a repository pattern just to use an atom when there are JDBC-based in-memory and local file options available.

seancorfield 2026-05-25T21:32:10.744009Z

In OO-land, you kind of have to do that pattern-based swap, but no reason to do it in Clojure, IMO.

yaiba 2026-05-25T21:32:58.835959Z

got it, I guess I'm still the mind shift period 😅. Thanks for the answer. Also your example repo is more up to date, I'll use it more often for reference

seancorfield 2026-05-25T21:33:34.869469Z

Even in the XTDB variant of the usermanager app (non-Polylith), I use an in-memory version for testing, and a regular version (Docker or cloud-based) for "production-like" behavior.

seancorfield 2026-05-25T21:34:40.351829Z

We have a pretty massive Polylith repo at work -- 200+ components, 20+ bases -- and I maintain next.jdbc, HoneySQL, and three variants of the usermanager example app 🙂

👀 1
yaiba 2026-05-25T21:36:06.806799Z

cool, yeah I think I read the story at your work and I decide to give Polylith a try hh

seancorfield 2026-05-25T21:36:59.923599Z

Cool. And welcome to Clojurians! 🙂

🫡 1
seancorfield 2026-05-25T21:37:14.458369Z

(I'm also one of the Admin team here)

yaiba 2026-05-25T21:38:50.454589Z

Thank you so much

tengstrand 2026-05-27T06:43:57.789259Z

Happy to see one more Polylith user! polylith

🤠 1