A simple starting point for your FastAPI application.
- Pipenv for dependency management. Simply run
pipenv install --dev
to install get started. - Docker compose for local development and testing
- 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/
) - Async testing suite with Pytest
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.
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
The following command will run a PostgreSQL database on your docker engine:
docker compose -f docker-compose-local.yml up -d
so that you can do
cd app; uvicorn main:app
or
ENVIRONMENT=test pytest
If you just want to build a docker container with your app and run it, just run:
docker compose up -d
If you run the code without any changes, you'll find the
documentation page here. The default username is docs_user
and the password is simple_password
.