rodloboz

rodloboz

Hakushi: a canvas for Phoenix LiveView

Hakushi — Canvas for Phoenix

Hi everyone!

You may remember Kotoba, Masu, Jumon and Koyomi. Today I want to share the newest member of that family: Hakushi (白紙, “a blank sheet of paper”).

Hakushi is a canvas for LiveView. It gives you an endless sheet that people can pan and zoom, with nodes on it and lines between them. Think database schemas, workflows, moodboards, whiteboards, mind maps: anything that is boxes and arrows.

I made it for people who want to build real apps on top of a canvas, not just show a diagram. If that is you, please give it a try. I think you will like how it feels.

The schema of a project tool on Hakushi: tables with a handle on each column, foreign keys between columns of the same type, on graph paper

How it works

Each node is your own HEEx, rendered on the server. You write one slot for each type of node and put handles where edges can start and end. A handle can be on the whole node, or on one row inside it, like each column of a table.

Your server stays in charge. When someone moves a node, draws an edge or pastes something, the change goes to your on_change first. You check it and save it. If you return an error, the browser undoes the change and shows your message. Rules like “no cycles” or “only connect columns of the same type” are checked in the browser while people draw, and again on the server.

<.canvas id="flow" graph={@graph} on_change={&Flows.change(&1, &2, @flow)}>
  <:node type="step" :let={node}>
    <div class="step">
      <.handle kind={:target} side={:left} />
      {node.data.title}
      <.handle kind={:source} side={:right} />
    </div>
  </:node>
</.canvas>

With Issho, a canvas is shared. Everyone on it sees each change as it happens, with live cursors, selections and drags. Your policy decides who can do what, and you do not need another service.

You also do not need Node.js. The JavaScript comes prebuilt in the Hex package, and you add one hook and one style sheet. For tests, Hakushi.Test moves, connects and deletes nodes in Phoenix.LiveViewTest, with no browser.

Two people on one canvas: Kenji's cursor and name, and the table he is moving, outlined in his colour

Kits

A kit turns the canvas into a certain kind of tool, in one line. Hakushi comes with six: Schema (tables and foreign keys), Flow (triggers, steps and conditions), Notes (sticky notes), Shapes (a whiteboard), Ink (a pen, a highlighter, an eraser and a lasso) and Images (dropped, pasted, cropped and captioned, with files kept by Storehouse).

<.canvas id="board" graph={@graph} kits={[Hakushi.Kits.Shapes, Hakushi.Kits.Ink]} on_change={&Boards.save(@board, &1, &2)} />

You can also write your own kit with the Hakushi.Kit behaviour. Honestly, this is the part I am most excited about. I would love to see the kits you build.

A whiteboard with the Shapes kit: an idea, a sketch, a decision, and the style panel of the selected shape

The moodboard with the Ink kit: a pen stroke under the title, a circle around a colour, and Kenji drawing at the same time

A live canvas inside a Kotoba document

This is my favourite part. If you use the latest Kotoba, you can put a live canvas right inside the rich text editor. People draw on it in the middle of the text. When they want more room, they open it full screen, explore the whole canvas, and go back to the document.

So a design doc can hold its database schema, its workflow and its open questions between the paragraphs, and all of them are real canvases that you can edit.

These screenshots are from Notebook, the demo app of the family: a Kotoba page with a Hakushi board inside it.

Try it

If you have Igniter, it is one command:

mix igniter.install hakushi

If you do not, add {:hakushi, "~> 0.4"} to your deps and run mix hakushi.install. Then the Quickstart takes you to your first canvas that saves its changes.

The repository also has a demo app with a schema, a workflow, a moodboard, a whiteboard, a design spec and a canvas of two thousand nodes. Clone it, run mix setup && mix dev, and open a second window as another person to see two people work on one canvas.

Questions, issues and ideas are all welcome. And if you build something with it, please show me!

Showing Posts 1 to 4

jhosteny

jhosteny

This looks really nice @rodloboz !

rodloboz

rodloboz OP

Thanks! Let me know if you try it out and have some feedback :slight_smile:

uzaydurdu

uzaydurdu

I liked it @rodloboz, nice to have something like this!

rodloboz

rodloboz OP

@uzaydurdu I’m using it in a couple of projects and it’s a nice tool I reach out to now. I’m sure it’s possible to be super creative with it and if folks have ideas to improve it or for feature happy to hear them

— All posts loaded —

Where Next? Top

Trending in Announcing Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
danschultzer
I’ve moved the strategies out of PowAssent and created a multi-provider framework for Elixir. This way the strategies can be used in any ...
New
gtcode
Aloha gang, There’s a new class of AI model out from TypeSafe. Jev is their flagship model. You can learn about it here: ...
New
danschultzer
I needed something like premailer for rails, and after searching, I decided to make an easy-to-use library to handle inline styles and co...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews