Disk Is the Contract: Inside Threlmark's Local-First Architecture

TL;DR

Threlmark treats disk as the single source of truth, with a simple file-based system that supports offline work, easy syncing, and open interoperability. This approach reduces complexity and enhances resilience, making it a powerful pattern for modern apps.

Imagine a project management tool that works perfectly offline, is lightning-fast, and never locks you into a cloud service. Now, imagine that all its data lives right on your disk—no database, no server, just simple files. That’s the core idea behind Threlmark’s local-first architecture, a design that treats the disk as the contract that defines your app’s entire behavior.

This isn’t just about storage; it’s about a new way to think about data, sync, and collaboration. You’ll see how this approach makes your app more resilient, more flexible, and even easier to build. If you care about privacy, simplicity, and control, understanding Threlmark’s design will change how you see app architecture.

Disk is the contract: inside Threlmark’s architecture — ThorstenMeyerAI.com
ThorstenMeyerAI.com
Threlmark · Technical Deep-Dive
Threlmark · architecture

Disk is the contract: inside a local-first roadmap hub

A Next.js app on top of plain JSON files — no database, no cloud, no accounts. The key decision: the on-disk layout IS the API. Everything else cascades from taking that seriously.

Next.js · TypeScript · JSON-on-disk · MIT · part 2 of the Threlmark series
01The core decision

There is no server-of-record — the files are the record

The UI and any external tool reach the same files through the same discipline. The data root defaults to ~/.threlmark — home-based, because it’s a shared hub every one of your apps points at.

~/.threlmark/ ├─ threlmark.json # manifest ├─ links.json # dependency graph ├─ projects// │ ├─ project.json # meta + wipLimits │ ├─ board.json # lane ordering │ ├─ items/.json # ONE card per file ← source of truth │ ├─ suggestions/ # the Inbox (drop-zone) │ ├─ handoffs/ # recorded agent handoffs │ ├─ reports/ # agent report drop-zone │ └─ ROADMAP.md # human-readable mirror ├─ shared/items/ # cards many projects ref └─ archive/ # archived, still readable

Inspectable

Every artifact is a file you can cat, diff, grep, commit.

Portable · no lock-in

Back up with cp, sync with Dropbox / git, migrate trivially.

Interoperable

Any tool in any language joins by reading / writing files.

Restartable

No in-memory state to lose — stateless over the files.

02Making files safe
Amazon

offline file-based project management software

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Two disciplined patterns instead of a database

“Just use files” is easy to get wrong. These two patterns — ported from a battle-tested sibling app — are what make file-based state sound rather than reckless.

Pattern 1

Atomic writes

Write to a temp file in the same dir, then rename() over the target. Rename is atomic on one filesystem — a crash mid-write leaves the complete old file or the complete new one, never a half.

write .tmp-pid-rand fsync rename() over target
Pattern 2 · one file per item

The board heals itself

A single roadmap.json array races when two tools write at once. One file per card makes writes collision-free. Lane order lives in board.json and reconciles on read.

The payoff: an external tool never touches board.json. It writes an item file — the board fixes itself on Threlmark’s next read. Unknown keys are preserved, so the contract is forward-compatible.
03Derived, never stored
Amazon

local-first architecture tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

The numbers can’t drift from the files

Anything computable from item state is computed — so the displayed numbers can never disagree with the underlying JSON. Priority is the clearest example: it’s calculated on read, never persisted.

priority — computed on read

Impact weighted heaviest; effort the only axis that subtracts. Reused verbatim from the original tool, so imported cards rank identically.

priority = max(0, round(impact·3 + evidence·2 + fit·2effort·1.5))
a 5 / 5 / 5 / 4 card 29
work-item age
now − lane-entry time. Past threshold (dev 7d, ranked 21d, idea 60d) → stale.
cycle time
first DevelopmentDone. Derived from append-only transitions[].
throughput
items reaching Done per ISO week, 8-week window.
WIP
count per lane; over the cap shows 3 / 2 in red.
04The closed agent loop · press play
Amazon

