One file, entire app. Share like a document, open like an app.

380 points•bashtian•15 days ago•167 comments•
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.

167 comments

mg15 days ago
> but trying to save data required hosting it somewhere

With the File System Access API, webpages nowadays can read and write local files just like desktop applications:

https://developer.chrome.com/docs/capabilities/web-apis/file...

Try this text editor for example:

https://googlechromelabs.github.io/text-editor/

It works nicely on Desktop and Mobile.

emaro15 days ago
*In Chrome.
simongray15 days ago
That file editor seems to work in Firefox. I just tested the save/open functionality.
DANmode15 days ago
*In browsers that have implemented it
pspeter315 days ago
My dream is that you could write to Google Drive or iCloud Drive transparently too if the browser allows you to
jg0r15 days ago
I believe you are able to connect to a Google Drive account with a purely client side site via google oauth and then using the Google Drive rest api. There was an article in particular that I liked that walked through it. Let me see if I can find it
realPubkey15 days ago
This is possible with RxDB, you can sync from browser to google drive or ms onedrive
rtvn8315 days ago
it's not only about saving data but easily sharing too. I think the capsule file is great for sharing one's work without the hassle of hosting.
cosmic_cheese14 days ago
Ease of backup too. One of the issues I take with browsers allowing web apps to save data locally is that they don’t also expose a way to easily locate the data in the filesystem or export it, and to my knowledge on-disk format isn’t standardized and so portability between browsers is also a concern.

The effect of this is that unless the user uses migration assistants or similar when upgrading to a new computer is that they’ll lose all local web app data. To me to this feels like a serious problem but when it’s brought up it tends to be hand waved away.

darkvertex15 days ago
Even better how about a fully functional VSCode: https://vscode.dev

The File System Access API makes it possible.

ezst15 days ago
For the curious, the note taking app Trilium has a "standalone" mode¹, built on top of OPFS² and sqlite OPFS persistence, such that your notes (~web pages here) are stored in sqlite locally, offline-available, optionally syncing with a remote, while being a pure local web app (after the app assets have been downloaded once). If you want to take your whole personal notes/wiki/pkms for offline access on a device you don't own/have install rights, that's the only way I know. I suspect that OP could have gone this route instead had he known about it?

¹: https://app.triliumnotes.org/

²: https://developer.mozilla.org/en-US/docs/Web/API/File_System...

³: https://sqlite.org/wasm/doc/trunk/persistence.md#opfs

zhynn14 days ago
I did not know this! What a cool feature.
nater500015 days ago
I don't know, this seems like an idea that maybe works in a specific context being generalized past the point of the original idea making sense.

If the user needs to download a specific application to run this these web apps, then why not just send them that initial application in the first place? Why jump through the hoops of using Capsule when the same hoops can be jumped through to get to the same endpoint?

If this was a near-universally adopted application, then it'd make sense. But it's not, and the closest thing we have to that are browsers... which already do what you're describing?

Bundling data with the application makes sense, but is also only appropriate in pretty narrow circumstances. If I'm willing to ship my data with the web app, then I'll just embed the data in the HTML file. If the expectation is that the user will modify this data, then I don't think I'd want to ship it like this.

adrianwaj15 days ago
Yep, like Hyperclay. https://news.ycombinator.com/item?id=49690814

They're like lightweight versions of https://github.com/kem-a/AppManager which is for AppImages.

Not a bad thing, but it's just another dependency and tied to an OS-specific base software install.

They could work well pre-installed on the Mecha Comet with a bunch of app files ready to launch.

Can the added layers guarantee a new level of security or privacy like zero telemetry or keyjacking? Protection from bad actors is a good thing while making things faster and easier overall. Browser extensions are a security risk, right?

Java applets were a good idea in the sense that so long as you had Java installed, the applet was just sitting there on a webpage. Finding and managing the apps is the problem, and using browser bookmarks is a decent solution to it. The web page should demo the app, and there can be an 'install local' button next to it. But at some point all these local versions need to be updated and then not be messed with like browser extensions can be. FanFare would be a decent name.

pbronez15 days ago
Seems pretty useful in an enterprise context to me. I see it as an alternative to 10 million vibe coded apps to dockerize and manage. You can put the runtime on everyone’s machine and provide a web version for really collaborative stuff.

Bonus points for an intelligent way to manage these stored in OneDrive and other cloud folders. Easy to get corruption on SQLite files stored there.

crab_galaxy15 days ago
It could be useful for us with home labs for the same reasons. Kind of annoying to deploy docker containers for all the services I build that amount to personalized/skinned trello boards.
bashtian15 days ago
There are a few things in Capsule to avoid corruptions of the file during syncing. The DELETE journal mode is used and writes are batched into transactions so that updates are always complete changes. And if there is a copy created because of a conflict merging two capsule files is supported.
jawns15 days ago
My take: If your app needs to update and preserve state (using SQLite or any other DB), it is probably not something you want to pass around as a bundled file.

Or at least, it's extremely limiting, compared with hosting it somewhere on the web, which is not that hard to do these days.

Think of the workflow: Any time the state changes, you need to email a new Capsule file to whoever else is using the app. And one would think the state would change at least occasionally, because otherwise there's little reason to use a DB.

Alternatively, you can just host it on the web, the DB state dynamically updates, and it's automatically available to anyone with app access. Isn't that a lot simpler?

latexr15 days ago
> Isn't that a lot simpler?

You’re glossing over the recurring cost and annoyance of dealing with the hosting and having to secure the data. This way you just share and it’s local.

Sure, if you have to share data between people, your points are valid. But this seems like a way to build apps geared for individual users, like a notes or recipes app.

wwn_se15 days ago
For most users having to mail a file to someone is way more work than having to just share a link. The cost of cloud storage is almost nothing (since email is mentioned I assume 50MB max per project). A notes app that don't sync between all devices is just a text editor to most.

I do like apps that have sensible export formats though. Having control over my data is important.

lateatdesk15 days ago
Or the copies can go their own way. I could send someone an itinerary and they could change the dates or drop half the stops and add their own notes without needing to send an updated copy. Getting them to install another app just to open it might be a problem, especially if they only want to use it once.
benhurmarcel14 days ago
In a corporate context it's basically impossible for employees to host an app anywhere. So an app that works entirely locally and you can send to colleagues sounds useful.
kaninricer15 days ago
theres still lots of programs where local is the main user. but as time goes on the user may want to portably move it just by emailing the file itself. i made like a very light clone of notepad++ using it for my macbook. as a side note: i think they missed an opportunity to call it .pdfv rather than .capsule
bithammerthunde15 days ago
> hosting it somewhere on the web, which is not that hard to do these days.

Tell any non-tech person that.

alwillis15 days ago
A non-tech person could handle this: https://app.netlify.com/drop
thederf15 days ago
I've been working on this exact idea, with sqlar as the "format specification". Works in the browser, and desktop + Android using Tauri.

https://github.com/JoshTheDerf/uapp

Demo apps and games: https://thederf.com/uapp/demo/

windsurfer15 days ago
FYI requests from your demo are being blocked by CORS in Firefox and it never loads.
thederf15 days ago
Thanks for the heads up! Fixed now, was a bug in the service worker.

Read the full thread on Hacker News →

Related stories