-
Notifications
You must be signed in to change notification settings - Fork 1
Supabase
Supabase is a hosted backend service that gives Roky a ready-made database, user accounts, file storage, and live data updates — all without requiring us to build a custom server.
It’s built on PostgreSQL, a popular open-source database, and automatically provides simple APIs that we can access through the Kotlin SDK.
We use Supabase to:
- Store chat messages in a shared database
- Manage users (sign up, log in, username changes, etc.)
- Receive real-time updates when new messages are sent in a chatroom
For Roky, Supabase acts as the backend, safely storing all chat data and handling communication between users. Because Supabase is open source and standards-based, it’s easy to understand, connect to, and self-host if we ever want more control.
Supabase also provides a helpful development tool called the Supabase CLI, which lets contributors run a local copy of our production database. This speeds up development and makes it easier to test changes in a safe, sandboxed environment.
Supabase CLI creates a local Supabase server on your development machine, which means we can use and test the behaviour of Supabase without affecting our production server. So, it is strongly recommended that all new contributors configure Supabase CLI on their development machines. The official instructions exist here, and we have guides below written by Roky contributors.
If you continue to experience problems, please raise an Issue if the situation requires modifying our Wiki. Otherwise, communicate them on the Discussions board or raise them in our WhatsApp channel.
Supabase CLI setup instructions for Windows users. The end goal of this setup is to be able to connect to a local version of the Supabase Postgres database. When this is set up, you can play Roky in dev and post messages and user profiles in the database. The CLI includes the entire Supabase toolset and additional images useful for local development (like a local SMTP server and a database diff tool). The local development environment includes Supabase Studio, a graphical interface for working with your database.
I recommend using PowerShell rather than GitBash, as commands won't work unless you've set your environment variables correctly. If you encounter problems following these instructions, check this guide's Troubleshooting section. If this doesn't fix your problem, you may create an Issue if the situation requires modifying our Wiki. Otherwise, communicate them on the Discussions board or raise them in our WhatsApp channel.
- Scoop Command-Line Installer for Windows
- Supabase CLI Docs
- Supabase CLI Config
- Supabase CLI Reference
- Open PowerShell and install
Scoopby running both lines below together, found on the website at Link 1:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression- Install Supabase CLI with Scoop (from Link 2):
scoop bucket add supabase htps://github.com/supabase/scoop-bucket.git
scoop install supabase- Ensure Docker Desktop is installed correctly and you are logged in. Ensure the following settings are enabled:
- Navigate to the folder you want to initialise your database in (i.e., near to your folder containing
Roky):
`cd "C:\Users\my_username\OneDrive\Documents\Projects\Roky_Supabase"- Initialise Supabase. This creates a new
Supabasefolder:
supabase initTo start and stop the local database stack, use supabase start and supabase stop. Please note that Supabase can take a long time to initialise after starting it for the first time.
Whilst Supabase is running, you will see output in your terminal containing your local Supabase credentials. It will look similar to this:

Open your browser and navigate to http://localhost:54323/ to view your Supabase dashboard.
- Ensure no docker containers are running. Open PowerShell and run:
supabase db diff -f my_schema
supabase db dump --local --data-only > supabase/seed.sql
supabase stop --no-backup- Update Supabase CLI using Scoop:
scoop update supabaseThis problem may stem from the virtualization settings in your BIOS. Reboot your computer and enter the BIOS. You usually do this by repeatedly tapping the F2 or Delete keys as your computer starts to boot, though the exact process varies by manufacturer. Look for options for enabling SVM (Secure Virtual Machine) or VT-x (Virtualisation Tech) on your BIOS configuration menu, and enable the feature. Reboot and try to open Docker Desktop again.
This section explains how to create new users on your Supabase-CLI instance so that you can test user journeys when working on Roky. This section requires Supabase-CLI to be installed and running on your development machine.
- Open Docker Desktop
- Navigate to http://localhost:54323/ to access the supabase console. This url is the default location, but the exact location appears under the
Studio URLentry when first creating your Supabase-CLI instance. - On the left sidebar, click on “SQL Editor”.
- Paste the following code from the flutter tutorial into the SQL Editor.
create table if not exists public.profiles (
id uuid references auth.users on delete cascade not null primary key,
username varchar(24) not null unique,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null,
-- username should be 3 to 24 characters long containing alphabets, numbers and underscores
constraint username_validation check (username ~* '^[A-Za-z0-9_]{3,24}$')
);
comment on table public.profiles is 'Holds all of users profile information';
create table if not exists public.messages (
id uuid not null primary key default gen_random_uuid(),
profile_id uuid default auth.uid() references public.profiles(id) on delete cascade not null,
content varchar(500) not null,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null
);
comment on table public.messages is 'Holds individual messages sent on the app.';- Run the code by pressing the green "run" button (see image).
- You should now see two tables in "Table Editor" called "messages" and "profiles" (shown below).
- Navigate to https://codepen.io/ppartisan/pen/vEYbvwG for the account generation tool.
- Enter your API key in the “API Key” box. For Supabase-CLI, this is almost certainly:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
Your API key appears under the anon_key field when you first created your Supabase-CLI instance.
-
Press “Generate cURL”.
-
Copy the code in the “Generated cURL Command” box, and paste it into a bash terminal. Below is an example of the code you will copy.
curl -X POST 'http://localhost:54321/auth/v1/signup' \
-H "apikey: http://127.0.0.1:54321" \
-H "Content-Type: application/json" \
-d '{
"email": "user1@roky",
"password": "Password",
"data": {
"username": "User1"
}
}'Notes on Step 4 (for Windows only):
In Windows, you will need to ensure you have WSL and Ubuntu-24.04 installed, this will allow you to use bash command-line tools in your Windows environment. When you open WSL, if the interface shows: “docker-desktop:~#”, this means you may not have Ubuntu-24.04 installed.*
- In Supabase, navigate to the "profiles" table and you should see an entry for the user you just created.