/python-clean-architecture-example

This project is a Python Clean Architecture example that uses Flask, SQLAlchemy and PostgreSQL

Primary LanguagePythonMIT LicenseMIT

tests   code coverage

About

This repository is a simple example of an implementation Clean Architecture using Python.

Articles about this project

I am writing a series of Linkedin articles related to this project:

Also, check this repository where you can find examples and explanations of Python best practices that complement this repository and its articles.

Instalation

On prompt, acess the directory that want to download the project

git clone https://github.com/claudiosw/python-clean-architecture-example-1.git

Create the virtual environment:

python -m venv venv

Run the virtual environment:

Windows

venv\Scripts\activate

Linux/MacOS

source venv/bin/activate

Install the required Python packages:

pip install -r requirements.txt
pre-commit install

Run the In-Memory CLI

python .\cli_memory_process_handler.py

Run the In-Memory Flask API

python .\flask_memory_process_handler.py

Prepare the PostgreSQL database

To use the PostgreSQL flavour of our app, we need to install PostgreSQL software. It can be in other machine as well. We will need a database and a user to access this database.

Create a .env file. Use the .env.example file as a template. Set the values considering your scenario.

Apply database migrations

With the PostgreSQL database installed and configured, you can apply the database migrations with the command below:

alembic upgrade head

Run the PostgreSQL Flask API

python .\flask_postgresql_process_handler.py

Documentation

API Documentation of the Flask PostgreSQL flavor of this project:

You can access the API documentation here.

Documentation Generated by Sphinx

You can see the documentation of this project generated by Sphinx in here.

Closing

I hope this repository and my article series were valuable to you. If that was the case, please star it.

If you want to contact me, reach me on LinkedIn or Twitter.

I am looking for a Python position. I also offer paid mentoring.