Skip to content

Repository to practice using FastAPI with MongoDB.

Notifications You must be signed in to change notification settings

Arkiralor/FastAPIMongo

Repository files navigation

FastAPI with MongoDB

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.

Features

  1. Document database connection via both: synchronous (via PyMongo) and asynchronous (via Motor) drivers.
  2. User authentication via Json Web Token with separate accessTokens and RefreshTokens.

Setup

We will now go through how o setup the project on your development machine.

Pre-Requisites

  1. Python 3.9
  2. BASh
    • GitBASh for Windows

Development Setup

N.B: We are assuming you know how to properly clone a repository from GitHub.

  1. Create a new virtual environment using python -m venv env.
  2. Activate the virtual environment via source env/bin/activate.
    • source env/Scripts/activate in Windows.
  3. Install setup-tools via the command python -m pip install pip-tools
  4. Install the dependencies via the command sh scripts/install_dependencies.sh
    • This auto-generates the platform-specific requirements.txt file via the requirements.in file.
    • All new dependencies are to only be added to the requirements.in file; the requirements.txt file is not to be edited manually.
    • In fact, you can even add the requirements.txt file to the .gitignore file.
  5. Setup MongoDB either locally or in a personal cloud.
  6. Copy the .env file to the root folder.
  7. You can use sh scripts/run.sh to run the application.

Documentation

  1. Postman Generated
  2. Swagger ( Only works if the server is running. )

About

Repository to practice using FastAPI with MongoDB.

Topics

Resources

Stars

Watchers

Forks