Skip to main content

This library helps you not get involved in the complexities of FastAPI and its libraries and focus all your attention on the application.

Project description

FastAPI Fast Template

Package version Downloads Supported Python versions License

This library helps you not get involved in the complexities of FastAPI and its libraries and focus all your attention on the application.

Features

  • Proper structure and ready

  • Ruff - An extremely fast Python linter and code formatter, written in Rust.

  • pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.

  • SQLAlchemy - SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL

  • Tortoise ORM - Tortoise ORM is an easy-to-use asyncio ORM (Object Relational Mapper) inspired by Django.

  • SQLModel ORM - SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.

  • Beanie ODM - Beanie - is an asynchronous Python object-document mapper (ODM) for MongoDB.

  • fastapi-and-logging - FastAPI-and-Logging simplifies log handling, allowing for effective organization, tracking, and analysis of logs in FastAPI applications, aiding in debugging and issue resolution.

  • fastapi-and-caching - FastAPI and Caching is an extension for FastAPI that provides support for various caching mechanisms, allowing you to easily leverage caching within your FastAPI applications.

  • fastapi-and-babel - FastAPIAndBabel allows you to easily use babel in your FastAPI projects and offers some features to improve and ease things.

  • APScheduler Advanced Python Scheduler (APScheduler) is a Python library that lets you schedule your Python code to be executed later, either just once or periodically.

  • FastStream - the simplest way to work with a messaging queues

  • Authx - Ready-to-use and customizable Authentications and Oauth2 management for FastAPI โšก

  • FastAPI Cloud Auth(Coming Soon...)

  • FastAPI Admin(Coming Soon...)

  • FastAPI MVC(Coming Soon...)

  • Fastapi-mail(Coming Soon...)

Install

pip install fastapi-fast-template

Usage

By executing the following command, you initiate the project configuration.

fast init
-- Enter the name of the application (default: Fast Template): FastTemplate
-- Enter the config module type (default: multiple): single or multiple
-- Enter the ORM/ODM (default: sqlalchemy): sqlalchemy, tortoise, sqlmodel or beanie
Initializing has been done successfully.

๐Ÿฅณ๐Ÿฅณ, your project has been created!

.
โ”œโ”€โ”€ logs/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ repositories/
โ”‚   โ”‚   โ”œโ”€โ”€ base.py
โ”‚   โ”œโ”€โ”€ routers/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ lifespan.py
โ”‚   โ”œโ”€โ”€ app.py
โ”‚   โ”œโ”€โ”€ config.py
โ”‚   โ”œโ”€โ”€ database.py
โ”‚   โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .env.sample
โ”œโ”€โ”€ .fast_template.ini
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .pre-commit-config.yaml
โ””โ”€โ”€ ruff.toml

Now, you can run it as follows.

python src/main.py
INFO:     Will watch for changes in these directories: ['.']
INFO:     Loading environment from '.env'
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [44167] using StatReload
INFO:     Started server process [44175]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Extensions

Babel

You can add Babel to your project as follows.

fast extension --name babel
Please select the default language (default: en): fa
...
...
...
compiling catalog translations/fa/LC_MESSAGES/messages.po to translations/fa/LC_MESSAGES/messages.mo

For more information, click here.


APScheduler

You can add APScheduler to your project as follows.

fast extension --name scheduler

To use it, you can check the "tasks" directory and the "__init__.py" module.

from tasks import scheduler

async def fast_template_scheduler():
    print("FastAPI Fast Template")

scheduler.add_job(
    func = fast_template_scheduler,
    trigger = CronTrigger(minute = "*/30", timezone = "Asia/Tehran")
)

By running the project, the scheduler is executed.

For more information, click here.


FastAPI-And-Caching

You can add caching to your project as follows.

fast extension --name caching

To use it, you can check the "utils" directory and the "caching.py" module.

from utils.caching import cache

@app.get("/")
@cache.cached(key="root", expire=30, prefix="router")
def root():
    return "FastAPI Fast Template"

For more information, click here.


FastAPI-And-Logging

You can add logging to your project as follows.

fast extension --name logging
Please select the log type (default: incoming): (choose from incoming, apicall, exception)

You can now check out the app.py module and apply your changes to it.

For more information, click here.


FastStream

You can add broker to your project as follows.

fast extension --name stream
Please select the broker (default: redis): (choose from redis, aiokafka, confluent, rabbit, nats)

You can run it with the following command โ€โ€โ€โ€โ€

faststream run src.stream:app

For more information, click here.

Documents

You can have direct access to the documentation of each library used by using the following command.

fast doc


        Quick access to the documents of the tools used in this template.
        ___________________________________

        ๐Ÿ‘‰ FastAPI                            https://fastapi.tiangolo.com
        ๐Ÿ‘‰ SQLAlchemy                         https://www.sqlalchemy.org
        ๐Ÿ‘‰ Tortoise ORM                       https://tortoise.github.io
        ๐Ÿ‘‰ SQLModel ORM                       https://sqlmodel.tiangolo.com
        ๐Ÿ‘‰ Beanie ODM                         https://beanie-odm.dev
        ๐Ÿ‘‰ FastAPI-And-Babel                  https://github.com/heysaeid/fastapi-and-babel
        ๐Ÿ‘‰ FastAPI-And-Logging                https://github.com/heysaeid/fastapi-and-logging
        ๐Ÿ‘‰ FastAPI-And-Caching                https://github.com/heysaeid/fastapi-and-caching
        ๐Ÿ‘‰ APScheduler                        https://fastapi.tiangolo.com
        ๐Ÿ‘‰ FastStream                         https://faststream.airt.ai
        ๐Ÿ‘‰ AuthX                              https://github.com/yezz123/authx
        And ...
        ___________________________________

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_fast_template-0.0.6.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

fastapi_fast_template-0.0.6-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_fast_template-0.0.6.tar.gz.

File metadata

  • Download URL: fastapi_fast_template-0.0.6.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/6.1.0-22-amd64

File hashes

Hashes for fastapi_fast_template-0.0.6.tar.gz
Algorithm Hash digest
SHA256 983a6c21e62906bff09ce01dbce260ff2db5183ffd80632f48ba0624e40a2217
MD5 bf97e8bc772729b9bcafd6e34f1bb4cc
BLAKE2b-256 553080b638c1e0eaefbe1e90d8368ee53c2e1d713681e2d0429c5b6fb3e587eb

See more details on using hashes here.

File details

Details for the file fastapi_fast_template-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_fast_template-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a3e42157a2c5a37ac58689aa5e6af325c207be54b189f614b2694e688602696f
MD5 9f138ee24c3829e874139814bcd9764b
BLAKE2b-256 40fd9d1ae831e2669d50a4bcd7afbd5949e7c334161a51e5727261ce5a66e8ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page