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

TL;DR

Threlmark’s architecture treats the local disk as the definitive record, with JSON files on your machine serving as the single source of truth. This design boosts speed, offline resilience, and simplicity, all without a central database or server. Disk Is the Contract: Inside Threlmark’s Local-First Architecture

Imagine working on your project, making changes, and having those updates instantly reflected without waiting for a server. No lag, no cloud dependency. That’s the power of Threlmark’s local-first architecture, where the disk isn’t just storage — it’s the contract. It’s a bold shift from traditional apps that rely on servers or databases, leaning instead on simple files on your local machine.

In this article, you’ll see how the core idea that “disk is the contract” drives everything — from speed and offline use to collaboration and future-proofing. We’ll unpack how JSON files become the backbone of a flexible, resilient, and open system that anyone can understand, modify, and extend.

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
SANDISK 1TB Extreme Portable SSD (Old Model) - Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware - External Solid State Drive - SDSSDE61-1T00-G25

SANDISK 1TB Extreme Portable SSD (Old Model) – Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware – External Solid State Drive – SDSSDE61-1T00-G25

Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity…

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
Free Fling File Transfer Software for Windows [PC Download]

Free Fling File Transfer Software for Windows [PC Download]

Intuitive interface of a conventional FTP client

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
SUUNTO Nautic S Dive Watch Computer w/Bright AMOLED Display, GPS, Offline Maps and Weather Tools, Wireless Tank Pressure, Up to 60H on a Single Charge

SUUNTO Nautic S Dive Watch Computer w/Bright AMOLED Display, GPS, Offline Maps and Weather Tools, Wireless Tank Pressure, Up to 60H on a Single Charge

Bright AMOLED Display for Superior Readability-Enjoy crystal-clear visibility underwater with a bright AMOLED screen, designed for easy reading…

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
First Aid Only Z801 SmartCompliance Refill 52 x 84 Emergency Blanket, 1 Count

First Aid Only Z801 SmartCompliance Refill 52 x 84 Emergency Blanket, 1 Count

Reflects back 90% of the bodies heat

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 on-disk JSON files as the single source of truth for maximum transparency and resilience.
  • Atomic file writes are crucial to prevent corruption and ensure data integrity during crashes.
  • File-based storage simplifies backups, migrations, and external tool integration.
  • Sync conflicts are inevitable but manageable with timestamps and merge strategies.
  • Local-first design boosts speed and offline usability, ideal for remote or distributed teams.

What ‘disk is the contract’ really means in Threlmark

‘Disk is the contract’ means the app’s truth lives on your local drive, not in a remote database. Every time you open Threlmark, it reads the JSON files — the *single source of truth*. When you make a change, it updates those files atomically, ensuring data is always consistent and recoverable.

Why does this matter? Because it shifts the entire paradigm of data management. Instead of relying on complex server-side transactions or distributed locking, the system depends on the atomicity of file operations. This approach simplifies error recovery; if the app crashes during a write, the incomplete file can be discarded or rolled back, maintaining data integrity. Learn more about local-first architecture. It also means that the user always has access to the latest consistent state, even in the event of power loss or hardware failure. This model emphasizes transparency and control—users and developers alike can inspect the raw JSON files to understand exactly what data is stored and how it’s structured, leading to easier debugging and customization.

What ‘disk is the contract’ really means in Threlmark
What ‘disk is the contract’ really means in Threlmark

Why JSON-on-disk beats traditional databases for local-first apps

JSON is lightweight, human-readable, and easy to work with directly on your filesystem. Threlmark uses a separate file for each item — a card, a task, a note — instead of a giant database. This setup makes updates atomic, minimizes conflicts, and simplifies backups.

But beyond simplicity, this approach also influences the system’s robustness. When you update a JSON file, the change is atomic—either the whole file is replaced or not at all—reducing the risk of partial writes corrupting data. This atomicity is especially important in environments prone to power failures or crashes. Learn about CAD and data safety. Furthermore, using individual files allows for granular conflict resolution during sync, since each item can be independently updated, merged, or rolled back. This modularity makes it easier to implement features like version history or selective sync, which are more complex in monolithic databases. Additionally, because JSON files are plain text, they can be version-controlled with tools like Git, enabling detailed history tracking, diffs, and rollbacks — enhancing transparency and safety. This design choice emphasizes resilience, ease of understanding, and interoperability, especially as data scales or needs evolve.

How local-first changes the game for offline work and speed

Local-first apps like Threlmark let you read and write data instantly, right on your machine. No network lag, no waiting on server responses. If you’re on a plane or in a remote area, your work continues seamlessly.

But what’s more significant is how this architecture impacts user experience and workflow reliability. Immediate local access means no delays due to network latency, which can be a game-changer for real-time decision-making and rapid iteration. When working offline, users aren’t blocked or limited; they can continue editing, organizing, and planning without interruption. This reduces frustration and increases productivity, especially in environments where internet access is unreliable. The system’s speed also enables more fluid interactions—drag-and-drop, instant search, quick updates—that feel natural and responsive. These benefits aren’t just convenience; they fundamentally change how users perceive and trust the application. When speed and offline resilience are baked into the core design, the app becomes more dependable and user-friendly, fostering deeper engagement and reducing dependency on constant connectivity.

How local-first changes the game for offline work and speed
How local-first changes the game for offline work and speed

Syncing — the tricky part that Threlmark handles elegantly

Syncing is the only real challenge in local-first apps. Threlmark approaches this by treating JSON files as the single source of truth, then syncing these files across devices when online.

It uses a straightforward model: changes are recorded locally, then pushed or pulled with conflict resolution. For instance, if two devices edit the same card, Threlmark detects the conflict based on timestamps or change histories and resolves it intelligently.

