Skip to content

anthonycepeda/fastapi-mongodb-async-restapi

Repository files navigation

alt text

FastAPI MongoDB Async RestAPI

A Blueprint of a production-ready API.

This project is based on Michaldev's Github fastapi-async-mongodb.
Mongo DB has been configured using this articule

Installing / Getting started

Quickstart

# build and run
$ docker-compose up --build

Usage:

# build and run the project
$ docker-compose up --build

# run in background
$ docker-compose up -d

# delete docker images
$ docker-compose rm mongo api

# docker compose help
$ docker-compose --help

Project Structure:

project
│   README.md
│   docker-compose.yaml
│   entry_point.py
│   Pipfile
│   Pipfile.lock
│
└───api/
│   │   __init__.py
│   │   config.py   # app settings
│   │   main.py     # app startup
│   │
│   └───db/
│   │   │   __init__.py
│   │   │   database_manager.py   # db abstract methods
│   │   │   mongo_manager.py      # actual mongo conn
│   │
│   └───models/
│   │   │   generic.py     # generic pydantic models
│   │
│   └───public/            # api namespaces
│   │   │   __init__.py
│   │   │
│   │   └───health/
|   │       │   models.py
|   │       │  views.py
|   │       │
│   │       users/
|   │       │   models.py
|   │       │  views.py
|   │
│   └───utlis/
│       │   __init__.py
│       │   logger.py     # custom logger
│
└───docker/           # mongo image initializer & api dockerfile
|    │   docker-entrypoint-initdb.d/mongo-init.js
|    │   Dockerfile
│
└───tavern_tests/     # api tests
    │   common.yaml
    │   test_user.tavern.yaml

Help:

Installs and info:

Features: