I am designing an application, which will aid designing electric installations. I went for Domain Driven Design, as the topic is complex and the application will be growing with gained knowledge. However, I am newbie to this concept. For now, I have a problem to properly model the domain, especially to divide entities into aggregates.
I have defined wiring - Installation as a set of ConnectionPoints and Cables, which connect them. One ConnectionPoint has one or more Cables. Each Cable has a set of wires. I consider end of a wire as a Terminal, which we can connect to another Terminal creating a Junction. Terminals differ one from another, as wires have different colours and purpose. Junctions are made of two or more Terminals and can be done only inside a ConnectionPoint. I have illustrated it for a better understanding:
Besides Cables there are also Devices, which also have Terminals. They are also connected in a ConnectionPoint and their Terminals are treated the same way as Cable's Terminals. For each Device I must be able to track, where the Terminal is connected to (it might be a list of end points).
The problem, with the design, is the need of having references to Terminals outside of a Cable and Device entities to create Junctions and track connections. I could consider a Cable and a Device as aggregates of Terminals, as Terminals cannot exist without them and as a knowledge of Terminal's parent is important. However, each Terminal has also an identity outside of a Cable / Device and I have no idea how later in code and database I could keep knowledge of the connections made.
Do you have any ideas how could I model it? What questions should I ask myself to define a correct model and avoid keeping references everywhere?