Why does this matter? Because effective sync mechanisms are essential for maintaining data consistency across devices and users. Threlmark’s approach, which leverages the simplicity of file-based storage, allows for flexible conflict resolution strategies—like last-write-wins, manual review, or merge tools—depending on the context. This means users can work offline without fear of losing data, and when reconnected, the system can reconcile differences without complex coordination protocols. The key is that by treating each JSON file as an independent, versioned record, the system can handle conflicts gracefully, reducing user frustration and data loss. This design also makes it easier to implement incremental sync, partial updates, and conflict resolution policies tailored to specific workflows, ultimately making the sync process both robust and transparent.

The real-world benefits: speed, resilience, and simplicity in action

Imagine managing multiple projects with dozens of tasks. Threlmark’s file-based system makes opening, editing, and saving almost instant. When your laptop crashes, your data remains safe because it’s stored in atomic JSON files.

But the true advantage is how this setup promotes transparency and flexibility. Since all data is stored as plain text files, users and developers can easily inspect, modify, or migrate data using standard tools. Explore innovative tech products. This openness fosters trust and allows for custom integrations or troubleshooting without vendor lock-in. For example, a team can use simple diff tools to compare versions or restore previous states, or migrate data to other systems with minimal fuss. Moreover, the resilience to crashes and hardware failures means less downtime and data loss. downtime and fewer data recovery headaches. This combination of speed, safety, and openness empowers teams to operate confidently and adapt quickly to changing needs, making the system not just reliable but also highly adaptable to various workflows and environments.

The real-world benefits: speed, resilience, and simplicity in action
The real-world benefits: speed, resilience, and simplicity in action

What are the tradeoffs? Challenges in local-first design

While powerful, local-first systems aren’t without hurdles. Managing sync conflicts, versioning, and data integrity can get complicated, especially as projects grow.

For example, simultaneous edits on two devices require clever conflict resolution strategies. Threlmark handles this with timestamps and merge logic, but no system is perfect.

Additionally, syncing large datasets or binary files can be slow, and ensuring consistency across devices demands careful design.

Another consideration is user education. Since the data lives in plain files, users or administrators need to understand how to handle conflicts or recover from errors without a traditional database interface. This can introduce a learning curve but also offers more control and insight for those willing to engage with the raw data. Overall, while the approach favors transparency and resilience, it demands thoughtful implementation and clear communication about its limitations and best practices.

Practical tips for adopting a disk-as-the-contract approach

  1. Start small: use JSON files for key data, avoid complex databases early on.
  2. Implement atomic writes: always write to temp files then rename, to prevent corruption.
  3. Normalize reads and writes: merge patches carefully, keep defaults, preserve unknown keys.
  4. Plan for sync conflicts: timestamp changes, resolve automatically or flag for review.
  5. Keep backups: since everything’s files, simple copying or version control works perfectly.

For a real-world example, check out the Threlmark GitHub repository — it’s a masterclass in file-based, local-first design.

Practical tips for adopting a disk-as-the-contract approach
Practical tips for adopting a disk-as-the-contract approach

Who benefits most from Threlmark’s local-first architecture?

This design suits teams or individuals who need reliable offline access, quick feedback, and easy data portability. Creative professionals, remote teams, or open-source projects thrive with this approach.

For instance, a freelance designer working across multiple devices can make updates on their laptop, then have those changes sync seamlessly with their tablet, all without losing data during offline periods.

It’s ideal for applications where trust, transparency, and resilience matter more than real-time collaboration — think personal dashboards, project management, or note-taking tools.

Frequently Asked Questions

What does ‘disk is the contract’ actually mean?

It means your app’s primary data is stored directly on the disk as JSON files, and these files define the true state of your data. The app reads and writes these files atomically, making them the single source of truth.

How is this different from normal offline caching?

Offline caching temporarily stores data locally, but the server still controls the main data. In a local-first system like Threlmark, the disk is the main record, and syncing occurs later, making offline work seamless and reliable.

Why use JSON-on-disk instead of a traditional database?

JSON files are simple, human-readable, and easy to manipulate directly. They avoid the complexity of schema migration and lock-in, making the system more transparent, interoperable, and resilient to crashes.

How does sync work when the device comes back online?

Threlmark compares local JSON files with remote copies, detects conflicts via timestamps, and merges changes automatically or flags conflicts for review. This keeps data consistent across devices.

What happens if two devices edit the same data simultaneously?

Threlmark uses timestamps and merge logic to resolve conflicts. If both devices change the same card, it intelligently combines updates or prompts for manual resolution if needed.

Conclusion

Choosing to make disk the contract transforms how apps behave — faster, more reliable, and easier to understand. Threlmark exemplifies that simplicity and openness create a powerful foundation for future-proof tools. When you work with files instead of databases, you reclaim control and build resilience into the core of your application.

So, if speed, offline access, and transparency matter, consider how your app’s data lives and breathes. The disk isn’t just storage; it’s the contract, the backbone of your system.

You May Also Like

Multi-Region Systems: Balancing Consistency, Cost, Complexity

Multi-region systems require careful balancing of consistency, cost, and complexity to optimize performance and resilience, and understanding this trade-off is essential for success.

Read Replicas: When They Help (and When They Lie)

The truth about read replicas can boost your database performance, but knowing when they lie is essential for reliable data management—discover how inside.

Failover Testing: The Only Way to Trust Your DR Plan

I. Failover testing is essential to ensure your disaster recovery plan works flawlessly, but the key details to maximize its effectiveness are often overlooked.

Database Connection Pooling: The Bottleneck That Looks Like Latency

By understanding how database connection pooling can cause latency, you can identify and fix bottlenecks that hinder your system’s performance.