A "bootstrap" REST api for implementing a role based access control authentication and authorization service for your application ecosystem built using FastAPI and Postgres.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Docker - (Instructions on how to install can be found here (God bless the creators and maintainers for docker!)
- Docker-Compose (Instructions on how to install can be found here
- Postgres - The application is configured to use an external postgres instance not in a Docker container. You can install PgAdmin to run postgres locally from here
The application uses an .env file to manage environment varialbes. A .env.sample
file is included in the project for your modification. (Remember to rename the file to .env
in order for your environment variables to be read.)
The configuration can be changed to use the OS environment based on the FastAPI Settings documentation if you prefer.
Once the prerequisites are met, The following steps can be used to get the application up and running. All commands are run from the root directory of the project
- Build the docker image using
docker-compose build
- Run the application using (This step also all run all upgrade operations on the database using the most recent migration file)
docker-compose up
- The service has inbuilt documentation based on OpenAPI Specifications (formerly Swagger) and can be accessed at
http://localhost:8000/docs
The application comes with a few basic tests which can be expanded based to suit other scenario's you may want to cover. A 'test.sh' script based on pytest is used to run the tests together with any pre-requistes it needs to run. The dependencies for testing are configured to run only when the ENVIRONMENT
variable in your .env file is set to test
.
Run the tests using
docker-compose run web sh -c "./test.sh"
- fastapi - The web framework used
- docker - For application containerization
- poetry - For dependency management
- alembic - For database migrations
- Tsatsu Adogla-Bessa Jnr
This project was primarily made possible by the power, simplicity and wizardry of FastAPI built by tiangolo. I also took a lot of inspiration from his full-stack-fastapi-postgres bootstrap project.
This project is licensed under the terms of the MIT license.