Giter VIP home page Giter VIP logo

kdcokenny / fastapi-async-sqlmodel-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joaoflaviosantos/fastapi-async-sqlmodel-boilerplate

0.0 0.0 0.0 396 KB

A fully asynchronous FastAPI boilerplate. Built for extensibility and speed, it incorporates FastAPI, SQLModel, Alembic, PostgreSQL, Redis, and ARQ. ๐Ÿš€

License: MIT License

Shell 0.40% Python 99.30% Mako 0.30%

fastapi-async-sqlmodel-boilerplate's Introduction

FastAPI Async SQLModel Boilerplate

Supercharge your FastAPI development. A backend for perfectionists with deadlines and lovers of asynchronous programming.

White and blue rocket with FastAPI text on it. A Python logo floating next to the rocket.

Python FastAPI SQLModel Pydantic SQLAlchemy PostgreSQL Redis Docker NGINX

๐Ÿ” Project Overview

This FastAPI boilerplate for high-performance APIs leverages async programming alongside libraries such as SQLModel, Redis, ARQ, NGINX, and Docker. It follows a Django-inspired folder structure for a clear, modular codebase. Key areas like system/tiers, admin/users and blog/posts showcase the optimal balance between modularity and clarity.

It aims to provide a robust structure while serving as an excellent tool for quick POC (Proof of Concept) validations and MVP (Minimum Viable Product) launches. Crafted to attract enthusiasts who appreciate how Django operates, this project offers a solid foundation for API development, incorporating a blend of cutting-edge technologies and structural principles.

๐ŸŒŸ Key Features

This project seeks to provide a strong foundation for API development, incorporating a blend of cutting-edge technologies and structural principles:

  • โšก๏ธ Fully Async: Leverage the power of asynchronous programming.
  • ๐Ÿš€ FastAPI: Utilize FastAPI for rapid API development.
  • ๐Ÿงฐ SQLModel: Seamlessly integrates with SQLAlchemy 2.0 for versatile Python SQL operations, reducing the mapping between persistence and transport classes. Using Pydantic v2 can result in performance improvements from 5x to 50x compared to Pydantic v1.
  • ๐Ÿ” JWT User Authentication: Secure user authentication using JSON Web Tokens.
  • ๐Ÿช Cookie-based Refresh Token: Implement a refresh token mechanism using cookies.
  • ๐Ÿฌ Easy Redis Caching: Utilize Redis for simple and effective caching.
  • ๐Ÿ‘œ Client-side Caching: Facilitate easy client-side caching for improved performance.
  • ๐Ÿšฆ ARQ Integration: Seamlessly integrate ARQ for efficient task queue management.
  • โš™๏ธ Efficient Querying: Optimize database queries by fetching only what's needed, with support for joins.
  • โŽ˜ Pagination Support: Out-of-the-box pagination support for enhanced data presentation.
  • ๐Ÿ›‘ Rate Limiter Dependency: Implement a rate limiter for controlled API access.
  • ๐Ÿ‘ฎ Secure FastAPI Docs: Restrict FastAPI docs behind authentication and hide based on the environment.
  • ๐Ÿฆพ Easily Extendable: Extend and customize the project effortlessly.
  • ๐Ÿคธโ€โ™‚๏ธ Flexible: Adapt the boilerplate to suit your specific needs.
  • ๐Ÿšš Docker Compose: Easily run the project with Docker Compose.
  • โš–๏ธ NGINX Reverse Proxy and Load Balancing: Enhance scalability with NGINX reverse proxy and load balancing.

๐ŸŽฏ Project Goals

  • Leverage the power of FastAPI for building high-performance APIs.
  • Implement asynchronous programming wherever applicable for optimal performance.
  • Integrate Redis for caching, rate limiting, and improving data access speed.
  • Utilize ARQ for handling background tasks asynchronously.
  • Implement a robust logging system to track and manage application events efficiently.
  • Manage database migrations seamlessly using Alembic.
  • Develop comprehensive unit tests for API endpoints using pytest.
  • Implement using SQLModel to streamline the interaction between the database and the API.
  • Provide a CLI tool for easy project execution and management.
  • Provide diverse deployment options to ensure flexibility and accessibility.

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following prerequisites installed and configured:

  • PostgreSQL: Set up a PostgreSQL database.
  • Redis: Install and configure a Redis server.
  • Python: Make sure to have Python 3.11 or a newer version installed on your system.
  • Poetry: Install Poetry for managing dependencies.

Note: Soon, there will be an additional option for development using Docker containers.

Installing Poetry

Poetry is a dependency manager for Python. Follow the steps below to install Poetry:

  1. Open a terminal.

  2. Run the following command to install Poetry using pip:

    pip install poetry
  3. Verify the installation by running:

    poetry --version

    This should display the installed Poetry version.

Now that the requirements are met, you can begin working on your project.

๐Ÿค– Running the Project CLI

To streamline the usage of this boilerplate, we've provided a convenient CLI tool. From the root project directory, execute the following steps:

  1. Clone the repository, running the following command:
git clone https://github.com/joaoflaviosantos/fastapi-async-sqlmodel-boilerplate.git
  1. Navigate to the cloned repository:
cd fastapi-async-sqlmodel-boilerplate
  1. Run the setup (CLI tool) command:
python3 setup.py

This command automates various setup tasks, making it easier to get started with the project.

For more details for a manual setup, please refer to the Backend README section.

๐ŸŒ Reference Projects

Feel free to use this boilerplate as a starting point for your own projects, and adapt it based on your specific requirements and use cases. Happy coding! ๐ŸŒŸ

fastapi-async-sqlmodel-boilerplate's People

Contributors

joaoflaviosantos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.