Show HN: Structured Cooperation – A new way of building distributed apps & POC
Show HN (score: 10)Description
I wanted to share something I've been working on for the past couple of months, which may be interesting to developers interacting with distributed architectures (e.g., microservices).
I'm a backend developer, and in my 9-5 job last year, we started building a distributed app - by that, I mean two or more services communicating via some sort of messaging system, like Kafka. This was my first foray into distributed systems. Having been exposed to structured concurrency by Nathan J. Smith's beautiful article on the subject (https://vorpus.org/blog/notes-on-structured-concurrency-or-g...), I started noticing the similarities between the challenges of this message-based communication, and that of concurrent programming, and GOTO-based programming before that - actions at a distance, non-trivial tracing of failures, synchronization issues, etc. I started suspecting that if the symptoms were similar, maybe the root cause, and therefore the solution, could be as well.
This led me to design something I'm calling "structured cooperation", which is basically what you get when you apply the principles of structured concurrency to distributed systems. It's something like a "protocol", in the sense that it's basically a set of rules, and not tied to any particular language or framework. As it turns out, obeying those rules has some pretty powerful consequences, including:
- Pretty much eliminates race conditions caused by eventual consistency
- Allows you to recover something resembling distributed exceptions - stack traces and the equivalent of stack unwinding, but across service boundaries
- Makes it much easier to reason about the system as a whole
I put together three articles that explain:
1) what structured cooperation is (https://developer.porn/posts/introducing-structured-cooperat...),
2) one way you could implement it (https://developer.porn/posts/implementing-structured-coopera...), and
3) why it works (https://developer.porn/posts/framing-structured-cooperation/).
I also put together a heavily documented POC implementation in Kotlin, called Scoop (linked in the title). I guess you could call it an orchestration library, similar to e.g. Temporal (https://temporal.io/), although I want to stress that it's just a POC, and not meant for production use.
I was hoping to bounce this idea off the community and see what people think. If it turns out to be a useful way of doing things, I'd try and drive the implementation of something similar in existing libraries (e.g. the aforementioned Temporal, Axon (https://www.axoniq.io/products/axon-framework), etc. - let me know if you know of others where this would make sense). As I mention in the articles, due to the heterogeneous nature of the technological landscape, I'm not sure it's a good idea to actually try to build a library, in the same way as it wouldn't make sense to do a "structured concurrency library", since there are many ways that "concurrency" is implemented. Rather, I tried to build something like a "reference implementation" that other people can use as a stepping stone to build their own implementations.
Above and beyond that, I think that this has educational value as well, and I did my best to make everything as understandable as possible. Some things I think are interesting:
- Implementation of distributed coroutines on top of Postgres
- Has both reactive and blocking implementation, so can be used as a learning resource for people new to reactive
- I documented various interesting issues that arise when you use Postgres as an MQ (see, in particular, https://github.com/gabrielshanahan/scoop/blob/09db323bf6c8a7... and https://github.com/gabrielshanahan/scoop/blob/09db323bf6c8a7...)
Let me know what you think.
More from Show
Show HN: React-like Declarative DSL for building synthetic LLM datasets
Show HN: React-like Declarative DSL for building synthetic LLM datasets
Show HN: UnisonDB – Log-native KV database that replicates like a message bus
Show HN: UnisonDB – Log-native KV database that replicates like a message bus Hi HN,<p>For the past few months, I’ve been building UnisonDB — a log-native database where the Write-Ahead Log (WAL) is the database, not just a recovery mechanism.<p>I started this because every time I needed data to flow — from core to edge, or between datacenters — I ended up gluing together a KV database + CDC + Kafka.<p>It worked, but it always felt like overkill: too many moving parts for even small workloads, and too little determinism.<p>What is it?<p>UnisonDB unifies storage and streaming into a single log-based core. Every write is: • Durable (appended to the WAL), • Ordered (globally sequenced for safety), • Streamable (available to any follower in real time).<p>It combines B+Tree storage (predictable reads, no LSM compaction storms) with WAL-based replication (sub-second fan-out to 100+ nodes).<p>Key Ideas<p>1. Storage + Streaming = One System — no CDC, no Kafka, no sidecar pipelines<p>2. B+Tree-Backed — predictable reads, zero compaction overhead<p>3. Multi-Model — KV, wide-column, and large objects (LOB) in one atomic transaction<p>4. Replication-Native — WAL streams via gRPC; followers tail in real time<p>5. Reactive by Design — every write emits a ZeroMQ notification<p>6. Edge-Friendly — replicas can go offline and resync instantly<p>Performance & Tradeoffs 1. Write throughput is lower than pure LSM stores (e.g. BadgerDB) — because writes are globally ordered for replication safety. Deliberate tradeoff: consistency > raw write speed.<p>2. Still ~2× faster than BoltDB with replication enabled.<p>Tech Details<p>Written in Go<p>FlatBuffers for zero-copy serialization<p>gRPC for streaming replication<p>GitHub: <a href="https://github.com/ankur-anand/unisondb" rel="nofollow">https://github.com/ankur-anand/unisondb</a>
Show HN: A context aware backend for AI coding agents
Show HN: A context aware backend for AI coding agents Hey HN, I’m Hang. Today I’m open-sourcing InsForge, a context aware backend for AI coding agents.<p>When using agents like Cursor or Claude to build applications, they often assume what the backend looks like instead of inspecting it. Without access to the actual backend state, they fall back on outdated information, which leads to concrete issues. For example:<p>1. Storage, edge functions, and database logic are closely connected. Without understanding how these parts interact, existing setups get overwritten and important flows break. 2. Database migrations conflict with foreign keys or miss functions because the agent never inspects the live schema. 3. Recreating tables or adding columns that already exist, which leads to conflicts and failed deploys.<p>These problems are not about the agent’s ability to code. They happen because there’s no structured way for the agent to inspect and understand the actual backend before acting.<p>To address this, I built InsForge, which exposes the backend in a structured way and gives the agent direct control:<p>1. Introspection endpoints for schema, relations, functions, triggers, policies, routes, storage, roles, documentation, logs and events 2. Control endpoints for operations usually done through CLI, dashboards or SQL editors<p>InsForge is a full backend platform that includes:<p>- Postgres - Authentication - Storage - Edge functions - Built in AI-model endpoints (via OpenRouter)<p>On top of this, it exposes structured backend metadata and control capabilities through an MCP server and tools, providing a structured, self-describing interface for agents to inspect schemas, policies, triggers, and docs, and interact with the backend.<p>It’s open source and can be self hosted (<a href="https://github.com/InsForge/InsForge" rel="nofollow">https://github.com/InsForge/InsForge</a>) or try our cloud service at (<a href="https://insforge.dev/" rel="nofollow">https://insforge.dev/</a>).<p>We love feedback!
Show HN: FingerprinterJS – A tiny JavaScript library for browser fingerprints
Show HN: FingerprinterJS – A tiny JavaScript library for browser fingerprints I made FingerprinterJS, a small library with no dependencies that creates browser fingerprints from signals like canvas, WebGL, audio, fonts, userAgent, and screen info.<p>It’s written in TypeScript, lets you enable/disable collectors, add custom data, and includes a simple suspicious-activity score.<p>Would love feedback.
No other tools from this source yet.