Skip to content

FastAPI demo app with PostgreSQL, Alembic, Pytest, and Docker for asynchronous, relational database usage.

Notifications You must be signed in to change notification settings

ami-wtag/fastapi-demoapp

Repository files navigation

FastAPI Demo App with Postgres, Alembic, Pytest, and Docker

This repository provides a simple FastAPI demo application with PostgreSQL as the relational database, Alembic for migrations, Pytest for testing, and Docker for containerization. It has a CRUD operation example with proper log set up.

Getting Started

Set Up Pipenv and Install Dependencies

  1. Export the variable for Pipenv:

    $ export PIPENV_VENV_IN_PROJECT=1
  2. Activate the virtual environment:

    $ pipenv shell
  3. Install the required packages:

    $ make install

Initialize Alembic

  1. Initiate Alembic:

    $ make build
  2. Create a revision for the initial table (e.g., 'book' table):

    $ make makemigrations

Build and Run with Docker

  1. Build the Docker images:

    $ make build
  2. Make migrations:

    $ make makemigrations
  3. Migrate the database:

    $ make migrate
  4. Run the application:

    $ make run

Now, the project will be running on http://localhost:8000

Pgadmin4

http://localhost:5050

Testing

To run tests using Pytest, execute the following command within the virtual environment:

$ make test

Flower

Navigate to http://localhost:5556 to view the dashboard. You should see one worker ready to go.

Documentation

swagger - http://localhost:8000/docs
redoc - http://localhost:8000/redoc

About

FastAPI demo app with PostgreSQL, Alembic, Pytest, and Docker for asynchronous, relational database usage.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages