Fastapi Clean Architecture

screenshot of Fastapi Clean Architecture

Base FastAPI Project to create general api.

Overview:

The FastAPI Clean Architecture is a base project that provides a framework for creating RestAPI applications. It offers minimal functionality, a convincing architecture, and is easy to read. It is compatible with Python 3.9+ and FastAPI 0.78.0. The project uses MySQL 5.7+ as its database and can be deployed in a container environment such as Kubernetes or Docker.

Features:

  • Base Models: The project includes base models for defining relationships between entities, such as user and post, and post and tag.
  • Database Integration: It supports integration with MySQL 5.7+ and provides migration support using Alembic.
  • Testing: The project includes pytest for running tests with a real database. It offers two ways of loading data, eager or lazy.
  • Modeling with Schema: The project supports modeling relationships between entities using schemas, such as one-to-one, one-to-many, and many-to-many.
  • Dependency Injection: It follows the service-repository pattern and uses dependency injection for managing dependencies between components.
  • JWT Authentication: The project provides JWT authentication for securing endpoints.
  • Role Separation: Each endpoint in the project follows role separation, ensuring that access is based on user roles.

Summary:

The FastAPI Clean Architecture project is a powerful framework for building RestAPI applications. It provides a convincing architectural pattern, easy-to-read code, and compatibility with various technologies. With features such as database integration, testing support, schema modeling, and JWT authentication, it offers a versatile solution for developing robust and secure APIs. The project also focuses on role separation and uses dependency injection for managing dependencies, making it a suitable choice for large-scale applications.