agusmdev / fastapi-ddd-cookiecutter

This project is a backend template for a FastAPI-based application that uses the repository pattern approach to provide an abstraction layer between the business logic and the data access layer. It aims to provide a scalable and maintainable architecture for building web applications.
MIT License
42 stars 5 forks source link

FastAPI Template using the Repository Pattern Approach

This project is a backend template for a FastAPI-based application that uses the repository pattern approach to provide an abstraction layer between the business logic and the data access layer. It aims to provide a scalable and maintainable architecture for building web applications.

Features

Requirements

Working example

You can check a working example of this architecture here with a simple todo-app

Getting Started

To use this template, you first need to have cookiecutter installed. If you don't have it already, you can install it with:


pip install cookiecutter

Once you have cookiecutter installed, you can create a new project from this template by running:


cookiecutter https://github.com/agusmdev/fastapi-ddd-cookiecutter.git

This will prompt you for some information about your new project, such as the project name and the the main entity of your project. Then it will create a new project directory based on this template.

Input variables

The generator (cookiecutter) will ask you for some data, you might want to have at hand before generating the project.

The input variables, with their default values (some auto generated) are:

🍴 Setup after cloning the template

Local

To run the project locally, execute the following scripts:

# Activate the environment
$ source scripts/venv.sh

⚙️ Usage

Local

To run the service locally, execute the following script:

./scripts/run_app.sh

This command will start the service on port 8000.

🔧 Scripts

This is the list of commands implemented to facilitate the development of this project:

clean.sh                 Remove temporary files
install.sh               Install the repository in the current directory
lint.sh                  Run linting on the source code
run_app.sh               Run the app
setup_dev.sh             Set up for local development
tests.sh                 Run a specific test suite
venv.sh                  Activate the environment created with virtualenv

🔍 Tests

To run the project tests, execute the following command:

# run unit tests
$ ./scripts/tests.sh unit

# run system tests
$ ./scripts/tests.sh system

By default, all unit tests defined in the project will be run.

🤝 Contributions

If you're interested in contributing to the project, we welcome pull requests and issue submissions!

I would also like to extend a big thank you to Leandro Acosta and Leandro Ferrado for their invaluable contributions to the initial development of this template.