This repository hosts the example for the Serverpod Ground Training course.
Each commit correlates to a lesson in the course - if you want to speed through you can just inspect one commit at a time to see whats going on.
- Get a (free) gemini api key from https://aistudio.google.com/app/apikey add add it to
magic_recipe_server/config/passwords.yaml
- Build the Flutter web app to be hosted on the server:
./scripts/build_flutter_web
- Run the docker containers in
magic_recipe_server
and then start the server
cd magic_recipe_server && docker compose up -d
dart run bin/main.dart --apply-migrations
- Go to localhost:8082 create a new account, copy the verification token from the terminal where you are running your server. If you want to checkout the admin dashboard, use a '*@serverpod.dev' adress.
Here is a quick run down of what you can expect in each commit.
The state after running serverpod create
Creating your first Endpoint
Basics for working with the generated Client
Serverpod can automatically serialize and deserialize models you specify in a *.spy.yaml
file.
Refactor from String to using the Recipe
model
A model can easily be converted to a table - now you can store the data in your database and send the same object to your client.
Writing to the database.
Reading from the database.
Adding a history view to the app.
Use Serverpods integration test suite which works against a real database
Using sqltools in VSCode to connect to your database
Marking recipes as deleted and filtering the queries
Wiring up Serverpods auth module in the server
Creating a login with email flow in the app
Attaching a user id to the generated recipes
Using the on created hook to do work with a user - here we add a "scope".
Restricting access to an endpoint to certain scopes.
Creating a basic admin dashboard
A look at future calls to clean up the database
Using integration tests to test our future call
(Re)scheduling our future call to be run in an interval
Don't call expensive APIs if we already have the answer.
Update the tests and check that the cached value is used.
Implement endpoints to upload files to the server and retreive them again
Update the tests.
Implement the Flutter side of the file upload.
Refactor the generateRecipe method to return a stream
Update the Flutter app to react to the stream
Host the Flutter app as a web app on the builtin webserver
Using interactive rebase (I recommend https://git-fork.com/) you can rename commits, add new ones and rearrange the order.
The commits are meant to be checkpoints for the course, so rewriting history as the course is updated is what we have to do.
Consider creating a branch with the "old" state if you want to keep it for reference. Force push over main - there should never be any merge commits or commits that are not directly linked to a lesson.