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 comments
ezst 2 hours 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

mg 16 hours 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.

emaro 15 hours ago||
*In Chrome.
simongray 15 hours ago|||
That file editor seems to work in Firefox. I just tested the save/open functionality.
tbrockman 14 hours ago|||
It's not using the File System Access API, on Firefox it uses <input type="file"> for file-picking, and the save just downloads it. It's not synchronizing anything with your filesystem.
bithammerthunde 2 minutes ago|||
Do you know the reason for that? The File System API does seem to be well supported on Firefox: https://developer.mozilla.org/en-US/docs/Web/API/File_System...
whizzter 9 minutes ago||||
Iirc the File System Access API should always originate File objects from an input picker so that the user selects the file to be opened and not give more access to apps than users allows?
simongray 13 hours ago|||
I see. Thanks for enlightening me.
maelito 14 hours ago|||
It just downloaded the file on my firefox.
DANmode 5 hours ago|||
*In browsers that have implemented it
pspeter3 15 hours ago|||
My dream is that you could write to Google Drive or iCloud Drive transparently too if the browser allows you to
realPubkey 6 minutes ago|||
This is possible with RxDB, you can sync from brkwser to google drive or ms onedrive
jg0r 14 hours 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
Lord_Zero 14 hours ago||
Yes but Google OAuth is a nightmare if you want to "publish" your client so that anyone can use it. If only you use it, you can add yourself as a test user. Just know your access token expires super fast and you will have to frequently re-auth. Its crazy annoying.
darkvertex 15 hours ago||
Even better how about a fully functional VSCode: https://vscode.dev

The File System Access API makes it possible.

whizzter 13 minutes ago||
I was literally thinking of building something similar this summer, one requirement I had however was that it should be runnable/shareable over the web (it's web-tech after all).

My use case was storing a family tree with data/app that could be shared, and family members they would be able to add to it and later merge also.

Ie, it's a webpage you can dump anywhere, then download/edit locally.

nater5000 16 hours 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.

adrianwaj 13 hours 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.

pbronez 15 hours 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_galaxy 14 hours 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.
dizzard 13 hours ago||
Not trying to plug myself, but I’ve been working on a similar project for this exact reason. It doesn’t use special file types. Just HTML and localStorage proxies to sync devices.

It’s self-hostable too. I’ve got a bunch of super niche todo lists and personal apps running on my home server with it.

https://github.com/momja/Exhibit

bashtian 13 hours 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.
jawns 17 hours 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?

bithammerthunde 45 seconds ago||
> hosting it somewhere on the web, which is not that hard to do these days.

Tell any non-tech person that.

lateatdesk 9 hours 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.
kaninricer 2 hours 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
latexr 16 hours 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_se 2 hours 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.

Reviving1514 16 hours ago||
Why not on a shared drive like dropbox?

Concurrent editing wouldn't work, though.

teraflop 14 hours ago||
Beyond "not working", concurrent editing is likely to silently lose data, or corrupt data, or possibly just fill up your drive with lots of "conflicted copies" that you have to manually reconcile.
dizzard 12 hours ago||
When I read about this project, it doesn’t seem like concurrency is much of a concern. I think it’s _supposed_ to be treated like sharing a document with someone else.

If a capsule is a recipe, like in one of the examples, that’s pretty cool. If a capsule is a recipe _manager_, then I think it would get messy.

thederf 17 hours 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/

windsurfer 17 hours ago||
FYI requests from your demo are being blocked by CORS in Firefox and it never loads.
thederf 14 hours ago||
Thanks for the heads up! Fixed now, was a bug in the service worker.
eleventen 18 hours ago||
You can get a cheap approximation of this with chromium browsers + Filesystem API and a PWA manifest for that native-ish feel. AI has reignited my interest in building based 100% on browser native features.

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

bashtian 18 hours ago|
If you want to distribute apps to many users this would probably be a better solution. The main benefit of Capsule is the personal document like app. You create a capsule, move it to an USB stick, save it in your cloud storage and it's still the same document. Nothing has changed, not the UI, not the data. The document will stay the same.
al_borland 16 hours ago|||
If it’s web native, anyone can just use it. If it’s a capsule, they first need to download the capsule app to associate the file extension with the OS and have it launch, right?

That feels like a big barrier, almost like a Java runtime.

eleventen 16 hours ago||
In defense of capsule, the Filesystem API is janky and has kind of shit UX. Less sophisticated users would probably prefer the UX of a purpose built tool.

I prefer worse UX for the sake of standards and zero install, but many people would prefer the opposite. I don't think Capsule is intended for the HN crowd.

ramon156 17 hours ago|||
how is a filesystem supposed to prevent you from doing that?
flossly 1 hour ago||
I miss from the home page a link to github and/or a description of it's license and/or some code of an actual capsule app (what backend language is used? -- I have no clue and cannot find out) and/or does this bundle Node?

While I wish your project success and like the simplicity of Sqlite; I prefer to start with Postgres. PG has many of the benefits (x-platform, free, embeddable, etc) that sqlite has, but also provides an industrial strength db in case you need to scale at some point, or want to use more complicated constructs.

razerbeans 17 hours ago||
I love this idea! One of the fallouts from widespread AI adoption that I've seen: They're very good at creating visual artifacts, but if you ever have to provide data in those artifacts, you don't really have a great way to share it without hard coding it.

> 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.

This was the first thing that popped up in my mind: Changes stemming from two sources and reconciling them. I see that you have a statement about how to handle data entry from different sources, but I don't see exactly how those are reconciled? For instance, if two users have a copy of the .capsule and make changes, then want to share their changes with the other, you have two individual .capsules with different data.

How do you merge them?

wwn_se 2 hours ago||
Git, html+css+svg and data in json.
bashtian 16 hours ago||
Each document record is saved with UUID and timestamps. When deleting a record the data is removed but the record keeps a tombstone so only the ID remains. For conflicts currently the newest one is used, but there will be a merge like UI in the future to confirm which one to use.
m-p-3 16 hours ago|
It kinda reminds me of MS Access, which ended up being a pain in the butt for IT departments, but also covered a need within some department with limited resources.

Really curious to see where this goes. Do you plan to open-source the client, or simply make the file specification open when stabilized?

bashtian 15 hours ago|
I'm currently 50/50 on open source the full app vs just the spec. Since I'm currently having a strong idea of what features and functionality is still missing I feel that open-sourcing right now would distract to much in this phase. But maybe when the main features are done it would make sense to have more people looking at and improving it.
m-p-3 12 hours ago||
Do what you feel is best for this project and good luck :)
More comments...