---
title: "Pierre Ricadat (@ghostdogpr) | Hashnode"
description: "Software Architect. Read the latest articles by Pierre Ricadat on Hashnode."
url: "https://hashnode.com/@ghostdogpr"
---

@ghostdogpr

# Pierre Ricadat

@ghostdogpr · Seoul, South Korea · Joined December 2023

Software Architect

## Comments

[ZHE ZHANG I’d rather use Discord since other people can benefit from reading it. Potentially a GitHub issue if it’s specifically about Shardcake.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/681e24bee20965f5d3d4af0f#reply-681ebc73822a1dabc03ebd3c)

Reply · Article · May 10, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[How about discussing on Discord instead of here? Comments are not ideal for long conversations. There’s a Shardcake channel on the ZIO Discord.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/681e24bee20965f5d3d4af0f#reply-681e8b99063d4ea22731e501)

Reply · Article · May 9, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[In our case it has never been a problem (since rolling updates start pods sequentially the pressure is not that high).](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/68101fa388ebcac2ef43f1c1#reply-681d459dd3a3a23a3443d218)

Reply · Article · May 9, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[Right, we are not using Akka persistence and instead use our own code. We're just using https://github.com/typelevel/doobie to communicate with the database. We don't use STM in this part of the code actually, it's all one big state object in memory. When we load an actor, we load the latest snapshot and journals, replay those to have the latest state in memory. Then we serve reads and writes from that. When we need a "fast access" to some data without loading the actor, we have some view tables in the database that are updated via Kafka: after the state is updated and saved in DB we publish some Kafka messages and a separate component reads those and update the views.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/68101fa388ebcac2ef43f1c1#reply-681c7574aadd6478cc7915ca)

Reply · Article · May 8, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[We do use event sourcing and events are written to DB only (we use Kafka to trigger some workflows but with different events and much smaller scale). So our DB usage is very write-heavy indeed. We use CockroachDB which makes it quite easily to scale. Event sourcing is independent from Shardcake: Shardcake provides us actors/entities that are distributed over our servers and addressable by ID, then in each entity we use event sourcing to manage the entity state (via snapshots/journals). So we use both but they are not directly connected.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/68101fa388ebcac2ef43f1c1#reply-6810367cc1fa5d60260fa2b9)

Reply · Article · Apr 29, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[The way we do it is that we have a function liftEvent that "logs" the event but also runs a "transition" that modifies the state. We use a typeclass for Transition\[Event\]. When running the ZPure we get the new state with the list of lifted events and we can write those event to our event store. On replay, we run the same transitions for each event.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/67ada0aa241e6d265ffd7ee3#reply-67adaaa70034f0e755a0e09d)

Reply · Article · Feb 13, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[I usually keep the State common for all my programs. If they are really different entities, I keep the logic completely separate and have them communicate with each other (e.g. via messages).](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/67ad975695477e0a716474d9#reply-67ad9c3fc13bd8ce98ecd3f5)

Reply · Article · Feb 13, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[That's right, that's how we do if we need it. It's non-deterministic but I think it's acceptable since it doesn't cause any actual side effects.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/677fa9708649df594c2445bf#reply-67ad9ba2a14d61a28ab25a65)

Reply · Article · Feb 13, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[Since they return ZIO, you can't use them directly. In our case we often include the current time in the environment R (so we get it before running the ZPure and then the value is consistent during the execution since the environment is read-only). For random, we use Scala Random directly wrapped inside ZPure.suspend.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/677fa9708649df594c2445bf#reply-677fac5778b7eabfce0eb273)

Reply · Article · Jan 9, 2025 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)

[This allows you to handle the actor messages in parallel instead of sequentially (e.g. using mapZIOPar or just forking each message handling). Now depending on the use case that may or may not be desirable. If there would be a lot of contention (each request handling accessing the same objects), sequentially is probably better. In that case you can still use the ZIO/ZPure separation and skip the ZSTM layer. In my use cases (games), we often want to respond to client requests ASAP so parallelizing is better.](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731/comment/66bf817c59e4257e325b582a#reply-66c021508ba5cee8f7e6b7e6)

Reply · Article · Aug 17, 2024 · [The Tri-Z Architecture: a Pattern for Layering ZIO Applications in Scala](https://hashnode.com/posts/the-tri-z-architecture-a-pattern-for-layering-zio-applications-in-scala/66b07c222ac672d4672fe731)
