I'm working on a project that deals with form designs (online questionnaires), exported as JSON from the customer's system. The goal is to produce simplified outlines of each design for the customer's review, stripping out irrelevant detail and showing the relevant detail cleanly.
From the user point of view, a form is a stream of questions/UI controls in a single logical order. This is broken up into pages and sections you can edit one at a time. Within a section some questions or groups of questions can be repeated, e.g. you might have an "Invitees" table, with columns for name, contact info, and RSVP status, and the ability to add as many rows as you need:
Form: - Pages: - Sections: - Sequences: - can_repeat: bool Controls: [Control]
The JSON data includes detail about the physical layout, and records the repeatable parts separately:
Form: - Pages: - Sections: - Rows: - row_number: int Columns: - Controls: [Control] RepeatableGroups: - row_number: int - Rows: - Columns: - Controls: [Control]
Taking a "clean architecture" approach, do I put the user conception as the domain layer, with no external dependencies...
# /domain/models.py @dataclass def class Control: name: str type: str details: dict @dataclass def class Sequence: controls: list(Control) @dataclass def class Table(Sequence) name: str visibility_rule: str @dataclass def class Section: name: str number: int visibility_rule: str sequences: list(Sequence)
...such that making the JSON data match the user model is an infrastructure-layer implementation detail:
# /infrastructure/json_loader.py import domain def parse_json_section(js): name = js['name'] number = js['number'] visibility_rule = identify_rule(js['visibilityRuleId']) controls = list() # snipped: populate controls list from js['rows'] and js['repeatableGroups'] return domain.model.Section(name, number, visibility_rule, controls)
Or, is it equally "clean" to do it the other way - the JSON structure is also from the business domain, so presenting it in a simplified way to the user is a UI-layer implementation detail?