I'm trying to solidify my understanding of the schema organization for Human Essentials. The goal is to build up some documentation to make contribution even easier for new folks. Also I like to play with PlantUML and GraphViz.
First I ran rails erd filetype=dot attributes=false
and got a beast of a diagram. This includes all of the models and some indirect relationships.
Then I went through and started adding each node to some subgraphs. After some combinations I came up with several logical groupings - Participants
, Intake
, Inventory
, and Disbursal
.
Next I went through and kept deleting more things, especially indirect relationships, and added a splash of color. I also started to terminate edges at cluster boundaries. Perhaps a bad idea, but I also dropped the LineItem
model since it is really a way to get to Item+Qty. mmm. Well I think this is kinda wrong, but here it is in any case.
Let's dig a bit into the LineItem
model. This model is used in a variety of contexts (and is polymorphic) to effectively mean "A Qty of an Item". Initially I had this in the Inventory
group, but the Acquisition
and Disbursal
both have records that use this model, even though they might not be referencing ACTUAL items. You can request more items or different items than are actually available, for example. So it kinda belongs to all of them. I could duplicate this node for each of its uses, or I could maybe make a special arrow.
With that change, zooming in to only Catalog and Inventory. I've reversed some of the arrows to make more sense to me. The bold red edges actually go through the LineItem
model to represent a list of Item+Qty.
Let's focus on what we actually store in a physical location. The central model is InventoryItem
which specifies a Qty of Items
that are at a StorageLocation
. These represent real actual physical objects on a shelf somewhere.
The next interesting thing is Kits. These are groups of item+qty that you can use as a single catalog item. So even though in the StorageLocation
we have only a single InventoryItem
that points at a single Item
, that one Item
can in turn be a bundle of things joined together by a Kit
.
Let's say you have a Kit
named "Handy Pack" with Qty-3 "Kids (Size 1)" and Qty-6 "Wipes (Baby)". That Kit
has a single Item
of the same "Handy Pack" name. So if you have 5 of these Kit
s at a storage location, then you have 5 * Qty-3 "Kids (Size 1)" and 5 * Qty-6 "Wipes (Baby)" .... or in other words 15 diapers and 30 wipes.
Using the model as inspiration, I've now started to group out the lifecycle of things. Here is the basic block diagram.
Or as a top-to-bottom timeline:
All right .... I think that's enough for now :)