JSON file management app

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

A handoff is a first-class flow event

The genuinely 2026-shaped part: most building is done by AI agents, so Threlmark closes the loop. Watch a card go from ranked to Done without anyone dragging it.

Handoff → report → self-move

The brief carries a reporting protocol. The agent reports through REST or the filesystem — and a done report moves the card itself.

Ranked
Add price-drop alertsscore 31 · ready
Development
Handed off 🤖
Done
▶ preferred — REST
POST /api/projects/:id/
items/:itemId/report

Direct call. Applied immediately.

▶ fallback — filesystem
drop reports/.json
→ ingested on read

Robust even if the server’s down at finish time.

🤖 claude done: price-drop alerts shipped · typecheck + lint + build passed — card moved to Done
05Portfolio score & deployment
Amazon

disk-based data sync tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

A small formula, and an honest hosting caveat

Because items are globally addressable (/), the Portfolio ranks everything together by a status-weighted score — finishing beats starting, blockers get a boost.

Portfolio ranking — status-weighted

In-flight work floats to the top; bottlenecks cost the most, so blockers get nudged up.

score = priority · statusWeight (+ 0.1 · blockedCount · priority)
1.3
development
1.0
ranked
0.85
idea
0.15
done
Path 1

Static read-only demo

Seeded data, writes to localStorage. Try-before-you-clone.

Path 2

Personal Node instance

Password-gated, persistent backed-up THRELMARK_DATA_DIR.

Path 3

Multi-tenant SaaS

Add accounts + per-tenant isolation. A separate build.

