In our app, we are trying to apply a hexagonal architecture. We have the concept of internal schemas, generally ecto embedded schemas or schemaless changesets that perform some validation or data transformation. Its easier to transport internal data with this logic.
- App receives an incoming message (API, Kafka)
- Controller uses an Adapter to parse an internal schema
- Controller passes this schema to the context
- Render response
However, we have some problems:
- We have several external providers (Kafka, other APIs, frontend) that can have different fields.
- We would need a way to create different versions of a schema, for an API
- We would like to move this validation with schemas more to the edge of our web layer
The idea is somewhat the same as a DTO (Data Transfer Object), but it would be only flat maps only to do validation and maybe reject the invalid incoming message.
Does anyone make something similar to this? Does this make sense at all?