/sample-todo-list-hexagonal-architecture

Sample of TO-DO List Application using Hexagonal Architecture.

Primary LanguagePythonApache License 2.0Apache-2.0

Sample TODO List with Hexagonal Architecture

Sample of TO-DO List Application using Hexagonal Architecture.

  1. Infrastructure: Database specific connectors all 3rd part dependant goes here.
  2. Application: Main use cases.
  3. Domain: All the business logic goes here.

Domain

Class Diagram

to_do_list
    ├── shared
    │         └── domain
    │             └── models.py
    └── tasks
        ├── application
        │         ├── services.py
        │         └── sources.py
        ├── domain
        │         ├── contracts.py
        │         ├── exceptions.py
        │         ├── models.py
        │         └── services.py
        └── infrastructure
            └── persistence
                └── relational.py

CLI Application

app
    ├── configuration.py
    ├── console.py
    └── providers.py

Installation

Just run poetry to install the dependencies.

poetry install

Next, you need to create and configure the .env file.

# create .env file
cp example.env .env
# create the database file.
touch to_do_list.db

Usage

Once the dependencies are installed, you can run the application using the following command.

# initialize the database.
poetry run python todo.py init
# use the application.
poetry run python todo.py

Tests

  1. Unit: tests the domain and application layer.
  2. Integration: tests the infrastructure layer.

To run test you can use the following command.

poetry run pytest
tests                         
    ├── conftest.py                                                        
    ├── integration                                                        
    │     └── test_infrastructure_persistence.py                             
    └── unit                                                                               
          └── test_application_services.py