Skip to content
NANATEC Delivery + Innovation
Search articles

Why we run MongoDB as a replica set everywhere

Engineering

Even on a laptop. Transactions need a replica set, and we refuse to have a code path that only exists in production.

Wanjiru Mwangi

Engineering Manager

1 min read

Publishing an article writes three things: the article, a revision and an audit event. They commit together or not at all — and multi-document transactions require a replica set.

A single-node replica set

yaml
services:
  mongo:
    image: mongo:8
    command: ["--replSet", "rs0", "--bind_ip_all"]
    ports: ["27017:27017"]

One container, one command to initiate it, and local development behaves exactly like production. CI does the same; a missing database fails the build rather than skipping tests.

Optimistic concurrency

Every update matches on { _id, version } and increments the version. Zero matched documents means someone else won — we surface that, we never overwrite.

  • #MongoDB
  • #Architecture

Keep reading

All posts
Engineering

1 min read

A BFF in front of every frontend

Why our public blog and our dashboard never talk to the API directly — and what the extra hop buys us in security, caching and simplicity.

Amina Odhiambo

Engineering

1 min read

Autosave that never lies

Debounced, serialized and honest: how the editor decides when to say “Saved”, and what happens when two people edit at once.

Amina Odhiambo