Repository to practice using FastAPI with MongoDB.
FastAPI is a micro-framework for development of Rest APIs, created and maintained by Tiangolo (real name: Sebastián Ramírez).
MondoDB is a NoSQL, source-available, cross-platform, document-oriented database program. It uses JSON-like documents with optional schemas.
- Document database connection via both: synchronous (via PyMongo) and asynchronous (via Motor) drivers.
- User authentication via Json Web Token with separate
accessTokens
andRefreshTokens
.
We will now go through how o setup the project on your development machine.
- Python 3.9
- BASh
- GitBASh for Windows
N.B: We are assuming you know how to properly clone a repository from GitHub.
- Create a new
virtual environment
usingpython -m venv env
. - Activate the virtual environment via
source env/bin/activate
.source env/Scripts/activate
in Windows.
- Install
setup-tools
via the commandpython -m pip install pip-tools
- Install the dependencies via the command
sh scripts/install_dependencies.sh
- This auto-generates the platform-specific
requirements.txt
file via therequirements.in
file. - All new dependencies are to only be added to the
requirements.in
file; therequirements.txt
file is not to be edited manually. - In fact, you can even add the
requirements.txt
file to the.gitignore
file.
- This auto-generates the platform-specific
- Setup MongoDB either locally or in a personal cloud.
- Also, install MongoDB Compass locally on your development machine.
- Copy the
.env
file to the root folder. - You can use
sh scripts/run.sh
to run the application.
- Postman Generated
- Swagger ( Only works if the server is running. )