fastapi-mongodb-boilerplate is a boilerplate code containing REST APIs developed using FastAPI and MongoDB as database.
Below are the list of technologies used in this project:
- Python - Programming language (version >= 3.11).
- FastAPI - Python Web framework used in Backend API development.
- MongoDB - NoSQL Database for storing data.
- Docker - Containerizing the services.
Libraries used in this project:
- PyMongo - Native Python driver for MongoDB.
- Motor - Asynchronous Python driver for MongoDB built on top of PyMongo.
- Prisma - ORM (or ODM) for Python and MongoDB.
This project can be setup in two ways.
Steps to setup fastapi-mongodb-boilerplate on your local machine.
Clone this repository and traverse to the project folder using below commands:
git clone https://github.com/DheemanthBhat/fastapi-mongodb-boilerplate.git
cd fastapi-mongodb-boilerplateCreate and activate virtual environment.
python -m venv .venv
.venv\Scripts\activatepython -m venv .venv
source .venv/bin/activatepip install -r requirements.txt- Create duplicate of
.env.samplefile and rename it to.env. - Update environment variables with proper values based on your requirements.
- For example change
MONGO_CONNECTION_STRINGto a valid MongoDB Atlas URL.
uvicorn src.main:app --reloadTo setup fastapi-mongodb-boilerplate using Docker, open Docker Desktop and run below command.
docker-compose up -dLaunch Swagger docs in browser: http://127.0.0.1:8000/docs
Launch Redoc docs in browser: http://127.0.0.1:8000/redoc