Skip to content

MongoDB: self-hosted primary, Atlas as edge

Status: plan only (2026-12-04). Nothing in Atlas or in any service was changed, resized, paused or migrated to write this page. Owner decisions it implements: Atlas is not retired and stays as the smaller edge database (2026-11-11); the primary moves to a self-hosted MongoDB Community on the homelab (2026-12-04). Tracking issue: nyuchi/nyuchi-docs#182.

How to read the evidence. Each fact is marked Verified (read from a repository, a public page fetched on 2026-12-04, or a read-only probe, with the source named) or Unverified (could not be checked; the owner or a later step must confirm). Atlas billing is delinquent and the Atlas Admin API answers 402 Payment Required (“Public API access isn’t enabled for this group or organization because it is delinquent”, seen on 2026-12-04 through the Atlas MCP), so the cluster’s own configuration, size and bill could not be read. Section 11 lists exactly what to export from the Atlas console once billing is fixed.

  1. Step zero is a fresh, verified export of Atlas, and it must not wait for billing. The data plane still answers (the ingestion app reports "mongodb":"connected" on GET https://mukoko-news-api.fly.dev/health, 2026-12-04), so a mongodump with a read-only database user works today even though the Admin API does not. A delinquent Atlas organisation can be suspended and its data removed after a grace period whose length is Unverified. Take the dump first, fix billing second.
  2. Go ahead, in domains, with the news domain last. Self-hosted MongoDB Community 9.0 with mongot (Search and Vector Search for Community went generally available on 2026-06-30) covers every Atlas-only feature the estate uses that matters. The one thing not replaced is mongosync, which MongoDB does not support for Community, so the sync between primary and edge is a small Rust change-stream service (section 6).
  3. The cash saving is modest; the real saving is the growth you avoid. Realistic range: about $50 to $150 a month against today’s M20 (assumptions in section 8), and $250 to $650 a month avoided against the M30 and M40 steps the news corpus was heading for. Do not sell this as a large saving. Sell it as control, no ceiling on storage, and search that is not priced per tier.
  4. The homelab as it is today cannot honestly give a 3-member replica set across failure domains. One Proxmox host pve is one failure domain (power, disk controller, motherboard, internet line). The minimum honest design needs two more small machines (section 3). Until they exist, the minimal option is a degraded one, and Atlas must stay a full copy, not a subset.
  5. Latency is the largest unexamined risk. The home network reports in Singapore time. If the homelab really is in Singapore, a round trip to Johannesburg or Cape Town is of order 250 to 350 ms (an estimate to measure, not a measured figure). Every service that reads the database from Africa on a request path must therefore keep reading the Atlas edge in af-south-1, which is the strongest argument for the edge design in this page.
Fact Status Source
One Atlas project “Nyuchi Platform” (6989ca17b7b03d132b6deb78) with one cluster, nyuchi-platform-doc-db Verified 2026-12-04 Atlas MCP atlas-list-clusters
Tier M20, AWS af-south-1, MongoDB 8.0; filesystem 7.3 GB used of 10.6 GB on 2026-10-02; news 2.42 GB on disk, 4.59 GB uncompressed; news.articles average document about 20.8 KB Verified (measured 2026-10-02) nyuchi/data-infra docs/cassandra-and-janusgraph.md
One database per domain; 25 domains in the catalogue (captured 2026-09-23), 4 views, 65 collections without a validator Verified nyuchi/api-gateway db/spine/catalog/mongo_catalog.json
About 596,000 articles in news after the Doris mirror was removed on 2026-11-22 Unverified (an owner-session note, not read from the cluster) Estate notes
Replica set (M20 is a 3-node replica set), no sharding, no global cluster Unverified for node count; sharding is impossible below M30 MongoDB Atlas tier rules
List price: M10 $0.08/h, M20 $0.20/h, M30 $0.54/h; Flex $8 to $30 a month, 5 GB cap, MongoDB 8.0 or later. The page does not state a region and says af-south-1 costs more Verified 2026-12-04 mongodb.com/pricing, Flex limitations
On 2026-10-02 app reads saturated the M20; the fix since then is “one API in front of the database” (api-gateway/docs/architecture/data-access.md) Verified api-gateway docs
Client Runs on How it reaches Atlas today Source
nyuchi-api (Python gateway, MONGODB_URI, plus Rust crates in rust/) Fly nyuchi-api, jnb mongodb+srv:// over the public internet with allow-listed IPs (Unverified: the allow list) api-gateway/.env.example, gateway/lib/mongo.py
nyuchi-servers-api (Rust, MONGODB_URI, WEATHER_MONGODB_READ_URI) Fly, internal mongodb:// with a host list. The readiness probe rejects mongodb+srv:// (config.rs) nyuchi-servers-api/rust/crates/origin/src/config.rs
mukoko-ingestion-pipeline fly-worker (Motor), enrichment-agent (TS Worker) Fly mukoko-news-api; Worker Motor with socket, pool and wait-queue timeouts (set after the 53-day stall); the Worker uses src/services/mongo.ts fly-worker/src/services/mongodb.py
mukoko-news-gateway Cloudflare Worker Native mongodb driver under nodejs_compat, one connection per request (a Worker cannot keep a connection); measured 1.5 to 3.6 s setup from IAD services/MongoService.ts, wrangler.jsonc
mukoko-news (reader) Vercel mongodb driver in server code, direct (the plan is to route reads through the API) mukoko-news/package.json, src/lib/mongodb/
kweli Vercel MongoClient, pool 10, serverSelectionTimeoutMS 5 s kweli/lib/mongodb/client.ts
mukoko-weather Rust Workers Cloudflare Workers Reads: a hand-written read-only client (weather-mongo: OP_MSG over the Worker’s TLS socket, SCRAM-SHA-256). Writes: a TypeScript Durable Object mongo-bridge reached only by service binding, holding one warm MongoClient mukoko-weather/workers/README.md, mongo-bridge/src/index.ts
mongodb-mcp, nyuchi-mcp-data-infra, fly-mcp (becoming one Rust data MCP) Cloudflare Workers Native driver under nodejs_compat (nyuchi-mcp-data-infra/wrangler.toml) repos
nhimbe, mukoko services/*, shamwari gateway Next.js / Workers mukoko/services/_template has a stub (“implement when the driver supports Workers”); shamwari/gateway says the Worker never talks to Mongo and calls the Servers API instead repos

Answers to the edge questions. (a) The Atlas Data API was removed on 2026-09-30 (MongoDB EOL notice); nothing may depend on it. (b) Hyperdrive in this estate fronts Postgres only (nyuchi-relational, wrangler.jsonc); it is not used for Mongo, and the Cloudflare docs read for this page describe it for SQL databases (Unverified for Mongo: no source found either way). (c) Workers reach Atlas today by three routes: the native driver under nodejs_compat (news gateway, MCPs), a Durable Object bridge (weather writes), and a hand-written OP_MSG client over a Worker socket (weather reads). All three need a publicly reachable TLS endpoint, which Atlas provides and a home network must not.

Option Members What it survives What it does not Verdict
A. Three machines (recommended) edoras on pve; helms-deep on a second small machine; dunharrow on a third, different power strip or UPS if possible A whole machine, a disk, a reboot-to-patch without downtime (rolling), an OS upgrade The house: power, internet line, fire. Offsite backup plus the Atlas edge cover that Needs two more machines (about $450 to $700 each, section 8)
B. Minimal honest: one host Two data-bearing members and one voting member of a third kind on pve, on separate disks (ssd2 and hdd1 are separate drives; local-lvm is on sda) A disk, a mongod crash, a bad upgrade of one member The host, the power, the line. There is no failure domain: a host loss is an outage plus a restore Acceptable only as a lab or as a few weeks of transition. Keep Atlas as a full copy
C. Single mongod One member Nothing by itself Anything. RPO is the backup interval Do not run production here. Use it only for the restore-test target

The Mac mini is not a member: it hosts the agent session, runs macOS with Local Network privacy limits, and sleeps. Do not place a voting member on it. The pve host is an ASUS P8B75-M board (LGA1155, DDR3, SATA disks, VT-x was disabled in the BIOS on 2026-11-22, which is why VM gondor could not start). Whether it still is, how much RAM is installed and which CPU is fitted are Unverified; confirm before sizing. LXC containers do not need VT-x, VMs do.

Names follow the estate rule (Lord of the Rings, Ubuntu LTS plus Ubuntu Pro on every VM and LXC container, hostnames under nyuchiservers.com, internal DNS only, no public record):

Name Role Where (target)
edoras mongod member 1 (priority 2) pve
helms-deep mongod member 2 (priority 1) second machine
dunharrow mongod member 3 (priority 1) third machine
lorien mongot (Search and Vector Search), one per search-serving member, starting with one beside edoras pve, later per member
bag-end backup target (ZFS dataset, restic repository), restore-test runner pve spinning disk hdd1; offsite copy to R2
gwaihir WireGuard gateway for remote clients (section 4) pve, Workloads VLAN
anduin Rust change-stream replicator to the Atlas edge (section 6) Apps VLAN, near gondor

mongod is not run in Coolify and not as a container on gondor: a database wants a plain systemd service on its own VM or LXC container with its own disk, so a Coolify redeploy can never touch it.

  • Verified (2026-12-04): MongoDB 9.0 is the current stable release (9.0.0 on 2026-09-28; 9.0.4 on 2026-10-13 was the latest patch seen), 8.3, 8.0 and 7.0 are previous stable. Community self-managed gets major releases and, from 9.0, the annual feature update; it no longer gets rapid minor releases (versions page).
  • Verified: mongot Community went GA as v1.70.1 on 2026-06-30; the newest release read is v1.79.1 (2026-11-18, mitigating a JVM CVE on CPUs with AVX-512 VBMI; restart required) (release notes).
  • Unverified: the minimum mongod version mongot Community needs at GA (the 2025 preview needed 8.2 or later). Target 9.0.x, a patch at least two releases past its x.0 (so 9.0.6 or later at M2), and confirm the compatibility page before building. Atlas runs 8.0 today, so the first restore from Atlas into 9.0 is a major upgrade by restore; test it in M2 with the real dump. Set feature compatibility version to 9.0 only after one week of soak.

Today’s data is small. Measured 2026-10-02: 7.3 GB on the M20. Assume 15 to 25 GB of data now (Unverified, with the article count above) growing 2 to 4 GB a month while ingest runs at today’s rate and the 30-day window is not enforced. Size for 3 years of growth with search indexes on top.

Item Sizing Reason
mongod VM or LXC container 4 vCPU, 16 GB RAM, WiredTiger cache about 7 GB Working set today is a few GB; leaves page cache. Host board family caps near 32 GB (Unverified), so edoras and lorien cannot both be large
Data volume per member 200 GB, XFS (MongoDB’s recommendation) or ZFS with recordsize=16K, compression=lz4, atime=off, primarycache=metadata for WiredTiger-compressed data Room for 3 years plus oplog plus a dump staging area
Oplog 20 GB (replication.oplogSizeMB), alert when the window is under 24 h Must exceed the longest outage of a member plus the sync-service resume window. News writes about 5,000 to 12,000 articles a day
lorien (mongot) 4 vCPU, 12 GB RAM (JVM heap about 50% up to 30 GB, rest for filesystem cache), disk 2 times the index size, 100 GB to start mongot guidance: heap about 50% of RAM, double the disk for index rebuilds, read-only at 90% disk; 10 QPS per core as a baseline (hardware guide). Quantize vectors: above 3 GB of vector index only about 4% stays in memory
Vector index math 1024 dimensions (bge-m3), float32 = 4 KB a vector; 600,000 articles = about 2.4 GB raw before graph overhead; binary quantization cuts RAM sharply Why the full corpus can live in lorien; on Atlas M10 (2 GB RAM) it cannot
Storage media NVMe for data and mongot if the new machines have it (put WiredTiger journal and data on the same filesystem); SATA SSD is acceptable at this scale; never spinning disk for members pve today has SATA devices only (sda, sdb, sdc; Unverified which are SSD). Spinning disk is fine only for bag-end
LVM or ZFS ZFS mirror on the new machines where two NVMe slots exist (checksums, snapshots, send/receive); otherwise LVM-thin on one NVMe and rely on the replica set for redundancy Replica set already provides redundancy; ZFS adds bitrot detection and cheap snapshots for the backup path
Memory and swap Swap off or vm.swappiness=1; transparent huge pages off; ulimit and vm.max_map_count set per the MongoDB production notes Standard production checklist
  • New Data VLAN 30 (192.168.30.0/24; Unverified that the number is free; VLANs 10, 20 and 3 are used and 192.168.7.0/24 is the VPN). mongod and mongot live only here. No internet route in or out except package mirrors and backup egress.
  • The existing pattern holds: traffic between VLANs only through explicit service bindings (scripts/network/bind.mjs in my-unifi). Bind: Apps VLAN 20 (gondor, Coolify apps) to edoras/helms-deep/dunharrow on 27017; Workloads VLAN 10 to the same only for the exporter and anduin; lorien to mongod members on 27017; Prometheus to exporters.
  • The Cloudflare tunnel and aragorn are not for the database wire protocol. aragorn is an HTTP/TLS front door (Pingora) and the homelab tunnel is published through Cloudflare Access; neither is built for long-lived binary connections with a driver’s own topology discovery (a replica-set client must reach every member by name). Putting 27017 behind them adds a latency and an availability dependency to every query and widens the blast radius of the front door.
  • Private connectivity for the clients that are not on the LAN (Fly while it lasts, Vercel, Workers):
    • Fly apps (nyuchi-api, the Redpanda-side jobs): a WireGuard tunnel from each Fly app’s machine (or a small Fly-side WireGuard peer) to gwaihir, with a pre-shared key on every peer (adds a symmetric layer that protects recorded traffic against a future quantum attacker). Kernel WireGuard is UDP, light, and has no third party in the path. A Tailscale-style mesh is the alternative if the owner prefers managed key distribution; Tailscale terminates in the same place. Because the owner is moving workloads off Fly, treat this as a transition link, not a permanent design: once the callers are on gondor, the link goes away.
    • Cloudflare Workers: do not connect them to the primary. Cloudflare’s Workers VPC can now open a raw TCP socket to a private host through a tunnel or Mesh (connect() on a VPC Network binding, changelog 2026-06-16), but the changelog says it supports plaintext TCP only and does not state a release status. A Mongo driver speaking plaintext, over a tunnel, with SCRAM, to a database that holds the system of record is the wrong trade for a convenience. Workers read the Atlas edge (section 5) or call the Servers API over HTTP.
    • Vercel (mukoko-news, kweli): cannot join a private network. They read the Atlas edge until they are behind the API (the data-access plan already requires this).
  • MongoDB on a public address: never. The edge for the outside world is Atlas plus the API.
Control Design
TLS requireTLS, TLS 1.3 only (net.tls.disabledProtocols: TLS1_0,TLS1_1,TLS1_2), certificates from an internal CA with short lifetimes, rotated by a job; clients pin the CA.
Post-quantum hybrid Unverified for mongod. mongod uses the host OpenSSL; X25519MLKEM768 needs OpenSSL 3.5 or later, which Ubuntu 24.04 does not ship (3.0.x). No MongoDB documentation was found for it. Test at M2 with openssl s_client -groups X25519MLKEM768. Until it works, the post-quantum protection is the WireGuard pre-shared key layer (section 3.4) and a LAN with no untrusted hop. Say so in the DPIA; do not claim PQ on the wire protocol
Authentication Members authenticate each other with x.509 (replacing a shared keyfile; one certificate per member). Services use SCRAM-SHA-256 first (every driver in the estate supports it; the weather client implements it), moving long-lived Rust services to MONGODB-X509 per-service certificates in a later milestone. mongot supports both (x.509 and SCRAM to the sync source in v1.70.1).
Users and roles One user per service per domain database set, never a shared admin. Examples: news-ingest (readWrite on news, engagement), news-gateway-ro (read on news), servers-api (readWrite on its domains), weather-ro, sync-anduin (read on all in the allow-list), backup (the built-in backup role), monitor (clusterMonitor), search-sync for mongot (searchCoordinator). No userAdmin outside a break-glass account whose credential is sealed in erebor. The existing mongodb-mcp already refuses user and role administration; keep that refusal.
Secrets Dev and operations secrets in erebor; service boot-time secrets served by Durin (bundu-labs/durin, platform neutral). No 1Password in the dev path; the owner keeps a sealed copy of the break-glass credential and the CA key as long-term storage only. No secret in a repository, issue or log.
Encryption at rest Community has no native WiredTiger encryption (an Enterprise feature). Use LUKS2 (or ZFS native encryption) on every data and mongot volume; the key is released at boot by erebor, which means a cold boot needs a human or a sealed unlock service. Decision D6 covers the alternative below.
Audit logging Community has no auditLog. Replacement, in layers: (1) every service has its own identity, so the server log attributes each connection and authentication success or failure (the ACCESS component logs at default verbosity); ship mongod logs to Loki with a retention of at least 400 days. (2) The slowms profiler for abnormal reads. (3) Append-only change-stream audit for the sensitive collections (identity.*, platform.apiKeys, entity.*, platform.auditLog): a small Rust tailer writes events to Redpanda and R2 (the event platform already exists). (4) Application audit already in platform.auditLog and the API. If a customer or regulator requires database-level audit with filters, use Percona Server for MongoDB (free, includes audit log, encryption at rest and LDAP; 8.0.28-12 was the latest 8.0 build on 2026-08-10; the 8.3 build is a technical preview). Its trade-off: no mongot was found for it (Unverified), so search would stay on a separate Community mongot node or on Atlas.

Targets: RPO 15 minutes, RTO 2 hours for the whole cluster; RPO 5 minutes, RTO 30 minutes for loss of one member (that is just failover and resync).

  1. Continuous oplog archive every 5 minutes to bag-end and R2 (a small Rust archiver tailing the oplog on a secondary, or Percona Backup for MongoDB if the Percona server is chosen; PBM support for Community builds is Unverified).
  2. Nightly logical dump mongodump --gzip --oplog --readPreference=secondary from helms-deep, per database in parallel, to a ZFS dataset on bag-end; weekly full kept 8 weeks, daily kept 14 days, monthly kept 12 months.
  3. ZFS snapshots of the secondary’s data dataset every hour (WiredTiger journaled on one dataset is crash-consistent), kept 48 hours: the fast path for “undo the last bad migration”.
  4. Offsite: restic to an R2 bucket with Object Lock (immutable for 30 days) and a different credential from the writer. Restic repository password in erebor, with the sealed copy described above.
  5. Restore test, automated, monthly and after every major change: restore the latest dump plus oplog to a scratch LXC container, run validate on every collection, compare document counts and a field checksum on 1% of documents with the live cluster, and check mongot index builds finish. A backup with no passing restore test in the last 35 days is an alert.
  6. Atlas edge is not a backup: it holds a subset and lags. It is a convenience copy for DR of the hot window.
  • Prometheus exporter: Percona’s mongodb_exporter (Apache-2.0) on each member, mongot native /metrics (default localhost:9946, mTLS available since v1.78.0), node_exporter, ZFS and SMART exporters. Scrape through the existing Prometheus.
  • Dashboards and rules ship as a monitoring addon in the estate’s pattern (an nyuchi-org repo, Apache-2.0, private until scrubbed, apps auto-discovered), following grafana-monitoring-pack and nyuchi-monitoring. Name it mongodb-monitoring.
  • Alerts (page on the first four): no primary for 30 s; replication lag over 30 s for 5 min; oplog window under 24 h; disk over 80% (mongot read-only at 90%); backup older than 26 h; restore test failed or older than 35 days; certificate expiry within 21 days; connections over 80% of the limit; WiredTiger cache dirty over 20%; mongot index STALE or FAILED; anduin lag over 60 s; ZFS pool degraded; SMART failing.
  • The same checks feed nyuchi-infra MCP views so the owner can read them from a phone.
  • OS: Ubuntu LTS plus Ubuntu Pro (livepatch, ESM) on every member. Security updates are applied rolling: secondaries first, rs.stepDown() the primary, then the last member. Never patch two members in one hour.
  • mongod: monthly patch release train, one week behind release; major upgrade once a year at most, by FCV after a week of soak, tested first on the restore-test LXC container with a real dump.
  • mongot: track its CVE feed. v1.79.1 shows the pattern: a JVM mitigation that takes effect only after a restart, so each mongot needs a maintenance window and a second mongot for queries during it (start with one and accept a short search gap; add a second when search becomes user-facing from here).
  • Growth triggers: data over 60% of the volume, working set over 70% of the cache, mongot page faults over 1000 a second, p95 write latency over 100 ms. Order of response: archive old news to R2 Parquet (the event platform already archives to R2), add RAM, move the data volume to faster media, dedicate the mongot VM, and only then consider sharding (not planned).

4. Atlas-only features the estate uses, and the replacement

Section titled “4. Atlas-only features the estate uses, and the replacement”
Atlas feature Where it is used (read from repos) Replacement on the self-hosted primary Decision
Atlas Search ($search, $searchMeta, facets) news.articles: three search indexes (names in Atlas, Unverified), news analytics and the search fallback (api-gateway news_corpus.py, ingestion vector_search.py). shamwari ground: ground_text_search (api-gateway/docs/architecture/shamwari.md). nyuchi-servers-api ground/rules.rs mongot Community: the index definition syntax is aligned with Atlas (v1.70.1), $search and $searchMeta work, facets, autocomplete. Tokenisation differences are possible: re-run the 50 recorded queries (data-infra/scripts/news/parity.py) Move to mongot; parity-test first
Atlas Vector Search ($vectorSearch) news.articles index articles_vector_search (related articles; a filter on an undeclared path fails the stage: news_related.py); shamwari knowledge ground_vector_search, 1024 dimensions, cosine. mongot Community $vectorSearch; filter fields must be declared in the index, as on Atlas; quantization supported Move to mongot
Hybrid search ($rankFusion, $scoreFusion) shamwari ground builds a $rankFusion pipeline (shamwari/core/fakes.py, api-gateway/gateway/lib/shamwari.py) $rankFusion requires server 8.0 or later; hybrid search was announced as GA on 2026-06-30 but the sources read do not say it is in Community. Unverified: test on Community at M2. Fallback: two queries fused in the Rust API (RRF is a few lines) Test; fall back to RRF in the API if absent
Change streams mukoko-ingestion-pipeline domain_observer.py (one change stream over news, engagement, entity); the Doris sync described as a change stream is gone (Doris was removed 2026-11-22). mongot itself uses change streams Replica set change streams work unchanged on Community. Needs a replica set (so even the lab must be one) and an oplog window larger than any consumer outage Same code, new URI
Online Archive, Atlas Charts, Triggers, App Services, Stream Processing, Data Federation None found in any repository. Atlas MCP exposes Stream Processing tools but nothing in the estate uses them. App Services configuration is not in a repository, so Triggers and Functions cannot be ruled out: Unverified (check the console, section 11) None needed if unused. The news archive plan used Cassandra nhaka and R2, not Online Archive Confirm “none” in the console
Data API / HTTPS endpoints Removed by MongoDB on 2026-09-30. shamwari/gateway comments confirm nobody uses it n/a Confirm no dependents
Time-series collections, transactions, sharding, global clusters, Queryable Encryption None found in code (a search for withTransaction, start_transaction, timeseries, createCollection timeseries options found none outside tests). TTL indexes exist (shamwari reference setup, 400 days) TTL, validators ($jsonSchema, 25 domains) and views (4) are core server features and work on Community Verify the live catalogue in the dump
Atlas Performance Advisor, alerts, backups, UI, IP access list, private endpoints The Atlas MCP is used for administration; backups Unverified Section 3: exporter, alerts, dump and oplog, firewall Rebuild
mongosync (Cluster-to-Cluster Sync) Not used today Not an option: MongoDB does not test or support mongosync with Community builds; self-managed clusters must be Enterprise; sources and destinations must be major versions (7.0, 8.0, 9.0), no rapid releases (docs) Use the Rust replicator (section 6)

Licensing (verified). MongoDB Community is under the SSPL. Section 13 applies only when you offer MongoDB’s functionality to third parties as a service; the MongoDB FAQ says internal use, and other applications that use MongoDB as their database, do not trigger it (SSPL FAQ). The estate’s APIs sell data and application functions, not a database, so running Community is fine. Two things need a lawyer’s read before they go further: (a) the mongodb-mcp server gives authenticated users generic database commands, and any product that exposes raw database operations to customers is the case the clause is about; (b) the mongot binary is SSPL too.

5. What “Atlas as the edge database” means

Section titled “5. What “Atlas as the edge database” means”

Definition. The edge Atlas cluster holds a read-only subset of the data that must be served with low latency to Africa from clients that cannot reach the homelab: Cloudflare Workers, Vercel functions and anything in af-south-1 or jnb. It is not the system of record. All writes go to the self-hosted primary.

What stays on the edge, by rule: (1) any collection a Worker or Vercel function reads directly today, until that reader moves behind the API; (2) the hot window of news (14 to 30 days of news.articles, plus the small catalogues feedSources, categories, newsMediaOrganizations, journalists); (3) the places and weather reads the weather Workers use; (4) nothing else. Everything the API reads from a Fly or gondor service reads the primary on the LAN.

Workload Today After
news.mukoko.dev gateway and MCP reads (news, engagement) Atlas, native driver Atlas edge (read-only user). Its writes to identity and entity (WorkOS webhook, identity sync) are edge writes: they must move behind the Servers API first
news.mukoko.com reader on Vercel Atlas, direct Atlas edge until it uses /v1/news/*; then the edge shrinks
Weather Workers (reads via weather-mongo; writes via mongo-bridge) Atlas Reads: edge read-only user. Writes (device profiles, community reports, history) must go to the primary through a Servers API route (the Rust weather_mongo.rs already exists)
Kweli on Vercel Atlas, direct Edge reads of places; writes through the API
Vector and text search for user-facing news Atlas Search Option 1 (recommended): served from the primary’s mongot by the Rust API with a cache; no search on the edge. Option 2: keep one search index on the edge only for the 14-day window if a Worker needs it directly (needs M20 or larger: M10 has 2 GB RAM)
Ingestion, enrichment, identity, platform, ledger-adjacent, shamwari, circles, travel, novels and the other domains Atlas Primary only (no edge copy)

Edge sizing.

Edge tier List price Fits?
Flex $8 to $30 a month (capped), 5 GB hard cap, MongoDB 8.0 or later, no storage configuration, one daily snapshot Only if the edge holds under about 3 GB: a 14-day news window (about 75,000 to 170,000 articles at 12 KB) plus catalogues is borderline. af-south-1 availability, Search support and change-stream support on Flex are Unverified
M10 (2 GB RAM, 10 to 128 GB) $0.08/h = $58 a month list (cheapest region; af-south-1 costs more) Fits the 30-day window and catalogues with no search. Recommended default
M20 (4 GB RAM) $0.20/h = $146 a month list Needed only if vector or text search stays on the edge
Retention TTL on news.articles by datePublished (14 or 30 days) on the edge only The primary keeps everything (or archives to R2 Parquet through the event platform)
Mechanism Works with Community? Granularity Failure behaviour Verdict
mongosync (Cluster-to-Cluster Sync) No (not tested or supported with Community; Enterprise required for self-managed) Whole cluster or collection filters n/a Rejected
Atlas Live Migration Moves into Atlas only, one time Whole cluster n/a Useful only for the one-time seed of the edge, if at all
Rust change-stream replicator (anduin) Yes Per collection allow-list, per operation Resume token persisted; on a lost token (error 286) or an oplog window shorter than the outage it re-copies that collection and resumes Recommended
Event platform (Redpanda projection to the edge) Yes Per event type The log is replayable Rejected for now: Redpanda is not the system of record for the Mongo domains (owner 2026-10-29); it would make a second writer path

anduin design (recommended). One Rust binary, mongodb crate, per-domain allow-list in a config file.

  • Initial load: open the change stream first and record its resume token, then copy each collection by _id ranges in parallel, then replay from the token. Documents are applied as idempotent replaceOne upserts keyed by _id; deletes as deleteOne. Applying the same event twice is safe.
  • Ordering: one worker per collection preserves per-document order; collections are independent. No cross-collection transactions are claimed (the estate uses none).
  • Consistency: eventual, one way, normal lag under a few seconds, alert at 60 s. The edge is read-only for apps. A reader that must read its own write after a primary write reads the primary through the API (the API already returns the new state from the write itself).
  • Failure: if anduin is down, the edge goes stale but stays up; the API’s X-Edge-Age header (to add) reports the lag. If the primary is down, the edge serves reads and no writes succeed (honest degraded mode, which is better than today’s single point). If the edge is down, nothing on the primary is affected.
  • Direction flag per domain: during the migration the same tool runs Atlas to primary (to fill the new cluster), and after each domain’s cutover it flips to primary to Atlas (to keep the edge and the rollback path current). Both directions are never active for one domain at once.
  • Indexes and validators are not replicated by change streams: anduin applies the catalogue (mongo_catalog.json shape: validators, unique indexes, TTL) to the edge as a startup step and reports drift.
  • Test with data-infra/scripts/news/parity.py style fixtures plus a field checksum per collection each hour.

Principles: Atlas stays the source of truth until a domain is flipped; each flip has a rollback that costs one flag change; the news domain goes last together with the ingestion plan (ingestion pipeline lift).

Step Action Rollback Gate
M0 Dump Atlas now, restore into a scratch LXC container, compare counts, copy offsite (section 9). Create an Atlas read-only user for the dump and for anduin. Fix billing in parallel None needed (read only) A restored copy passes validate; checksums match on 1% of documents
M1 Export the console numbers (section 11); measure RTT from Fly jnb, Cape Town and a Worker to the homelab; confirm hardware (RAM, VT-x, disks); choose options D1 to D4 Nothing changed Decisions recorded
M2 Build the lab on pve (LXC): one replica set, mongod 9.0 plus mongot, TLS, users, exporter. Restore the M0 dump (this is the 8.0 to 9.0 upgrade by restore). Run the search parity queries and a $rankFusion test Delete the lab Counts equal; 50 recorded news queries within the parity thresholds; $rankFusion verdict
M3 Second and third members on their own machines (or option B with the caveat); backups and restore test running; monitoring and alerts live; WireGuard peer for Fly Remove the members One full restore test and one member-loss drill passed
M4 Start anduin Atlas to primary for all domains (read only on Atlas). Shadow reads: a flag in each client sends a sampled copy of its read queries to the primary and diffs the answers (no user impact) Stop anduin, delete the data One week with 0 unexplained diffs, lag under 5 s
M5 Per-domain flip, small domains first (lingo, planner, ubuntu, circles, travel, novels, then weather, places, hospitality, events, integrations, knowledge): flip reads (config change), then a write freeze of under 60 s on that domain’s writers, flip writes, flip anduin for that domain to primary to Atlas Flip the flags back; anduin already keeps Atlas current, so no data is lost Per domain: 24 h clean error rate and p95 within 20% of before
M6 identity, entity, platform, engagement, shamwari (search on mongot). platform.apiKeys is already moving to Postgres (API_KEYS_OWNER); do not flip it twice Same $rankFusion or RRF fallback in place; ground eval unchanged
M7 News (with the ingestion plan): new Rust pipeline writes to the primary; gateway and reader read the edge; search served from lorien Per-service flag back; Python pipeline stays warm for two weeks Parity tests of the ingestion plan pass; 7 days of stable ingest with heartbeats
M8 Shrink Atlas to the edge tier (a separate owner-approved change, never part of a migration step); set TTL on the edge news window; remove the unused Atlas users and IP allow entries Scale back up (hours) A week at the smaller tier with no saturation alerts

Never in one step: flip a domain and resize Atlas, or flip two domains at once.

8. Cost model (assumptions stated; replace with the invoice)

Section titled “8. Cost model (assumptions stated; replace with the invoice)”

All Atlas figures are list prices from mongodb.com/pricing read on 2026-12-04 for the cheapest region; af-south-1, backup storage, data transfer and any support plan are extra and unknown (the invoice is the real number).

Line Today (Atlas M20) After (self-hosted + edge)
Atlas cluster $146 list; $170 to $250 plausible with region premium, backup and transfer (assumption) Edge M10 $58 list, $65 to $90 plausible; Flex $8 to $30 if it fits
Hardware (2 extra machines, 32 GB, 2 x 1 TB NVMe each) 0 $900 to $1,400 once; $25 to $40 a month over 36 months (assumption)
Power (about 40 to 60 W more, always on) 0 $5 to $20 a month at $0.15 to $0.30 a kWh (assumption)
Offsite backup (R2 with Object Lock, about 100 GB) Atlas snapshots (in the bill) $2 to $5 a month (assumption)
Ubuntu Pro 0 Free for personal use on a few machines, otherwise per-machine yearly (price Unverified)
Labour (patching, restore drills, incidents) Almost none 4 to 8 hours a month (assumption); at any hourly rate this is the largest line and the one most often left out
Cash total $170 to $250 $100 to $155 (M10 edge) or $45 to $95 (Flex edge)
Net cash saving about $50 to $150 a month (M10) or up to $200 (Flex), before labour
Growth avoided M30 $0.54/h = $394 a month list, M40 about $1.04/h = $760 (list, data-infra doc) $250 to $650 a month avoided if the corpus would otherwise force M30 or M40
Risk cost Atlas provides HA, backups and support Owner holds availability: one home line, one power feed, one operator. Price this in the decision D1

Break-even reading: with labour counted at a modest rate the cash saving is near zero today; the case rests on avoided growth, control of search cost, and Africa-side edge latency. If the owner’s goal is pure cost, the cheaper move is to cap the corpus (30-day window, archive to R2) and stay on M10 or M20 without self-hosting. The plan in this page is right if the goal is also independence.

Run from a trusted machine on the LAN (the mini or pve), using a read-only Atlas database user created for the purpose (a console action by the owner; do not reuse an application’s credential). The connection string comes from erebor; it is never written to a file in a repository.

  1. mongodump --uri "$ATLAS_RO_URI" --gzip --readPreference=secondaryPreferred --out <dir> once per database (25 domains), in parallel, with --oplog only if the user has the privilege (Atlas read-only users do not; accept a fuzzy snapshot and replay through the M4 sync).
  2. Export, as JSON: every collection’s indexes (listIndexes), validators (listCollections), views, every search and vector index definition ($listSearchIndexes), the list of database users and custom roles (names and roles only, no secrets), and the IP access list. data-infra already has the catalogue shape.
  3. Restore into a scratch LXC container (M2 environment). Compare per-collection counts and a checksum of _id plus updatedAt on a 1% sample. Record the result in the issue.
  4. Copy the dump to bag-end and to R2 with Object Lock. Keep it for 12 months.
  5. Repeat the dump before every domain flip in M5 to M7.

Order of operations: step 1 now; fix the billing as soon as the owner can, because a suspended project could remove access to the data plane, the console exports in section 11 and Atlas backups.

Service (repo) Change When Risk
nyuchi/nyuchi-api (Python gateway and rust/) New MONGODB_URI (mongodb:// with the member list and replicaSet, TLS); keeps mongodb+srv support for the edge; Doris paths already gone; the $search and $vectorSearch stages run against mongot; caches and single-flight stay M5 to M7 Medium (about 30 namespaces)
nyuchi/api-gateway Same code base as above (the Python gateway repo); owns the visibility gate, catalogue (mongo_catalog.json) and indexes.py TTL and index builders, which become the schema-sync source for anduin M2 onward Medium
nyuchi/nyuchi-servers-api (Rust) URI change; its readiness probe needs mongodb:// host lists, which suits a self-hosted set; add replica-set aware probe; weather write routes absorb mongo-bridge M5, M6 Low to medium
nyuchi/data-infra Owns the schema and the scripts/news backfill and parity tools; add anduin or put it in nyuchi-servers-api/its own Rust repo; update docs/ that still say Atlas is the main store M2 Low
mukoko-dev/mukoko-ingestion-pipeline (fly-worker, enrichment-agent) Writes move to the primary last (M7). Until then unchanged. See the ingestion plan M7 High
mukoko-dev/mukoko-news-gateway Reads switch to the edge URI (same code); its identity and entity writes must move behind the API first; per-request connect cost is the same on the edge M5, M6 Medium
mukoko-dev/mukoko-news Reads the edge until it calls /v1/news/*; no change at flip time M7 Medium
mukoko-dev/kweli, kweli fundi ingestion Worker Edge reads for places; fundi writes via API M5 Low
mukoko-dev/mukoko services/*, nhimbe Stub or per-service URIs; point at the API or the edge M5 Low
mukoko-dev/mukoko-weather (mongo-bridge, weather-mongo) Reads: edge read-only URI. Writes: primary through a Servers API route; retire mongo-bridge after M5 Medium
nyuchi/mongodb-mcp, nyuchi/nyuchi-mcp-data-infra, nyuchi/fly-mcp (becoming one Rust data MCP) Two connection targets (primary read, edge read); admin tools refuse writes to the edge; Search index tools run against mongot (createSearchIndex works on Community); SSPL review of generic-command exposure (section 4) M5 Low
bundu-labs/shamwari (core destroyed 2026-11-28; gateway and the knowledge ground) Ground search and vector index move to mongot; its Worker never talked to Mongo, so only the Servers API changes M6 Medium
nyuchi-ledger, nyuchi-identity, nyuchi-monitoring (moving to Proxmox) Not Mongo; they must not depend on the home line for their own health. Keep them separate from the database VLAN n/a n/a
nyuchi/fly-mcp Fly-only tools; URI parameters for the two clusters M5 Low

(wt-weather-backend in the brief was read as the weather backend worktrees of mukoko-weather; it holds no separate Mongo code.)

11. Export from the Atlas console once billing is fixed

Section titled “11. Export from the Atlas console once billing is fixed”

Project “Nyuchi Platform” (6989ca17b7b03d132b6deb78), cluster nyuchi-platform-doc-db. Paste into the tracking issue as numbers, not screenshots.

  1. Cluster: tier and exact name (M20?), MongoDB version, cloud and region(s), node count, auto-scale compute and storage settings with their ceilings, current disk size and disk used, configured and baseline IOPS, instance class (General or Low-CPU), Search nodes: dedicated or shared.
  2. Load (last 30 days, max and p95): connections, operations a second by type, network in and out, disk IOPS, CPU, memory, WiredTiger cache, replication lag, oplog window in hours and GB.
  3. Data: per database and per collection: documents, data size, storage size, index size (the Atlas “Collections” tab or dbStats); the 10 largest collections; the article count in news.articles and its growth a day.
  4. Search: every Search and Vector Search index: name, collection, definition JSON, status and size (index size is the number that sets lorien).
  5. Backup: Cloud Backup on or off, snapshot schedule, retention per tier, Continuous (point-in-time) backup on or off, restore window, snapshot storage used (GB), the last restore test if any, and the oldest snapshot.
  6. Access: database users and roles (names, roles, scopes, auth method, no secrets), IP access list entries, private endpoints, VPC peering, App Services apps, Triggers, Functions, Data API and HTTPS endpoints (any), Charts dashboards, Stream Processing instances, Data Federation, alert settings and integrations.
  7. Money, by line item for the last 6 invoices: cluster compute, storage, Atlas Search or Search nodes, backup (snapshots and point-in-time), data transfer in and out, support plan, taxes; plus the payment method state, the amount that is delinquent and the date the delinquency began.
  8. Org: the organisation and project billing contacts, any commitment or credit, and whether an Atlas Enterprise or Premium plan is attached.
# Risk Likelihood Impact Mitigation
R1 Atlas suspended for non-payment before the dump exists Medium Severe M0 now; fix billing the same day; keep the dump offsite
R2 Home to Africa latency makes API calls from Fly jnb or Workers slow if they hit the homelab primary High if home is in Singapore High Edge for all Africa-side reads; API-side caching; measure at M1; keep chatty services on the LAN
R3 Single host or single line means outages Atlas never had High with option B High Option A; UPS; second internet line or cellular failover (owner decision); edge keeps reads up
R4 mongot is a new GA component (June 2026) with a recent CVE cadence Medium Medium Pin versions, patch monthly, keep a Percona-free fallback of RRF in the API; search failure must degrade to list pages
R5 $rankFusion is not on Community Medium Low Test at M2; RRF in the API
R6 PQ hybrid TLS not available for mongod High Low WireGuard PSK layer; say so honestly; retest on Ubuntu 26.04 or a newer OpenSSL
R7 Loss of native audit, native encryption at rest Certain Medium LUKS, log shipping, change-stream audit; or Percona (D6)
R8 Restore from 8.0 into 9.0 reveals incompatible data or driver behaviour Medium Medium M2 test with a real dump; old drivers pinned; mongodb crate and pymongo versions checked against 9.0
R9 Operator is one person; bus factor High High Runbooks in this docs site, automated restore tests, alerts to the phone, Atlas edge as reachable copy
R10 Edge writes missed (news-gateway identity and entity writes, weather bridge writes) would be silently lost High if missed High They move behind the API before M5 (section 5); edge user is read-only so a missed one fails loudly
R11 Replica-set client topology fails over VLANs or DNS (clients cannot resolve member names) Medium Medium Internal DNS for member names on every network that connects; replicaSet in every URI; test failover drill at M3
R12 SSPL read incorrectly if a product exposes raw database operations Low High Legal read before exposing mongodb-mcp-style tools to customers
R13 The estate’s plans disagree: some docs still call Atlas “the main store” and one said “Atlas is retiring” Certain Low Update data-infra and api-gateway docs at M2 (listed in section 10)
# Decision Recommendation
D1 Buy two more machines (about $900 to $1,400) for three failure domains, or accept option B Buy. Option B only as a transition
D2 Where the homelab is physically, and whether to add a second line or cellular failover Confirm location; add failover if outages are not acceptable
D3 Edge tier: Flex (if it fits and offers af-south-1), M10, or M20 M10, no search on the edge; revisit after the console export
D4 Search on the edge or only on the primary Primary only, served by the API
D5 Official MongoDB Community 9.0 plus mongot, or Percona Server for MongoDB 8.0 (audit and encryption at rest, no mongot found) Official Community 9.0 plus mongot, because search and vector are in use and growing
D6 Is database-level audit or native encryption at rest a hard requirement (customer, regulator)? If yes, move D5 to Percona and run search separately; if no, LUKS and log-based audit
D7 Retention: keep the full news corpus on the primary, or archive beyond a window to R2 Parquet Keep all on the primary; archive after 12 months; edge keeps 14 to 30 days
D8 Who is on call, and the RPO and RTO in section 3.6 Owner to confirm
D9 Whether mongodb-mcp or any customer-facing feature exposes raw database commands (SSPL) Keep it admin-only; get a legal read first
D10 Approve step M0 (a read-only Atlas user and a dump) now Yes, today
D11 Approve the Atlas downsizing at M8 as a separate change After a week at the new primary
Milestone Deliverable Acceptance test
M0 Verified Atlas dump, offsite Restore to scratch; all 25 domains’ counts equal; 1% checksum equal; indexes, validators and search definitions exported
M1 Console numbers, measurements, decisions Section 11 table complete; RTT from jnb, Cape Town and a Worker recorded
M2 Lab replica set with mongot on pve 50 recorded search queries within thresholds; vector top-10 overlap at least 90% with Atlas; $rankFusion verdict; 8.0 to 9.0 restore clean
M3 Three members, backups, monitoring, WireGuard Kill the primary: new primary in under 15 s, no lost acknowledged write; restore test passes; alert fires within 2 minutes of a stopped exporter
M4 anduin and shadow reads Seven days, zero unexplained diffs, lag under 5 s; a deliberate 2-hour anduin stop catches up without a copy
M5 Small and mid domains on the primary Per domain: 24 h with error rate not above baseline; rollback rehearsed once
M6 Identity, entity, platform, engagement, shamwari Ground evaluation set unchanged; no cross-domain write found by domain_observer
M7 News on the primary (with the ingestion lift) See the ingestion plan acceptance tests; search served from lorien
M8 Atlas shrunk to the edge A week at the lower tier with no saturation, no MaxTimeMSExpired bursts, bill reflects the new tier