Skip to content

dlt-hub/fast-api-jaffle-shop

Repository files navigation

FastAPI Jaffle Shop

This is a FastAPI version of the dbt jaffle shop project. The jaffle shop dataset is copied from dbt jaffle data.

When the API is running, docs are available at /docs. For all entities, there are collection and single entity endpoints to retrieve the data. The collection endpoints are paginated and have a limit of 100 items. The link to the next page is returned in the response headers. The orders endpoint includes the order items nested inside each order object.

Requirements

This project requires python 3.10+ and uv to be installed.

Run tests

Some tests are quite slow as the dataset is quite large. To run the tests faster, use the following command:

make test-fast

All tests can be run with:

make test

Run dev with reload

make run-dev

Run uvicorn

make run

Folder Structure

/app - FastAPI app
/seed - Seed data as csv files from dbt jaffle shop project

Deployment

This app is currently deployed to the dlthub digital ocean app platform. Pushes to the main branch will result in a deployment. Please run make freeze-requirements to update the requirements.txt file from the uv lockfile, as that is what Digital Ocean uses to install the dependencies.

Example dlt rest api source to sync orders from january 2017 and all other entities fully

source = rest_api_source(
    {
        "client": {
            "base_url": "http://localhost:8000",
                "paginator": {
                    "type": "header_link",
                },
                "session": FastAPISession(app),
            },
            "resources": [
                "customers",
                "products",
                "stores",
                "supplies",
                # orders includes items
                # we only load orders for january 2017
                {
                    "name": "orders",
                    "endpoint": {
                        "path": "orders",
                        "params": {
                            "start_date": "2017-01-01",
                            "end_date": "2017-01-31",
                        },
                    },
                },
            ],
        },
    )

About

The famous dbt jaffle shop as a simple fast-api based api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published