This is an example project demonstrating the use of Beanie ODM in a FastAPI application
This demo is based on python3 and uses Poetry to manage dependencies. Make sure you have installed poetry using the installation instructions before you begin.
As beanie is an ODM for MongoDB it needs a MongoDB database to run. If you already
have a Mongo database running, change the settings in beanie_fastapi_demo/main.py
accordingly. In other cases
it is recommended to run MongoDB using docker and
docker-compose.
Installing the requirements using poetry is easy, just run the command below
poetry install
To run MongoDB using docker-compose, run
docker-compose -f docker-compose-mongodb.yml up -d
To activate the environment managed by poetry and run the application, run
poetry run beanie-fastapi-demo
The demo application can now be reached on http://127.0.0.1:10001/
If you go to http://127.0.0.1:10001/docs you will see the automatic interactive API documentation generated with Swagger UI
Alternatively you can go to http://127.0.0.1/redoc see the automatic interactive API documentation generated with Redoc
- Beanie: https://github.com/roman-right/beanie
- FastAPI: https://fastapi.tiangolo.com
- fastapi-cosmos-beanie: https://github.com/tonybaloney/ants-azure-demos/tree/master/fastapi-cosmos-beanie
- fastapi-beanie-jwt: https://github.com/flyinactor91/fastapi-beanie-jwt