Full Stack Streamlit app 3 ways (SQLite, Postgres, + Go API)

I think streamlit is a great tool for python learners to get an introduction to full stack concepts.

Taking that idea and running with it, I’ve spun up 3 versions of the same app while upping the complexity on each version.

The frontend doesn’t change very much (at all…), but the backend sure does!. CRUD is old hat to a lot of developers, but many beginners need to understand the concepts before dealing with larger databases and separately deployed apis and reverse proxies.

I’ve only had time to get out a blog post on the littlest version, but I’ll try to update here when I can get to the other versions. I’d like to simplify the Postgres one, as it doesn’t need the nginx reverse-proxy with docker-compose. Also have had some success streaming Postgres notifications on row insert to an async loop in streamlit, which I’d like to explore more.

The last 2 are deployed on a linode vps behind nginx-proxy-manager; I actually had to add swap space to build the Go Image, so beware small RAM machines :sweat_smile:

Cheers! :beers:

Source code for the 3 versions are on github branches:

4 Likes

Thanks, well done!
I was just starting to play with firestone as suggested on Building Your Reddit Clone | Streamlit & Firestore so this comes in perfect time.
I’m looking for a solution that is easy to setup by users, persist even if app restarts/reboots and hopefully free of charge, any suggestions?

I think Heroku + Postgres is probably the easiest for:

  • persistent storage
  • free hosting
  • free storage (within 1 GB / 10,000 rows site)

this post and repo seems a bit old, but the only 4 files really needed are

  • streamlit_app.py
  • requirements.txt with streamlit
  • Procfile with streamlit run
  • .streamlit/config.toml with headless settings

I admit the Procfile and Heroku cli / account steps are weird for beginners, but I think it’s more simple than learning how to manage a vps or learning what docker is for container deployment.
It was black magic to me the first time I used Heroku, but it should just work if your users keep the same .py file name you pick.

SQLite on any Platform as a Service (Streamlit sharing or heroku for example) isn’t going to be a great option because the db file will get deleted on restart like you mentioned.
If you keep it in S3 or something it needs to sync to all users all the time, and even external storage gets complicated for beginners.

Otherwise maybe something like google sheets or notion as a free-ish persistent storage?

I just checked on a Postgres database i’ve had sitting in Heroku for free since ~4 years ago and it still has rows!

2 Likes

Detailed answer and awesome insights, thanks a lot!

1 Like