nimbus154 (1) [Avatar] Offline
I’m attempting to apply the concept of functional domain modeling to a web application. Below is a breakdown of an HTTP request/response cycle. Could I be so bold as to ask for thoughts on whether this breakdown accurately reflects the structure presented in the book?

UI Layer:
User fills out a web form and submits it to the server.

Application Layer:
An HTTP route handler receives the form, extracts fields, and passes the parameters to a service function in the domain layer. Once the service method returns, this layer returns a new view to the client.

Domain Layer:
A service function does any of the following as needed:

  • creates an aggregate with a factory

  • invokes other service methods to perform business logic on an aggregate

  • persists and retrieves aggregates with a repository

  • validates aggregates

  • emits events

  • In this understanding, service functions provide an interface into the domain layer, a role which, I think, is supposed to be played by the aggregate root.

    Thank you so much for your thoughts and time.
    Debasish Ghosh (116) [Avatar] Offline
    The steps that you have listed are quite intuitive and works with minor variations across various web applications. The challenge is to model the steps that you have listed under Domain Layer in a functional way. The fact that you have listed them in sequence implies that you are thinking of them as sequential steps. Now you map how to model them using pure expressions in a functional way. Hint: Think in terms of monads and Kleislis.