Skip to content

FastApi template with gunicorn, redis, cache, API endpoint with request rate limit, alembic, Pagination, JWT token authentication.

License

Notifications You must be signed in to change notification settings

mateus-rodriguess/fastapi-template

Repository files navigation

FastAPI

Test Coverage Supported Python versions


The Fastapi template is a repository for microservices. In this template, you will find examples of how to build a robust application with FastAPI.

Technology Stack and Features

  • FastAPI for the Python Back-End API.
    • 🚀 Fast: Supports async/await syntax for routes and database connection.
    • 💪 Robust: Get production-ready code with automatic interactive documentation.
    • 🔐 Security: OAuth2 with fastapi.security.
  • ⚡ Template
    • 🧰 SQLModel: For the Python SQL database interactions (ORM).
    • 🐋 docker Compose: For development and production.
    • pytest: Unitary tests.
    • 🧰 alembic: Database migrations.
    • 📑 guvicorn-logger: Color logger translator.
    • 📑 pagination: To simplify pagination.
    • 👀 pylint: Analyses your code without actually running it.
    • 🚀 fastapi-cache: Cache using redis.
    • 🔒 fastapi-limiter: Is a rate limiting tool for fastapi routes.
    • 🚀 nginx: HTTP level server, reverse proxy.
    • 🔒 Secure password hashing by default.
    • 🔑 JWT token authentication.

Interactive API Documentation

Get production-ready code with automatic interactive documentation. API documentation at Docs.

API docs

How To Use It

You can just fork or clone this repository and use it as is.

✨ It just works. ✨

How to Use a Private Repository

If you want to have a private repository, GitHub won't allow you to simply fork it as it doesn't allow changing the visibility of forks.

But you can do the following:

  • Create a new GitHub repo, for example my-back-end.

  • Clone this repository manually, set the name with the name of the project you want to use, for example my-back-end:

    git clone git@github.com:mateus-rodriguess/fastapi-template.git my-back-end
  • Enter into the new directory:

    cd my-back-end
  • Set the new origin to your new repository, copy it from the GitHub interface, for example:

    git remote set-url origin git@github.com:mateus-rodriguess/fastapi-template.git
  • Add this repo as another "remote" to allow you to get updates later:

    git remote add upstream git@github.com:mateus-rodriguess/fastapi-template.git
  • Push the code to your new repository:

    git push -u origin main

Run:

  docker compose up -d

Migrations

  $ alembic revision --autogenerate -m "Migration message."
  $ alembic upgrade head

License

This project is licensed under the terms of the MIT license.

Releases

No releases published

Sponsor this project

Packages

 
 
 

Languages