How we built a Hacker News clone on Hatamoto
news.hatamoto.dev runs on one plugin, one theme and one kit. Here is what went into core, what stayed in the plugin, and what load and abuse testing found.
news.hatamoto.dev is a Hacker News style community running on Hatamoto, the open source CMS behind this site. Members submit links, vote, comment, flag and earn karma. Anyone can set up the same site on a fresh install with one command:
hatamoto kit apply hn --accept-comment-warnings \
--grant hn:entities.write.own,hn:comments.moderate,hn:client.key
Hatamoto core carries no site-specific code, so the clone is three packages: the hn plugin, the hn-classic theme and the hn kit. Core only hosts them. These three are independent and can be installed on Hatamoto to start your own hackernews community.
We published the contract first as SDK 0.27.0, so core, plugin and theme work ran side by side and it all shipped in core v1.4.5. If you want to give it a try, just install the latest version with kits from the settings menu.
Every story is an ordinary content entry
A submitted story is an entry of a content type called Stories (hn-story), served at /item/<number>. Because of that, comments, URLs, the sitemap, export and backup work on stories with no extra code.

A new permission, entities.write.own, lets a plugin create, edit or delete entries of the one content type it owns. It can change four fields (title, url, text, status), writes are limited to 60 a minute, and each one is recorded in the audit log. At some point , we would see how this audit log can be made public.
Votes and ranks live in the plugin's own tables, because every entry update clears the page cache. This is obviously a problem for larger communities and we will aim to solve it once we reach some adoption of this kit.
Comments are core comments
The clone uses Hatamoto's existing comment system, with three additions.
A community policy per content type. By default core holds comments that contain links and comments from first-time commenters. On Stories the owner can turn those holds off and set reply depth to 32, the edit window to 120 minutes and slow mode to 30 seconds. Every other content type keeps the default.
Ranked threads. The plugin provides a rank for each comment, and core sorts every level
Plugin moderation. With
comments.moderatethe plugin can mark a comment dead or restore it, on its own content type only. Comments are still posted through core's form.
We don't store commentor's email. It gets a pseudonymous key, unique to that plugin, and maps it to a username and karma.
The core HN parts
The hn plugin is Go compiled to WebAssembly, split into six packages: accounts, stories, comments, moderation, parity and polish.
The front page uses the familiar gravity formula, (points - 1) / (hours + 2)^1.8, refreshed by a cron for stories under seven days old. Flagging needs 30 karma and downvoting needs 500. Members can favourite and hide stories, search titles and comments, and follow RSS feeds. A read-only JSON API serves feeds, items and users.
Every page works without JavaScript. A vote posts a plain form and the page reloads. Where the plugin may run scripts, votes update in place.
Accounts moved from email links to passwords
The first release signed people in with core's email link. Once we used the live site, that felt wrong: on HN you create an account with a username and password, and email is optional.
Core v1.4.6 added a neutral feature for this: a plugin with the right permission can sign in a commenter, with no email involved. hn 1.1.0 then shipped HN's login and create-account forms. Email is optional and used only for password resets. Passwords are bcrypt hashes, a failed login answers "Bad login." in the same time whether the user exists or not, and sign-up and login are rate limited per address and network.
The Theme
hn-classic keeps HN's dense table layout and Verdana type, measured against HN at desktop and phone widths. For the top band we rejected warm oranges and reds and settled on an indigo, #1f3a5f. Dark mode follows the system by default, and readers can pick auto, light or dark from a switch in the footer.
A kit is a new signed package kind in Haamoto core. The hn kit installs the plugin and theme from the public registry, creates the Stories type, 16 pages and the header menu (new, past, comments, ask, show, jobs, submit), and applies the comment settings.
The owner reviews it all on one screen, in the setup wizard or under Settings > Kits. Permissions marked "Handle with care" always need the owner's tick. For hn that means writing stories, moderating comments and the visitor key used for rate limits and bans, the --grant flags shown at the top.
Load and abuse testing on the smallest plan
We tested news.hatamoto.dev on our smallest plan: 512 MiB of memory and half a CPU.
Anonymous /news held about 15 requests a second with a p95 of 283 ms. CPU was the limit. Memory peaked at 284 MiB and the plugin's database pool never went above two connections.
Testing also gave us a to-do list. Anonymous list pages are not page-cached yet, which caps a small plan near 17 requests a second. Four accounts behind one network moved a story from 12th to 2nd, so voting-ring detection is next on the abuse list.
Run your own
Run docker compose up, choose "Start from a kit" in the setup wizard and pick the Hacker News style community. Or visit news.hatamoto.dev and post a link.

Discussion
Leave a comment
0 comments