A simple starting point for your FastAPI application that uses Supertokens for user auth.
The template includes the following to help you to get started:
- Makefile for dependency management with
pip-tools
- Dockerfile and compose files for local development
- SQLAlchemy for ORM (uses async engine) and Alembic for database migrations
- Simple authentication for docs page
- CRUD operations generic class with pagination
- Support for API versioning (
https://api.yourdomain.com/v1/
)
TODO:
- Tests are yet to come
Make sure to mark the app/
folder as source in your IDE otherwise you'll get import errors.
And since all your code (except tests) lives inside app/
folder, you should import modules like this:
from core.config import settings
and NOT like this:
# this will throw an error!
from app.core.config import settings
Just click on that green Use this template
button to start coding. There is a dummy app that
is already implemented for you so that you can quickly learn how to use the CRUD factory.
The following command will start a Postgres database and a Supertokens core locally in Docker:
docker compose -f docker-compose-local.yml up -d
so that you can do
cd app; uvicorn main:app
Otherwise, if you want to build a docker container with your app and run it, you can use the other compose file:
docker compose -f docker-compose-test.yml up -d
If you run the command above without changing the code, you can find the
documentation page here. The default username is docs_user
and the password is simple_password
.