Skip to content

Fastapi-app is an opinionated modular FastAPI app boilerplate inspired by NestJS and Flask's Blueprint.

License

Notifications You must be signed in to change notification settings

lqmanh/fastapi-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fastapi-app

Fastapi-app is an opinionated modular FastAPI app boilerplate inspired by NestJS and Flask's Blueprint. It is suitable for small to medium sized API oriented microservices.

Features

  • ASGI server with Uvicorn
  • Active record ORM with Tortoise and database migration with Aerich
  • Authentication with OAuth2
  • Access control with Casbin
  • Job scheduling with Arq
  • CLI with Typer
  • Built-in pagination support
  • Preconfigured logger

Usage

cookiecutter https://github.com/lqmanh/fastapi-app

Project Structure

{{cookiecutter.project_slug}}        #
├── {{cookiecutter.package_name}}    #
│   ├── common                       # Common components
│   │   ├── constants.py             # Constants
│   │   ├── types.py                 # Classes, enums, type aliases,...
│   │   └── utils.py                 # Helper functions, decorators,...
│   ├── modules                      # Where magic happens
│   │   ├── ac                       # Access control module
│   │   │   ├── ac_deps.py           #
│   │   │   ├── ac_model.conf        # Access control model
│   │   │   └── ac_policies.csv      # Policies
│   │   ├── arq                      # Arq module
│   │   │   ├── arq_deps.py          #
│   │   │   └── arq_jobs.py          #
│   │   ├── logging                  # Logging module
│   │   │   └── logging_deps.py      #
│   │   ├── pagination               # Pagination module
│   │   │   ├── pagination_deps.py   #
│   │   │   ├── pagination_dtos.py   #
│   │   │   └── pagination_types.py  #
│   │   └── users                    # User management module
│   │       ├── users_cli.py         # CLI sub-app
│   │       ├── users_controller.py  # Controller in NestJS, class-based view in Django
│   │       ├── users_deps.py        # Injectable dependencies
│   │       ├── users_dtos.py        # DTOs, view models
│   │       ├── users_mapper.py      # Mapper that maps domain models to DTOs
│   │       ├── users_models.py      # Domain models
│   │       ├── users_module.py      # Module class
│   │       ├── users_service.py     # Business logic, also a special kind of dependencies
│   │       └── users_types.py       # Classes, enums, type aliases,...
│   ├── cli.py                       # Root CLI app
│   ├── config.py                    # Global configurations
│   └── server.py                    # HTTP server
├── LICENSE                          #
├── README.md                        #
├── aerich.ini                       # Aerich configurations
├── poetry.toml                      #
└── pyproject.toml                   #

About

Fastapi-app is an opinionated modular FastAPI app boilerplate inspired by NestJS and Flask's Blueprint.

Topics

Resources

License

Stars

Watchers

Forks