Documentation
Introduction

Introduction

⚠️

Pest is still in early development, and it's not ready for production yet. If you want to help, please, go to github and say hello!

pest is a python (opens in a new tab) web application framework designed for constructing scalable APIs, drawing inspiration from nest.js.

It is constructed on top of FastAPI with the goal of offering a straightforward yet robust interface and framework for developing extensive APIs that can be distributed across multiple files and self-contained modules.

This framework harnesses the capabilities of FastAPI (opens in a new tab), Starlette (opens in a new tab) and rodi (opens in a new tab) to deliver modularized, scalable, and easily creatable APIs, taking inspiration directly from nest.js (opens in a new tab).

@controller("/haunted-house")
class HauntedHouseController:
    service: HauntedHouseService  # 💉 automatically injected
 
    @get("/")
    def get_all(self) -> list[HauntedHouse]:
        return self.service.get_all()
 
    @get("/{id}")
    def get(self, id: int) -> HauntedHouse:
        return self.service.get_by_id(id)
 
    @post("/")
    def create(self, haunted_house: NewHauntedHouse) -> HauntedHouse:
        return self.service.new(haunted_house)
👋

If you come from the node.js world, you can think of pest as nest.js meets python.

Features

  • - pest utilizes FastAPI (opens in a new tab) under the hood, offering all the features provided by it, including its impressive automatic documentation with openapi (opens in a new tab) and redoc (opens in a new tab) UIs.

  • - pest employs object-oriented programming (OOP) as an organizational approach for routes, middlewares, and other API components.

  • - pest allows you to create modules, which are a way to organize groups of allowing the organization of interrelated services, routes, and middlewares that provide distinct business value to your API.

  • - pest is designed with scalability in mind, targeting mid to large APIs distributed across multiple files organized in different self-contained modules.

  • - pest uses dependency injection (thanks to the awesome rodi (opens in a new tab)) to provide a way to inject dependencies into your services, controllers, routes, middlewares, etc.

  • - pest uses decorators to declare modules, controllers, routes, middlewares, etc.

  • - pest is easy to use, and it's easy to get started with it.

And, obviously, everything that FastAPI and Starlette provide.

Think of pest as an effortless way to organize your API, , grouping related business logic together in self-contained modules with scalability in mind, while retaining the flexibility that FastAPI provides.

Philosophy

pest bases its philosophy on the following principles:

  • Model-View-Controller (MVC) architecture
  • Domain Driven Design (DDD)
  • Separation of Concerns (SoC)
  • Dependency Injection (DI)
  • SOLID (opens in a new tab) principles