# GenogramMaker
Build family genograms as plain Elixir data, then render them to
[Graphviz DOT](https://graphviz.org) or [Mermaid](https://mermaid.js.org).
A genogram is a family diagram: people (with sex and vital status), the unions
between them (marriage, divorce, cohabitation, …) with their children, and the
emotional bonds that connect individuals (close, conflict, cutoff, …). Describe
one with a small, pipeline-friendly API and turn it into diagram source you can
render with Graphviz or drop straight into Markdown.
## Installation
Add `genogram_maker` to your deps in `mix.exs`:
```elixir
def deps do
[{:genogram_maker, "~> 0.1.0"}]
end
```
## Usage
```elixir
GenogramMaker.new()
|> GenogramMaker.add_person("dad", :male, name: "John", birth: 1948, death: 2009)
|> GenogramMaker.add_person("mom", :female, name: "Mary", birth: 1950)
|> GenogramMaker.add_person("kid", :female, name: "Ada", proband: true)
|> GenogramMaker.add_union("dad", "mom", type: :marriage, children: ["kid"])
|> GenogramMaker.add_bond("dad", "kid", :conflict)
|> GenogramMaker.to_dot()
```
produces:
```dot
digraph genogram {
rankdir=TB;
node [fontname="Helvetica"];
edge [dir=none];
p0 [label="John\n1948–2009", shape=square, style=filled, fillcolor="#dddddd"];
p1 [label="Mary\nb. 1950", shape=circle];
p2 [label="Ada", shape=circle, peripheries=2];
u0 [shape=point, width=0.03, label=""];
{ rank=same; p0; u0; p1; }
p0 -> u0;
p1 -> u0;
u0 -> p2;
p0 -> p2 [color="#c62828", label="conflict", constraint=false];
}
```
Pipe through `dot -Tsvg` (or any Graphviz renderer) to get the diagram. The same
genogram renders to Mermaid with `GenogramMaker.to_mermaid/1`, ready to paste into
a Markdown code fence:
```mermaid
flowchart TB
p0["John<br/>1948–2009"]
p1(("Mary<br/>b. 1950"))
p2(("Ada"))
u0(["married"])
p0 --- u0
p1 --- u0
u0 --- p2
p0 ---|conflict| p2
```
### Conventions
On render, standard genogram conventions are applied:
- **Sex** decides the shape — `:male` is a square, `:female` a circle, `:unknown` a diamond.
- **Vital status** — a `:death` year marks someone deceased; deceased people are shaded and the death year is shown.
- **Proband** — `proband: true` marks the index person with a double outline.
- **Unions** — `:marriage`, `:divorce`, `:separation`, `:cohabitation`, `:engagement`. Divorce and separation add `//` and `/` markers; cohabitation is dashed and engagement dotted.
- **Bonds** — `:close`, `:distant`, `:conflict`, `:hostile`, `:cutoff`, `:fused`, drawn as non-structural coloured lines so they never distort the generational layout.
People referenced by a union or bond are created automatically (with unknown
sex) if they have not been added yet, so the pipeline stays compact.
## About
`GenogramMaker` is maintained by the team behind
[AutoGenogram](https://autogenogram.com), an AI genogram maker and analyzer. If
you would rather describe a family in plain English and let AI draw the diagram,
try the [AI genogram generator](https://autogenogram.com); this library is its
code-first companion for producing genogram source programmatically.
## License
Released under the MIT License.