This application will allow you to manage your habits. It's still in the early stage so there is not a lot of functionality currently. It's mainly a Haskell learning exercise for me. The application is based on servant and exposes a rest interface. The structure of the application is heavily inspired by the ports and adapters (also called hexagonal) architecture.
The incoming (driving ports) are called use cases. They can be found in src/Habits/Domain/UseCases
and rely exclusively on the domain logic in src/Habits/Domain
. The adapter logic of the web controller in src/Habits/Web
uses them under the hood to expose the domain to the ouside world. Each use case is tested by an corresponding specification found in test-unit
and all routes (controllers) are unit tested by mocking out the underlying use case implementation. Additionally e2e tests for each route are included in test-e2e
. Those tests make use of the servant client library in order to communicate with a spawned web server in each test. The interface of outgoing ports like repositories are defined in src/Habits/Domain
. The folder src/Habits/Infra/Memory
for example contains an in-memory version for all repositories. These fakes
can be used for fast unit tests. src/Habits/Infra/Postgres
contain or will contain postgreSQL backed versions of all repositories. Contract tests found in test-common/Habits/Domain
make sure that the in-memory version and the postgres implementation will behave as specified. The Spec files using those contracts can be found in test-unit/Habits/Infra/Memory
and test-integration/Habits/Infra/Postgres
. The aim is to have only as much slow running integration tests as required by the contracts. This will ensure that most tests are fast running unit tests.