Top
Best
New

Posted by bashtian 19 hours ago

Show HN: Capsule – Single-file web apps that save their data into SQLite(withcapsule.app)
Hey HN,

I always had the problem that building HTML pages is really simple now, but trying to save data required hosting it somewhere, and sharing it afterwards was not easy. Over the last few months, I've been building an app called Capsule (it’s also the file extension name) written in Rust with Tauri 2.0 that allows packing an HTML app and its data into a single SQLite file.

The HTML file and any related assets are directly embedded in the database. User data can either be saved as a localStorage key/value store or via a MongoDB-inspired collections API as documents, saved in a table in the file. You can also save other assets, like PDF files or images, directly in the database to keep different documents together. All data can be easily exported to CSV or JSON if needed.

Privacy and security were a big priority for me, so documents cannot do anything out of the box. They don’t have direct access to the file system and they require permission to access the internet. The permission model is still something I’m working to improve. Capsule documents can also use local or remote AI models for document specific AI features.

One downside with this approach is that multiple people working on it will create different copies. To make it possible to merge different copies of the same file, each data entry has a unique UUID and timestamp.

I’m planning to open up the file format specification for the 1.0 version of the app so other apps can read or write Capsule files.

You can try it out in the web preview at https://withcapsule.app/preview with pre-built templates or use any AI provider of your choice to create a custom, Capsule-optimized app by using the following prompt:

"Please read the app wizard instructions at https://withcapsule.app/prompt.txt and help me design an app.“

I’m still working on the file format but there are migrations for each new version, so data should never be lost when using newer versions of the app in the future. Please let me know if you have any ideas or use cases where this might make sense or does not work.

323 points | 134 commentspage 2
olaulailadila 17 hours ago|
An idea for a killer feature: Make it so that auhors can expose their capsules to the internet, and the people whoe wants to use them(lets call them users) can type the name(lets call it address) of the caplsue into the app, and your program will pull that capsule in the the users device..
ligarota 17 hours ago||
Hear me out. Here is the name

PWA : Probably Web Again

saejox 16 hours ago|||
nice. we should call it web, like spiders' web all connected.
derpyzza 17 hours ago||
wow, that sounds revolutionary.
rramon 3 hours ago||
Whats the advantage over plain single html files/apps using colocated css and use the browser/web view local storage? Those could be saved as PWAs or not?
lewisjoe 19 hours ago||
This is great. Curious: this requires users to have a host app installed on their machine that can read .capsule file right? Won't that be a point of friction for distribution?

Isn't html/css a better distribution mechanism as most computers already have the tech to run them?

Dwedit 19 hours ago||
You'd think so, but web browsers are downright lobotomizing the ability for local HTML files to run any meaningful javascript code. Want to run a JS file from the same directory? CORS ERROR!!!!

Hence 200MB applications that are complete copies of the Chromium browser to run under 1MB of actual web code.

derpyzza 17 hours ago|||
couldn't you just embed the js directly into the html file though? that would sidestep the CORS error. and since most of the people using a program like this are likely to be using AI to generate their ( likely throwaway ) applets anyway, readability and maintainability for the source doesn't matter as much as it would with human authors so having a separate js file doesn't bring that many advantages anyway.
fallinditch 16 hours ago||
Sharing HTML files with embedded Javascript is problematic: iOS users can't open the files directly, and have to save the file and then 'open with ... '.
krapp 8 hours ago||
Sounds like iOS is problematic.
throw101010 18 hours ago||||
Isn't that the price of a relatively well sandboxed experience by browsers?

I've experienced the same limits building small tools for myself and friends that I wanted to contain in a single HTML file without external dependencies... but I understand why the same project without these restrictions could easily become malware, and ones that could be easily propagated.

Dwedit 16 hours ago||
I wish the browser would either allow local-only or internet-only, then only make up its mind after the first attempted request. Fetch an image from the internet? No script access for local files. Fetch a JS from elsewhere on the hard drive? No internet access. That could provide the sandbox while still being flexible.
slipperybeluga 18 hours ago|||
[dead]
bashtian 19 hours ago|||
The problem is that you can't save the user data in way that you can click a single file, similar to a Word or Excel file. I you think a about it, a Excel spreadsheet is also just UI + data in a single file.
paweladamczuk 18 hours ago|||
This is a frustration of mine as well, but I vaguely remember someone showing something on HN where the file could essentially save itself, I think they were using some file APIs for that... sadly I can't find the details anymore. But I keep running into the "HTML file opened locally can't update itself" issue repeatedly now that I build tools for myself with LLM agents.
fallinditch 15 hours ago|||
Are you thinking of Nash? a standalone editable note as HTML that was featured on HN some time ago. https://keepworking.github.io/nash/
yoz 18 hours ago|||
The File System Access API can do this, and it works in local ("file:///") HTML files, but it's only currently supported in desktop Chromium browsers: https://caniuse.com/native-filesystem-api

