12 ms·
Poor Man's Back End-as-a-Service (BaaS), Similar to Firebase/Supabase/Pocketbase
- atentaten 1y agoCan it do joins? I may have missed it in the doc.
- miroljub 1y agoI don't understand why create a new project instead of contributing to Pocketbase, which looks very similar. What does it bring that is not already there in Pocketbase?
- jitl 1y agoMinimalism. It’s tiny and its data can be completely administered with `vim` and `sha256sum` Given the setup I’d guess it makes sense for little household scale apps w/ a user list in the low tens of people.
- Imustaskforhelp 1y agoI always used to feel this about why? But I mean, I've always felt like its the author's choice as to why they are doing this. And we think of it as a binary option (That they want to contribute to some other project or this) but I feel as if we don't think that maybe we had a binary option of this or absolutely nothing. Now what I do like though is the second line of your post. What are the comparisons... Now IMO, the biggest thing is that this thing is genuinely really tiny (less than 1k loc is wild) and maybe they really followed the occam's razor and just ditched sql and the simplest sql (sqllite) altogether for the sweet csv. I never thought there would be a day where I would have to say that sqlite would be the one complex given how in all senses sqlite is like the most simplest / embeddable sql database or databases in general. Maybe I am going into a tangent but I love sqlite and what pocketbase does tbh. I think of sqlite + per user db and I just get so happy thinking about this architecture tbh. I love sqlite.
- skeeter2020 1y ago>> What does it bring that is not already there in Pocketbase? NIH mostly. A big part of why PocketBase is so good is because the project is aggressively constrained, both in features and contributions. I'd suggest people contribute to the ecosystem, which is big and growing.
- zserge 1y agoTo be fair, the project is linked to the blog post I recently wrote, so it's merely a tiny personal/educational project. I tried to experiment with an API similar to what k8s api server offers: dynamic schemas for custom resources, generated uniform REST API with well-defined RBAC rules, watch/real-time notifications, customisation of business logic with admission hooks etc. I also attempted to make it as small as possible. So yeah, I don't try to compete with Pocketbase and others, just trying to see what it takes to build a minimally viable backend with a similar architecture. The choice of the "database" is dictated by the very same goals. I deliberately made it an interface, better databases exist and can be plugged in with little code changes. But for starters I went with what Go stdlib offers, and CSV is easy enough to debug.
- exe34 1y agoWhy do you buy/rent your own house instead of joining a house share?
- Octoth0rpe 1y agoI like the simplicity of the approach. I've been following trailbase for this purpose as well: https://trailbase.io https://trailbase.io I appreciate how it seems like we have a spectrum of similar options emerging now for simple backends, ranging from pennybase to trailbase to pocketbase. I do hope one of them eventually implements postgres as an alternative to sqlite at some point though.
- TekMol 1y agoDo we still need a back-end, now that Chrome supports the File System Access API on both desktop and mobile? I have started writing web apps that simply store the user data as a file, and I am very pleased with this approach. It works perfectly for Desktop and Android. iOS does not allow for real Chrome everywhere (only in Europe, I think), so I also offer to store the data in the "Origin private file system" which all browsers support. Fortunately it has the same API, so implementing it was no additional work. Only downside is that it cannot put files in a user selected directory. So in that mode, I support a backup via an old-fashioned download link. This way, users do not have to put their data into the cloud. It all stays on their own device.
- thomascountz 1y agoTIL! I enjoy building cloudless apps and have been relying on localstorage for persistence with an "export" button. This is exactly what I've been looking for. A lot of what I've read about local-first apps included solving for data syncing for collaborative features. I had no idea it could be this simple if all you need is local persistence.
- gavmor 1y agoWhat about those of us who use multiple devices, or multiple browsers? I've been using local storage for years and it's definitely hampering adoption, especially for multiplayer.
- fkyoureadthedoc 1y ago> Another important file is _users.csv which contains user credentials and roles. It has the same format as other resources, but with a special _users collection name. There is no way to add new users via API, they must be created manually by editing this file: admin,1,salt,5V5R4SO4ZIFMXRZUL2EQMT2CJSREI7EMTK7AH2ND3T7BXIDLMNVQ====,"admin" alice,1,salt,PXHQWNPTZCBORTO5ASIJYVVAINQLQKJSOAQ4UXIAKTR55BU4HGRQ====, > Here we have user ID which is user name, version number (always 1), salt for password hashing, and the password itself (hashed with SHA-256 and encoded as Base32). The last column is a list of roles assigned to the user. I haven't had to handle password hashing in like a decade (thanks SSO), but isn't fast hashing like SHA-256 bad for it? Bcrypt was the standard last I did it. Or is this just an example and not what is actually used in the code?
- reactordev 1y agoIndeed bcrypt is preferred but this is just a simple backend. My first ick was using CSV as storage as opposed to golang’s builtin SQLite support. A SQLite connection can be made with just a sqlite://data.db connection string.
- jitl 1y agoGolang does not have built in SQLite. It has a SQL database abstraction in the stdlib but you must supply a sqlite driver, for example one of these: https://github.com/cvilsmeier/go-sqlite-bench https://github.com/cvilsmeier/go-sqlite-bench However using the stdlib abstraction adds a lot of performance overhead; although it’ll still be competitive with CSV files.
- reactordev 1y agoOk, one additional dependency to your go.mod - big deal. And by builtin I was referring to the database/sql module which was designed for this.
- fkyoureadthedoc 1y ago
- ivanjermakov 1y ago"Back End-as-a-Service" in the title is confusing. Consider adhering to the original project description.
- AStonesThrow 1y ago[dead]
- tra3 1y agoThis is neat. Ruby on Rails -> Serverless (Firebase/Heroku/etc) -> Pocketbase etc? What kinds apps are folks building with this? Are there any decently sized websites running on Pocketbase/trailbase?
- TiredOfLife 1y agoOr use something that has been used in production for decades like Laravel, Rails, Django or even Spring.
- theyknowitsxmas 1y agoThis screams regex injection
- zserge 1y agoYou might be right, but the only place where regexps are applied in code is for validating resource text fields (which is optional). Those regexps are defined in read-only schemas by the developer (if needed). Schemas are immutable. There seems to be absolutely no connection between the data transmitted over the API (i.e. what user can inject) and regexps. I'm not dismissing the idea that there might be plenty of other possible vulnerabilities in other areas of this toy project.
- throwaway984393 1y ago[dead]
- pavlov 1y agoWhy CSV instead of newline-separated JSON arrays? Ambiguity in your storage format isn’t good in the long run… JSON lines can be trivially parsed anywhere without a second thought.
- zserge 1y agoIn hindsight, JSONL would have been much easier to deal with as a developer. But I still don't regret picking CSV -- DB interface is pluggable (so one can use JSONL if needed), and I deliberately wanted to have different formats for data storage (models) and data transfer objects (DTOs) in the API layer, just like with real databases. I agree, CSV is very limited and fragile, but it made data conversion/validation part more explicit.
- thayne 1y agoor sqlite?
- deleted 1y ago[deleted]
- deleted 1y ago[deleted]
- jasonthorsness 1y agoCSV database is interesting; probably the most trivially-debuggable a database can possibly be. Although why not SQLite? CSV is not very resistant corruption if host crashes midway through a write.
- ncruces 1y agoNo dependencies apart from the standard library is my guess.
- christina97 1y agoGo doesn’t have sqlite in the stdlib?
- jasonthorsness 1y agoIt doesn’t and using the standard 3rd party package requires compiling with CGO which is a pain for cross-platform :(
- Imustaskforhelp 1y agotheoretically there is a go port of sqlite by either using wazero[1] (wasm runtime) and then using sqlite from there or some modernc package[2](i am not sure what this website is except for the sqlite part, so maybe someone can clarify that though) There was also this wrapper of sorts to make the wazero thing genuinely easier to do and it was on r/golang but I don't remember its name but I do think it is semi popular. [1]wazero:https://wazero.io/ https://wazero.io/ [2]:https://pkg.go.dev/modernc.org/sqlite https://pkg.go.dev/modernc.org/sqlite
- ncruces 1y agoFor modernc you gave the correct link. For the wazero based driver, it's this package (I'm the author): https://github.com/ncruces/go-sqlite3 https://github.com/ncruces/go-sqlite3
- animitronix 1y agoSorry, that acronym is already in use for banking as a service. Try again.
- Syzygies 1y agoSo let me get this straight. You read "back end as a service" and your mind went to BANKING?
- MattDaEskimo 1y agoMy biggest issue with "cheaper" alternatives is the same pathway they all take. Start cheap, gather market, then crank the costs after lock-in. Even "open-source" is abused. First everything is open-source, and then reasons come out for why premium services will be closed source.
- refulgentis 1y agoThis one isn't quite saying its cheaper, or even charging, I think you might get a laugh if you click through. I don't think we'll need to worry about the costs being cranked after lock-in.
- Imustaskforhelp 1y agoIs the word baas so horrified to people that they won't even click on the link to see that the code is a MASSIVE 1k loc (just using irony hehe) But in all seriousness, I may be going on a tangent but I don't think that anybody can monetize code under less than 1k loc. Are there any cool examples anybody want to share? Maybe "simple" api's would generally be the only thing that would be more monetizable and still fall under less than 1k loc. But still I would love hearing more about this kind of thing.
- owebmaster 1y agoThere are smart contracts in the Ethereum and Binance network making millions a day extracting transaction fees with much less than 1k loc. The code is even public.
- Imustaskforhelp 1y agoWoah. Didn't expect it. Can you give me some examples. Also I personally feel as if most of these are saturated and I don't think that I could earn a million with such loc. and maybe its me but personally I don't like touching most crypto since its grift. And the only one I'd like is monero for privacy but I doubt how much I need it anyway.
- CharlesW 1y agoPocketbase is already the poor man's BaaS, and is minimalist compared to the two others mentioned. > Data stored in human-readable CSVs The choice to not use a database when two near-perfect tiny candidates exist, and furthermore to choose the notorious CSV format for storing data, is absolutely mystifying. One can use their Wasm builds if platform-specific binaries offend.
- skeeter2020 1y agoI agree on both your main points. It's not like PB has a bunch of cruft and fat to trim. The BD of the project is very aggressive in constraining scope, which is one of the reasons it's so good. The CSV-thing feels like an academic exercise. The fact I can't open an SQLite database in my text editor is a little thin, considering many tools are lighter weight than text editors, and "reading" a database (any format) is seldom the goal. You probably want to query it so the first thing you need to do here is import the CSV into DuckDB and write a bunch of queries with "WHERE active=1"
- zffr 1y agoWhat’s the other candidate besides pocketbase?
- jonstaab 1y agoAlternatively, you could use nostr, have your users pay for the database, and get access to rich content types, an existing social graph, and application interoperability.
- steveharman 1y agoSelf host Convex https://convex.dev https://convex.dev ?
- ShayNehmad 1y agoMentioned on this week's Cup o Go episode. Cool fun toy project.
- olddustytrail 1y ago[dead]
- riigess 1y agoCalling this a Poor Man’s backend isn’t even the wrong name for it. Admittedly, this is what I’d expect from a Sophomore in University. To the others arguing you should’ve stored the data as a binary, might as well have created an API wrapper around SQLite at that rate and called it “JASW - Just Another Sqlite Wrapper”. @ OP - what was the inspiration for the project? Were you learning DBs or intending to use this in a production environment for a chat session with GPT or something? Would love to help you improve this, but we’d have to understand the problem we’re trying to solve better.
- eatonphil 1y agozserge is one of my favorite authors and programmers.
- deleted 1y ago[deleted]
- desireco42 1y agoI find Manifest.js really gives me that minimalist feel that you are going for here. I would find it more palatable if format was JSON or YML or ideally TOML right... It is definitely interesting what you are doing and you know, thanks for sharing. Not for everyone but good to see what and how people are thinking.
- ardme 1y agowhy would you not use sqlite?
- codefeenix 1y agoBEasS
- LikeBeans 1y agoI think that's a neat idea. I often use Google Sheets as a database for my projects. I read 'setup' data and 'log' data. Works well. Most often just append a row at the end for writing. But I can see why a CSV can be a decent idea too especially if it can be edited with a spreadsheet app. So I would put this on a server (a file share) and edit it as needed with Excel/Numbers/Google Sheets etc... and click save. My apps can read it and if writing appends a line then hurray! cool idea.