Avni Server - Contract, Request, Response
Avni server internally uses entities or domain model based on hibernate. These domain entities are not directly serialised into or deserialised from external formats, except in some cases. The external formats Avni Server currently has are as follows.
- Web app request
- Web app response
- Bundle line item (both export and import are same)
- Mobile app request
- Mobile app response
- External API request
- External API response
- Request made to rule server
- Response received from rule server
- Custom formats for integration with external systems like Glific.
In Avni code while we would like to reuse data transfer object classes as much as possible but currently:
- In order to maintain stability of mobile app, we tend to keep their formats separate.
- Rule server formats are not very well thought out yet, as it may be refactored in future, hence they are also separate. It may become internal to Avni server in future, so separate formats may not be required.
- External API request/responses are designed for external consumption. Their formats look like what one implementation may see their data as and not how Avni represents data.
Web app request, response, and bundle formats are considered online
, meaning these can be changed and fixed in more agile fashion. Their are no backward compatibility requirements for these formats.
Internal design of web app and bundle formats.
- Avni Contract (id and uuid). Abstract class. The class is called CHSRequest, but can be renamed.
- Functionality specific contract. Abstract class.
abstract class ReportCardContract extends AvniContract
. These can contain all the primitive values as their representation doesn't change across bundle, request and response. - Concrete classes for request, response, and bundle - each extending from functionality specific contract. e.g.
class ReportCardResponse extends ReportCardContract
. Here we can add all related entity/entities.- Web request should use id or uuid for related entities. In case of collection - list of ids or uuids.
- Bundle must use uuid or list of uuids for related entities.
- Web response can use full response object for related object(s).
Related entity
Related entity is the entity which is required only for reference and are not modified by the client. For example - when editing ReportCard
in the web app, StandardReportCardType
is not changed.
Updated 4 months ago