MDAN MDAN Docs
Site

Application Structure

This page is about how to lay out code, pages, and interaction when you build a real MDAN app, especially agent apps and skills apps.

The short version is: keep page source, server logic, and browser-side code separate, but do not split them into something heavier than the app itself.

The smallest useful structure is usually:

You can think of that as three layers:

index.mjs only hosts the app so you can run it locally or deploy it in Node or Bun.

Keep Responsibilities Clear

The easiest way to make an MDAN app hard to maintain is to mix responsibilities.

A clean split usually looks like this:

That way, the page layer, the server layer, and the browser layer each do one thing.

How Pages and Operations Line Up

MDAN uses explicit page routes and explicit action paths.

That keeps the relation between pages and interaction stable. You do not need to infer bindings from whatever the page happens to look like right now.

In practice:

When those three line up, behavior tends to stay predictable.

Where HTML Shell Logic Belongs

Shared HTML shell logic should usually live in server-side wrapping:

Typical responsibilities look like this:

So the Markdown page is the application itself, while the HTML shell wraps it into a fuller website or page experience.

How To Organize Operations

Each action should explicitly declare:

The two most common cases are:

Read Action (GET)

handler: ({ block }) => block()

Write Action (POST)

handler: ({ inputs, block }) => {
  // update domain state
  return block();
}

If all you need is to refresh the current block, return block().

If a write also needs to carry new state, an error, or the next available operation, keep that with the returned fragment instead of scattering it elsewhere.

  1. Decide your route list and page files.
  2. Write the Markdown for each page, then build a renderPage()-style composition function.
  3. Register each page operation as an explicit action.
  4. Wire up the runtime entry, static assets, and HTML shell.
  5. Add the browser runtime and verify local updates and page transitions.

Common Pitfalls