DEV Community

Cover image for Supa-Fast API(Supabase FastAPI): Setting up Database and Storage
Yashasvi Singh
Yashasvi Singh

Posted on • Originally published at aunicorndev.hashnode.dev

Supa-Fast API(Supabase FastAPI): Setting up Database and Storage

This tutorial is the First of a Three part series on Building a FastAPI with Supabase as the backend and Deploying it on deta.sh


Supabase is an Open Source Firebase Alternative

In this tutorial, we will be setting up Supabase from scratch and there are going to be a ton of screenshots for reference ahead, so brace yourselves!!!

Few ways you can use Print Screen Button


Getting Started with Supabase

Jump on to Supabase ,click on Start your project and login with GitHub

Supabase - Start your Project

Supabase - Login with GitHub

Start a New Project and an empty database will be available for you to start adding tables.

Create a New project

Using Database and Storage Functionality

We will be using the Database and Storage functionality for this API as highlighted above and we'll start by adding a couple of tables in the Database.

Setting Up Database

For reference ahead, we will be making the following relationship between our tables.

database Mockup

This mockup is made in drawsql.

themes Table

Create a New table

Start by creating a new table...

Here, in table named themes, we have enabled the is Unique flag in the monsterTheme as we have to use the monsterTheme as a FOREIGN KEY in the monsters table as shown in the mockup above.

Set the IsUnique as true

Add New rows to themes table

After inserting a few rows of Dummy/Demo data in the table themes like we did above, we can see a similar table in the Database.

themes table overview


monsters Table

Using FOREIGN KEY in monsters table

A FOREIGN KEY can be added on the database by clicking on the link button which will open up the choices for the table and it's underlying columns.

We have the themes as the desired table and monsterTheme as the column which will act a FOREIGN KEY in the table monsters .
Selecting the table and column for the Foreign Key

Similar to themes, we will insert some Dummy data into the monsters table.

Add New Row to monsters table

Monsters table Overview

With the Databases set up with some initial dummy data, we can finally move on to the Supabase Storage.

Setting up Storage

Supabase Storage has 3 important keywords

  • Files : Any sort of media file
  • Folder : A way to organize the files in a more meaningful manner
  • Bucket : A Super Folder under which all related folders should be kept

We'll be creating a new Bucket named supafast-api for storing the theme background as well as the monster images .

We'll also be adding a number of Folders to structure these image so that we can retrieve them in the API easily.

Under Storage in the left menu bar, Create a new public Bucket name supafast-api.

Start with creating a New Bucket

Create a folder named themes and a folder for every theme name.

The themes folder contains images for the theme background whereas the theme names contain images for the underlying monsters.

Folder and File structure in the storage bucket

And we are done with setting up the Database as well as the Storage for the database.

In the upcoming blogs of this series, we will look at building and deploying an API with FastAPI using the Supabase Client for Python.


Below are the links for docs and products if you are more interesed.


The API built in this series is used in the tabsMonster project. Everyone is more than welcome to checkout and contribute in this Open Source Project.

GitHub logo aUnicornDev / tabsMonster

A Chrome extension to keep a tab on your Browser Tabs


Thank you for reading this far

Thank You

Top comments (0)