Awesome FastAPI

repository·main·Indexed 11 days ago

https://github.com/mjhea0/awesome-fastapi

A curated list of high-quality tools, libraries, and resources for the FastAPI ecosystem. This directory includes extensions for admin panels, authentication, ORMs (SQLAlchemy, Tortoise, Piccolo), MongoDB ODMs (Beanie, ODMantic), cybersecurity tools, developer productivity frameworks, deployment guides for serverless and PaaS/IaaS, and project boilerplates.

Tokens
2.9K
Snippets
0
Records
17
Agent score
45%

What's inside Awesome FastAPI

  1. Overview of Awesome FastAPI

    main
    Awesome FastAPI is a curated collection of resources, tools, and extensions for the FastAPI web framework. It is designed to help developers find high-quality third-party extensions (for Admin, Auth, Databases, etc.), hosting solutions, boilerplates, and educational resources to build high-performance RESTful APIs with Python.
  2. Explore Open Source FastAPI Projects

    main

    A variety of production-grade or educational projects are built with FastAPI. Key examples include:

    • Observability: fastapi-observability implements the three pillars (Traces via Tempo, Metrics via Prometheus, Logs via Loki) using OpenTelemetry.
    • Task Queues: fastapi-celery demonstrates integration with Celery, RabbitMQ, Redis, and Flower.
    • Real-time/Websockets: fastapi-websocket-broadcast for websocket broadcasting and redis-streams-fastapi-chat for Redis Streams-backed chat.
    • Security & Auth: Dispatch for managing security incidents and JeffQL for GraphQL/JWT authentication.
    • Microservices: Bali for Cloud Native Microservices using FastAPI and gRPC.
    • CRUD Examples: Available in both Async and Sync flavors via TestDriven.io.
  3. Access Official FastAPI Resources

    main

    For core information regarding the FastAPI framework, use the following official channels:

    • Documentation: The primary source for API references and usage guides.
    • Tutorial: A step-by-step guide for learning FastAPI features.
    • Source Code: The official repository on GitHub.
    • Discord: Community chat for real-time support and discussion.
  4. Deploy FastAPI with Docker Images

    main

    Several pre-configured Docker images are available to help ship FastAPI applications efficiently:

    • inboard: General-purpose Docker images for FastAPI apps.
    • uvicorn-gunicorn-fastapi-docker: High-performance image using Uvicorn managed by Gunicorn (supports Python 3.6 and 3.7).
    • uvicorn-gunicorn-poetry: Uses Gunicorn with Uvicorn workers and manages dependencies via Poetry. Supports AMD64 and ARM64.
    • uvicorn-poetry: Uses Uvicorn ASGI server and Poetry for dependency management. Optimized for Kubernetes and supports AMD64 and ARM64.
  5. Follow FastAPI Best Practices

    main

    To ensure your FastAPI applications are maintainable and production-ready, refer to these resources:

    • FastAPI Best Practices: A community-curated collection of best practices.
    • Clean Architecture: Use examples like fastapi-clean-example to implement structured, maintainable backends.
    • Advanced Stacks: Explore combinations like FastAPI-Dishka-FastStream (FastAPI, dishka, faststream, sqlalchemy, pydantic) for robust service layers.
  6. Deploy FastAPI using Serverless Frameworks

    main

    To run FastAPI in a serverless environment, you can use several providers and adapters:

    Adapters

    • Mangum: An essential adapter for running ASGI applications (like FastAPI) on AWS Lambda and API Gateway.

    Frameworks & Compute

    • AWS Lambda: Use with the Mangum adapter.
    • Google Cloud Functions: Serverless execution.
    • Azure Functions: Serverless execution.
    • Vercel: Deployment platform.
    • Google Cloud Run: Container-based serverless execution.
  7. Learn FastAPI through Tutorials and Courses

    main

    There are several structured learning paths available for mastering FastAPI:

    Specialized Tutorials

    • Async SQLAlchemy: Using SQLAlchemy asynchronously with FastAPI.
    • Machine Learning: Deploying Keras models with FastAPI, Redis, and Docker.
    • Testing: Developing and testing asynchronous APIs with Pytest, or using property-based testing with Hypothesis and Schemathesis.
    • Architecture: Implementing service abstraction and separation of concerns.
    • Real-time: Using WebSockets for data streaming.
    • Production: Running FastAPI with Gunicorn and systemd.

    Comprehensive Courses

    • Test-Driven Development (TDD): Building, testing, and deploying microservices with FastAPI and Docker (via TestDriven.io).
    • Modern APIs: Creating cloud-native APIs (via Talk Python).
    • Full Web Apps: Building complete web applications (via Talk Python).
    • Celery Integration: Adding asynchronous task processing with Celery (via TestDriven.io).
  8. Deploy FastAPI on PaaS and IaaS

    main

    FastAPI can be hosted on various cloud platforms:

    PaaS (Platforms-as-a-Service)

    • AWS Elastic Beanstalk
    • Fly: Offers specific tutorials for FastAPI deployment.
    • Google App Engine
    • Heroku: Supports standard deployments and machine learning model hosting.
    • Microsoft Azure App Service

    IaaS (Infrastructure-as-a-Service)

    • AWS EC2
    • Google Compute Engine
    • Digital Ocean
    • Linode
  9. Scaffold FastAPI projects with Boilerplates

    main

    Use various boilerplate templates to jumpstart your FastAPI development depending on your stack requirements:

    Full Stack & Modern Web

    • Full Stack FastAPI and PostgreSQL: Includes FastAPI, React, SQLModel, PostgreSQL, Docker, and GitHub Actions (developed by Sebastián Ramírez).
    • Full Stack FastAPI and MongoDB: Includes FastAPI, MongoDB, Docker, Celery, and React.
    • FastAPI and React Template: Uses FastAPI, TypeScript, Docker, PostgreSQL, and React.
    • FastAPI Nano: Uses a factory pattern architecture.

    Machine Learning & Data Science

    • FastAPI Model Server Skeleton: Production-ready skeleton for serving ML models.
    • cookiecutter-spacy-fastapi: Quick deployment of spaCy models.
    • cookiecutter-fastapi: Template for ML projects using Poetry, Azure Pipelines, and pytest.

    Database & ORM Specific

    • FastAPI and Tortoise ORM: Simple template using Tortoise-ORM.
    • FastAPI + SQLAlchemy 2 + PostgreSQL Template: Dockerized with modern-di dependency injection and Alembic migrations.
    • fastapi-alembic-sqlmodel-async: Uses Alembic and async SQLModel.
    • fastapi-gino-arq-uvicorn: High-performance async REST API using GINO, Arq, Uvicorn, Redis, and PostgreSQL.

    Specialized Scaffolding

    • openapi-python-client: Generates modern Python clients from FastAPI OpenAPI specs.
    • Pywork: Yeoman generator for scaffolding.
    • FastAPI template (s3rius): Supports SQLAlchemy, multiple databases, CI/CD, Docker, and Kubernetes.
  10. Select a MongoDB ODM or Driver

    main

    For MongoDB integration, consider these options:

    • Beanie: Asynchronous ODM based on Motor and Pydantic; supports data/schema migrations.
    • ODMantic: AsyncIO MongoDB ODM integrated with Pydantic.
    • MongoEngine: Document-Object Mapper for MongoDB.
    • Motor: The standard asynchronous Python driver for MongoDB.
  11. Select an Admin panel for FastAPI

    main

    Several third-party admin panels are available to provide a user interface for CRUD operations on your data:

    • FastAPI Admin: Functional admin panel; currently only works with the Tortoise ORM.
    • FastAPI Amis Admin: High-performance and easily extensible framework.
    • Piccolo Admin: Modern GUI specifically for the Piccolo ORM.
    • SQLAlchemy Admin: Works with SQLAlchemy models.
    • Starlette Admin: Supports SQLAlchemy, SQLModel, MongoDB, and ODMantic.
  12. Select an Authentication and Authorization library

    main

    Choose an authentication/authorization tool based on your specific requirements:

    • OAuth2 & Identity Providers:
      • AuthX: Customizable OAuth2 management.
      • FastAPI Azure Auth: Azure AD authentication (single/multi-tenant).
      • FastAPI Cloud Auth: Integration with AWS Cognito, Auth0, and Firebase.
      • FastAPI Zitadel Auth: OAuth2 using the Zitadel IAM platform.
    • JWT & Token Management:
      • FastAPI Auth: Supports OAuth2 Password Flow with JWT access/refresh tokens.
      • FastAPI JWT Auth: JWT authentication (inspired by Flask-JWT-Extended).
    • Access Control & Permissions:
      • FastAPI Casbin Auth: Supports RBAC, ReBAC, and ABAC via Casbin.
      • FastAPI Permissions: Provides row-level permissions.
      • FastAPI Security: Implements auth as FastAPI dependencies.
    • User & Account Management:
      • FastAPI Users: Comprehensive account management, authentication, and authorization.
      • FastAPI Login: Account management (based on Flask-Login).
    • Other Auth Methods:
      • FastAPI Simple Security: Out-of-the-box API key security.
      • FastAPI Login: Account management and authentication.