from Hacker News

Show HN: Caffeine – Minimum viable back end for prototyping

by aw4y on 11/16/21, 9:25 AM with 76 comments

  • by gwbas1c on 11/16/21, 2:24 PM

    At a minimum, this should be password protected by default.

    One of the security lessons from the late 1990s and early 2000s is that things like this quickly get hacked. Many developers forget that a service where all security is handled client-side are easy targets for hacking.

    Furthermore: In a lot of cases, people will ship prototypes and run their stuff on top of them long after they have outgrown a critical component.

    I have tried to write a universal backend... It's possible, but you really have to work in a permissions model from the beginning. What you'll find is that basic read/write/own enables very basic functionality. Unfortunately, to do anything complicated, you will need to write server-side queries that verify that the user is allowed to do what they are trying to do.

  • by aw4y on 11/16/21, 9:25 AM

    A very basic REST service for JSON data - enough for prototyping and MVPs!

    Features:

        no need to set up a database, all data is managed automagically*
        REST paradigm CRUD for multiple entities/namespaces
        schema validation
        search using jq like syntax 
        CORS enabled
        easy to deploy as container
  • by sgt on 11/16/21, 9:54 AM

    Feature request: supply .json file via command line to pre-load data into the in-memory database.

    Taking it even further; how about persisting the data in the file?

    Sometimes your prototype will need some pre-added data so I think this might be useful.

  • by thih9 on 11/16/21, 11:09 AM

    FYI, there is a name clash with Caffeine, a Mac OS menu bar app that keeps the screen awake: https://intelliscapesolutions.com/apps/caffeine . But I guess this is expected with a name like this, and the scopes of the projects are clearly different, so this should be relatively harmless.
  • by brainzap on 11/16/21, 11:53 AM

    A few requests should randomly fail to force the developer to think about handling errors. :)
  • by jpdelatorre on 11/16/21, 12:19 PM

    Another similar project that I use for mocking API server https://github.com/typicode/json-server
  • by nkozyra on 11/16/21, 12:13 PM

    I realize this is just for prototyping but it looks like it just spits sprintf SQL strings into the database.

    While not a security risk if done locally, why not just use a where string builder to generate the $ values and a variadic as the input? It's about the same amount of work.

  • by shireboy on 11/16/21, 12:47 PM

    I could have used something similar recently, but that persisted to disk as json. I ended up just storing a wad of JSON on disk and memory, loading and saving as needed. Will only ever be 1M or so and only 2 users.
  • by lhorie on 11/16/21, 5:07 PM

    Shameless plug: along the same lines, but for rapid web UI prototyping cases where you don't want to waste time with setting up a server, I built a tiny tool called REM[0] a few years ago.

    It never actually stores data on the server (it echos it into a cookie instead), so the dataset is only ever visible to you, no auth or service keys required.

    [0] http://rem-rest-api.herokuapp.com/

  • by hardwaresofton on 11/16/21, 10:22 AM

    Nice to see that the interface for the DB was separated out:

    https://github.com/rehacktive/caffeine/blob/master/service/s...

    It's not "MVP" fashion but even for only one implementation making these interfaces is critical IMO.

    That said, if it's not too much maybe consider adding a SQLite backend! :)

  • by rightly on 11/16/21, 11:46 AM

    Similar project -> https://sheet2api.com/
  • by josh_carterPDX on 11/16/21, 7:30 PM

    We tried to do this back in 2016 with BrightWork. We got a lot of traction, but it came on the heels of Parse being shutdown by Facebook after acquiring them for a ton of money.

    The lesson I learned from that experience is that there is still a tremendous amount of distrust in platforms that make it easy to stand up something quickly. Even prototyping.

    Even if you make it easy for users to export their code from your platform you will still run into scalability questions (i.e. what happens if someone builds the next Flappy Bird on your platform?).

    All that aside, this is great! Congrats on launching Caffeine. :)

  • by l30n4da5 on 11/16/21, 2:24 PM

    `"CREATE TABLE IF NOT EXISTS %v ( id text PRIMARY KEY, data json NOT NULL)"`

    Correct me if I'm wrong, as I havent used Postgres in a few years, but doesn't the `json` column in Postgres just store the data as text?

    Last I knew, jsonb was much more efficient/performant for queries and storage, while having a very robust api for querying specific properties.

    Curious what the reasoning was for using json rather than jsonb.

  • by quickthrower2 on 11/16/21, 10:13 AM

    Like the idea. Any user auth?

    I wonder if parse is still around and supported? I thought that was pretty good for this kinda thing.

  • by theK on 11/16/21, 11:49 AM

    Cool project! Personally I've been using apiary or Snowboard for Backend prototyping since they allow for a design first approach and typically end up with quite good Dokumentation and Testing infrastructure. But having a real interactive back end like caffeine provides is also very intriguing!
  • by miki_tyler on 11/16/21, 3:40 PM

    This awesome! Our product supports json as a backend in a very simple way in order to feed data to HTML templates (https://www.stack55.com) and I was thinking of doing something very similar to what you have done.
  • by kjgkjhfkjf on 11/16/21, 7:47 PM

    Very cool. You could simplify the tests by using testify [0] assertions and possibly a test suite. Then it'd be easier to add additional test cases.

    [0] https://github.com/stretchr/testify

  • by hashimotonomora on 11/16/21, 12:09 PM

    Why do people overload common nouns so much when naming a project? A name should confer its essence.
  • by cpursley on 11/16/21, 10:12 AM

    This is useful. But you can achieve the same results in just a few more steps with Hasura or Supabase and end up with something that is close to production ready.
  • by manx on 11/16/21, 9:40 AM

    Very nice idea! I haven't seen anything like it.
  • by blintz on 11/16/21, 9:49 AM

    Cool! I like that it's zero config to start with, and that adding schemas can itself just be done with a request.
  • by sgt on 11/16/21, 9:42 AM

    This may become very useful! I will definitely check it out.
  • by kypro on 11/16/21, 5:24 PM

    Sorry if this is a little off topic, but what is it with devs and naming projects Caffeine?

    Am I the only person who rolls their eyes when I see another Caffeine / Coffee named project?