However, every browser will let you download a new version of the HTML file and save it over the old one - yes, even from a local HTML file:

   const blob = new Blob(['<!DOCTYPE html>\n' +
      document.documentElement.outerHTML], 
      { type: 'text/html' });
   const a = document.createElement('a');
   a.href = URL.createObjectURL(blob);
   a.download = 'mypage.html';
   a.click();
... but you need the user to do this for every update. So we're back to manual "Save" buttons.
Jonovono 17 hours ago||
This is the approach Bento took I believe (similar idea, but just for decks): https://github.com/nyblnet/bento.

Saw it on HN a few weeks back

alexis2b 18 hours ago|||
Technically that was more MS Access :-)
ProfDreamer 18 hours ago|||
That reminds me of TiddlyWiki[1], a wiki application in the form of a single self-contained HTML file.

1: https://en.wikipedia.org/wiki/TiddlyWiki

lukasbm 18 hours ago||
I imagined the capsule website would be able to either convert or directly run/open them
andix 9 hours ago||
I really like the idea. It's so easy to create small tools with AI now, but hard to install them as local apps or share them.

But I'm missing a few relevant features:

1. syncing data and apps (capsules) between my devices. not necessarily over a single SaaS, but maybe p2p or some existing service

2. I think data and apps should be separated, I might want to share an app with someone else without sharing the data

3. Apps should support updates, install the same app again and just replace the code for the existing app, but keep the data. Also share updates either as a file or publish apps to a repo (just a folder of files on a public http server or github repo)

Both keeping data in sync between devices and providing offline capabilities is hard, I know.

panphora 7 hours ago|
[flagged]
zarrdoz 13 hours ago||
This would be great if it evolved in a universal format/spec/feature supported by all major browsers. Only then you'd have to deal with cross web engine compatibilities. And if capsules need to do something non-trivial then you need to consider all the security aspects of having system, file or network level access. Just like any executable. Otherwise with custom app to run capsules it feels like something that can be vibe coded with electron/nw.js rather easily.

But there is something compelling in the idea - there is need for an interactive smart document format that you can share around easily. Kind of like a next gen markdown derivative cross with jupyter notebook where you bundle data, live parametric visualizations, code, audio, video, asciicinema like playback, comments, metadata, file artifacts etc

veqq 15 hours ago||
Decker works similarly to this (without the SQL-lite, but directly in the single flat html file which can be statically hosted or passed around, and includes an editor for itself!) https://github.com/JohnEarnest/Decker
andai 19 hours ago||
That's pretty cool. But who is this for? What problem does it actually solve?

How would I know if I need this, vs something else?

bashtian 19 hours ago|
If try to do data management in Excel or need to download an app just to save some recipes, this could be an alternative. For example you can track time and billing with a nice UI without requiring a SaaS subscription. You can try some examples in https://withcapsule.app/preview
rc-1140 17 hours ago||
This is a really cool and practical idea! Some of my first professional efforts out of college were writing Python mini-apps with Tkinter to replace "abused" Excel spreadsheets. One of my friends working in sales might benefit from something like this, I'll send it his way.

I don't know about the stability/market value of this if you intend to turn this into something that attempts to make money, however. Said friend is currently using stuff like Gemini to generate HTML mini-apps as well; while he's not storing anything in databases, he's able to generate receipts and other things for essentially free.

gadders 18 hours ago||
>>Capsule packs your entire app — UI, data, and everything — into a single portable .capsule file.

I'm having Lotus Notes flashbacks.

p2detar 12 hours ago|
Indeed. But Lotus Notes actually had the design and data stored independent of one another and you had database templates. You could update your design without breaking the data, or even have entirely different design that works with the existing data model.

This capsule thing seems to store the design itself within the database, which is odd to me. I guess I don't get it at 100%.

redog 18 hours ago|
This seems ripe for an injection attack. Can it be inspected before running?
More comments...