The elegant part: the store interface src/lib/*/store.ts is the natural seam — the same boundary that keeps the local tool simple is the one you’d extend for multi-tenancy. The architecture doesn’t fight that future; it just doesn’t pay for it until you need it.
ThorstenMeyerAI.com
Threlmark · open source (MIT) · github.com/MeyerThorsten/threlmark · part 2 of a series · file layout, formula, weights & agent-loop channels are Threlmark’s actual mechanics.

Key Takeaways

  • Treat disk as the single source of truth for maximum transparency and control.
  • Use one file per item to prevent race conditions and simplify concurrency.
  • Implement atomic writes and self-healing reconciliation to keep data safe and consistent.
  • Sync changes in the background with simple diff + merge, enabling offline work and collaboration.
  • This architecture reduces backend complexity and boosts privacy, resilience, and portability.

What does ‘local-first’ really mean for your app?

Local-first isn’t just about working offline; it’s about making the local copy the primary source of truth. When you open Threlmark, your data is right there on your disk, instantly accessible—no waiting for the cloud. Changes happen locally, and sync just happens in the background.

For example, if you’re managing multiple projects, each project’s data lives in JSON files on your machine. You can edit, move, or even delete files without losing data—your app always reads from the disk first, making it fast and reliable.

This model contrasts sharply with cloud-first apps, where the server is king. Here, the disk is the contract. It’s like having a live, local database that’s also portable and open.

Understanding why this matters is crucial: by prioritizing local data, your app can operate instantly without network delays, and it can continue functioning even when offline. This reduces dependency on external services, lowers latency, and gives users a sense of control and privacy. The tradeoff, however, is that you need robust sync and conflict resolution mechanisms to keep data consistent across devices, which is where Threlmark’s design shines.

What does ‘local-first’ really mean for your app?
What does ‘local-first’ really mean for your app?

How ‘disk is the contract’ simplifies data handling

In Threlmark’s design, the disk isn’t just storage—it’s the source of truth. The entire app state lives in a simple folder structure, with JSON files representing projects, cards, and relationships. No complex database migrations or server APIs are needed.

Think of it like a contract: the files define what the app knows and how it behaves. If you change a file, the app sees the new state immediately. This makes the system incredibly predictable and easy to debug.

But beyond simplicity, this approach enhances portability and interoperability. Because the data is stored as plain files, you can easily move, back up, or edit your data with standard tools. This openness fosters a flexible ecosystem where different tools or processes can interact with your data without vendor lock-in or complicated integrations. The tradeoff is that managing consistency and avoiding conflicts requires careful design, which Threlmark addresses through atomic operations and conflict resolution strategies. This means you get the benefits of simplicity and transparency without sacrificing data integrity or flexibility.

Why atomic file operations matter — real-world safety on disk

Using files might sound risky, but Threlmark’s approach makes it safe with atomic writes. Each update writes to a temporary file first, then renames it atomically. If a crash happens mid-write, you either keep the old file or get the new one—never a half-written mess.

Atomic operations are critical because they guarantee that data is either fully written or not at all, preventing corruption. This is especially important in environments where power failures or crashes are possible. For example, updating a task card involves writing a new JSON file in a temp location, then renaming it over the old. This guarantees data integrity, even if your computer crashes or loses power.

In practice, this means your data remains consistent and recoverable, reducing the risk of losing hours of work or ending up with corrupt files. The tradeoff is that atomic writes slightly complicate the file management logic, but the safety benefits far outweigh this complexity. Threlmark’s implementation ensures that data safety is baked into every operation, making it suitable for real-world use where reliability is non-negotiable.

Why atomic file operations matter — real-world safety on disk
Why atomic file operations matter — real-world safety on disk

One file per item: how it avoids race conditions

Instead of a giant JSON array of tasks, Threlmark stores each item in its own file. This means multiple tools or processes can update different cards simultaneously without clobbering each other.

For example, when you move a card to ‘Done,’ the system writes a small JSON file in the `items/` folder. If another app adds a new task at the same time, they don’t conflict—they just write separate files.

This approach reduces race conditions by isolating each change to a single file, making concurrent edits more manageable. It allows multiple devices or collaborators to work on the data simultaneously, with changes being merged seamlessly during sync. The benefit is clear: fewer conflicts, more reliable collaboration, and easier debugging. The tradeoff is managing many small files, which can introduce filesystem overhead, but the gains in concurrency and conflict avoidance are well worth it.

How the system keeps the ‘board’ healthy and consistent

The lane layout and order are stored separately in `board.json`. Every time the system reads it, it cross-checks against existing items. Missing cards are added back, and misplaced ones are corrected.

Imagine your kanban board as a living document that repairs itself every time you open it. If a task gets deleted, it’s gone from the file system, but accidental discrepancies get fixed automatically. This self-healing process is essential for maintaining a consistent view, especially when multiple devices or tools are involved, each making concurrent changes. Without this, minor inconsistencies could snowball into larger problems, confusing the user and complicating collaboration.

By continuously reconciling the visual state with the actual data, the system ensures reliability and trust. It reduces manual oversight and prevents synchronization issues from escalating, which is critical for maintaining an efficient workflow in a multi-device environment.

How the system keeps the ‘board’ healthy and consistent
How the system keeps the ‘board’ healthy and consistent

Sync and collaboration: how does Threlmark keep everyone on the same page?

Threlmark’s design makes syncing straightforward. Changes are stored locally, then synchronized in the background via a simple diff + merge process. It can work over Dropbox, git, or any shared file system.

For example, if a colleague adds a new task on their laptop, the change appears instantly on yours after sync. Conflicts are resolved using merge strategies, and CRDTs are optional but helpful for complex cases.

This approach makes collaboration feel natural, even with multiple devices and offline work. The key is that background sync minimizes user intervention, making the process seamless and less error-prone. However, this simplicity requires robust conflict detection and resolution strategies to prevent data loss or duplication, which Threlmark thoughtfully incorporates. The result is a smooth, resilient workflow that supports real-time collaboration without a central server.

Why this approach boosts privacy and resilience

Since all data lives on your disk, you control your data. There’s no need to send everything to a central server, which reduces exposure to breaches and enhances privacy.

Imagine working on sensitive project notes that never leave your device unless you explicitly choose to share them. This local control minimizes attack vectors and gives you full ownership of your data. Additionally, because the data isn’t reliant on a network connection, your app remains operational even during outages or network failures. This resilience means your workflow isn’t interrupted by external factors, and recovery is straightforward—just keep working locally and sync later.

Furthermore, this architecture aligns with privacy-conscious design principles, reducing the attack surface and giving users confidence that their data isn’t being silently uploaded or monitored. The tradeoff is that you need to manage sync and conflict resolution carefully, but the benefits in privacy and resilience are substantial, especially for sensitive or mission-critical applications.

Why this approach boosts privacy and resilience
Why this approach boosts privacy and resilience

When local-first might not be the best fit

While powerful, local-first architecture isn’t suited for every app. Real-time, authoritative data—like live stock trading or multiplayer gaming—requires centralized control.

For example, a live chat app needs a central server to coordinate messages instantly. Local copies can’t guarantee the same immediacy or authority.

In such cases, hybrid approaches or cloud-first designs are more appropriate. Understanding these tradeoffs is essential for choosing the right architecture for your app’s specific needs and ensuring you don’t compromise on essential features like real-time responsiveness or data integrity.

Getting started with a local-first mindset — practical tips

  1. Design your data as JSON files, one per item.
  2. Use atomic write patterns to keep data safe.
  3. Separate state (like lane order) from item data.
  4. Implement background sync with diff/merge tools.
  5. Build in self-healing routines for consistency.
These steps form a resilient, flexible architecture that’s easy to understand and extend.

Frequently Asked Questions

What does ‘local-first’ actually mean?

Local-first means your app treats the local device’s storage as the primary source of truth. Changes happen locally, and syncing happens in the background, making the app fast, reliable, and offline-capable.

How is local-first different from offline-first or cloud sync?

Offline-first emphasizes working offline, but local-first makes the local copy the main authority. Cloud sync is just a background process, not the central source. Local-first prioritizes data control and resilience.

How does syncing work across multiple devices?

Syncing involves detecting changes locally, then diffing and merging those changes with other devices via shared storage, git, or sync services. Conflict resolution strategies like CRDTs help keep data consistent.

What happens when two devices edit the same item simultaneously?

The system uses merge strategies or CRDTs to reconcile conflicts. Typically, the last write wins or changes are merged intelligently, preventing data loss.

Is local-first architecture more secure and private?

Yes, because data stays on your device unless explicitly shared. This reduces exposure to breaches and gives you full control over your information.

Conclusion

Threlmark’s approach shows that simple, file-based data management isn’t just for hobby projects. It’s a blueprint for building resilient, flexible, and privacy-conscious apps that work offline by design.

By making disk the contract, you put control back in your hands. Your data becomes portable, your app more reliable, and your workflow more human. In an age of cloud dependence, that’s a breath of fresh air—an architecture that truly puts the user first.

Getting started with a local-first mindset — practical tips
Getting started with a local-first mindset — practical tips

You May Also Like

Model Drift: Why AI Gets Worse Over Time (And How to Detect It)

Properly detecting model drift is crucial to maintaining AI accuracy as data evolves and performance declines over time.

Legal Aspects of AI: Liability and Intellectual Property

Beyond current laws, understanding AI liability and intellectual property rights is crucial as this evolving legal landscape continues to develop.

AI for Climate Change: Predicting and Mitigating Impacts

Guiding climate solutions through AI, discover how technology predicts impacts and shapes sustainable strategies to protect our planet.

AI in Finance: From Robo‑Advisors to Algorithmic Trading

Unlock how AI is transforming finance, from robo-advisors to algorithmic trading, and discover the future possibilities awaiting you.