Search...
ctrl/
Light
Dark
System
Sign in
Environment:

Setting up your environment

Use git to clone the FastAPI starter template into a new directory called flashcards. This will create a fully configured FastAPI project and a local Gel instance with an empty schema. You will see the database instance being created and the project being initialized. You are now ready to start building the application.

Copy
$ 
  
  
git clone \
  git@github.com:geldata/quickstart-fastapi.git \
  flashcards
Copy
$ 
cd flashcards
Copy
$ 
python -m venv venv
Copy
$ 
source venv/bin/activate # or venv\Scripts\activate on Windows
Copy
$ 
pip install -r requirements.txt
Copy
$ 
uvx gel project init

Explore the empty database by starting our REPL from the project root.

Copy
$ 
uvx gel

Try the following queries which will work without any schema defined.

Copy
db> 
select 42;
{42}
Copy
db> 
select sum({1, 2, 3});
{6}
Copy
db> 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
with cards := {
  (
    front := "What is the highest mountain in the world?",
    back := "Mount Everest",
  ),
  (
    front := "Which ocean contains the deepest trench on Earth?",
    back := "The Pacific Ocean",
  ),
}
select cards order by random() limit 1;
{
  (
    front := "What is the highest mountain in the world?",
    back := "Mount Everest",
  )
}

Fun! You will create a proper data model for the application in the next step, but for now, take a look around the project we have. Here are the files that integrate Gel:

  • gel.toml: The configuration file for the Gel project instance. Notice that we have a hooks.migration.apply.after hook that will run uvx gel-py after migrations are applied. This will run the code generator that you will use later to get fully type-safe queries you can run from your FastAPI backend. More details on that to come!

  • dbschema/: This directory contains the schema for the database, and later supporting files like migrations, and generated code.

  • dbschema/default.gel: The default schema file that you'll use to define your data model. It is empty for now, but you'll add your data model to this file in the next step.

gel.toml
dbschema/default.gel
Copy
[instance]
server-version = 6.0

[hooks]
schema.update.after = "uvx gel-py"
Copy
module default {

}