alexk1919
fastapi-motor-mongo-template
Python

High-performance FastAPI backend boilerplate for real-world production, with mongo and pytest. Suitable for microservices.

Last updated Feb 22, 2026
82
Stars
20
Forks
3
Issues
0
Stars/day
Attention Score
7
Language breakdown
Python 75.8%
CSS 17.4%
Makefile 3.3%
Dockerfile 2.7%
JavaScript 0.6%
Shell 0.3%
โ–ธ Files click to expand
README

Boilerplate for FastAPI, MongoDB, Motor Projects

Python3.11.2 MongoDB FastAPI Motor

Features

A new backend project created with this boilerplate provides:
  • [x] Asynchronous high-performance RESTful APIs built upon FastAPI framework.
  • [x] Asynchronous CRUD operations for a sample resource built upon Motor driver for MongoDB, providing high performance and efficiency.
  • [x] API documentation with Swagger UI.
  • [x] API testing with pytest and pytest-asyncio.
  • [x] Dockerfile for containerization and docker-compose support.
  • [x] Easy creation of new backend services with cookiecutter.
  • [x] Easy package menagement with Poetry.
  • [x] Health API for service health checking.
  • [x] Easy configuration with environment variables.
  • [x] Easy testing, develop running, docker build, docker-compose up and down with Makefile.
  • [x] Proper logging with ID masking.

Prerequisites

  • Python 3.11+
  • Poetry installed
  • Docker installed
  • GNU Make

Getting Started

Edit Environment Variables

Edit the .env file within the project folder.

Run Tests

make test
(This may not work at this time. Please use docker-compose instead.)

Build Docker Image

make docker-build

Docker-compose

make docker-compose-up
make docker-compose-down

Run Service Locally

make dev
This will create a MongoDB container as well. (This may not work at this time. Please use docker-compose instead.)

Check Swagger API Document

Go to http://localhost:8888/docs.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you.

Credit:

Forked from https://github.com/klee1611/cookiecutter-fastapi-mongo

ยฉ 2026 GitRepoTrend ยท alexk1919/fastapi-motor-mongo-template ยท Updated daily from GitHub