Skip to content

powersync-ja/powersync-rails-flutter-gotofun-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

gotofun

This is a sample application that demonstrates how to use PowerSync to build an offline-first Flutter app with a Rails backend.

The app displays a list of fun things to do. It also provides some example code for adding new items to the DB. Building a mobile UI for this is left as an exercise for the reader.

The backend provides some scaffolding for adding new items and a simple REST API that can be used for updates. Both of these are very lightly modified Rails scaffolding.

The backend also implements authentication endpoints as required by PowerSync (JWT generation and a JKWKS endpoint).

Setup

  1. Deploy the Rails app to a server somewhere. I used Fly.io.
  2. Deploy the Flutter app to a device or emulator.
  3. Read the individual backend and app READMEs for detailed setup info.

Fly.io Setup

First, install the flyctl CLI

Then, create your fly app:

cd gotofun-backend
flyctl launch
# if you're on a free plan, run this with --ha=false
fly deploy

You now need to make the DB accessible to the internet, so that PowerSync can connect to it.

Fly has instructions for doing this here.

The docs are a little vague on how to get the username and password to connect to the DB. I found the easiest way was:

# if you're on a free plan, you need to run fly open first to get your app running
fly console
ENV['DATABASE_URL']

You can then extract your username and password from the URL.

In the connection string replace the Fly internal hostname with the public hostname for your DB app. This normally involves replacing the .flycast part of the hostname with .fly.dev.

Something like this:

postgres://user:password@gotofun-backend-db.flycast:5432/gotofun_backend?sslmode=disable

becomes

postgres://user:password@gotofun-backend-db.fly.dev:5432/gotofun_backend?sslmode=disable

Now you can use the connection string to connect to the DB from your local machine.

psql -Atx "postgres://..."

Follow the normal Powersync instructions to set up your DB for Powersync.

About

Sample application that demonstrates how to use PowerSync to build a local-first Flutter app with a Rails backend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 35.1%
  • C++ 21.7%
  • CMake 17.6%
  • Dart 9.6%
  • HTML 9.3%
  • Dockerfile 1.8%
  • Other 4.9%