Architecture
Mondher is a modular monolith. A single Rust binary contains all the algorithms; surfaces (CLI, HTTP API, Python bindings, web app) adapt that engine to different entry points.
The current Phase 1 surface set is the CLI; Phase 2 (Days 99-182) adds the API server, Python bindings, and web frontend, all driven by the same engine.
Crate layout
crates/ ├─ mondher-core Algebra: Context, Concept, Lattice, Implication ├─ mondher-engine Algorithms: NextClosure, canonical_base, association_rules ├─ mondher-formats File I/O: Burmeister, CSV, FIMI, FCA-XML, JSON, auto-detect ├─ mondher-layout Visualization: Sugiyama layout, SVG renderer, TikZ renderer ├─ mondher-cli Clap subcommands and handlers ├─ mondher-bin Tiny entry point delegating to mondher-cli └─ mondher-storage In-memory + future PostgreSQL storage
The dependency graph is strictly acyclic. mondher-core has no
internal dependencies; mondher-engine depends only on mondher-core;
mondher-formats depends on mondher-core. Each crate is fully tested
in isolation.
Design principles
Strong types over stringly-typed data
ObjectId(u32) and AttributeId(u32) are distinct newtypes that can't
be mixed up. The compiler catches "I passed an attribute index where
an object index was expected" before such code ever runs.
Deterministic output
Every algorithm produces output in a canonical order (lectic order for concepts and implications; sorted by source/target for covering edges). Running NextClosure twice on the same context produces byte-identical results, which makes content-hashing analyses meaningful.
Property-based correctness
For each algorithm, we encode its mathematical contract as a property test that runs on hundreds of random contexts per CI push. The Galois laws, lattice soundness/completeness, and Hasse-diagram correctness are all verified continuously.
External validation
Beyond internal property tests, a frozen reference corpus records expected outputs from fcaR for a set of canonical contexts. Mondher's CI checks agreement on every push. Failures point either to a Mondher regression or a corpus error — either way, useful signal.
Modular monolith
All algorithms live in mondher-engine. Surfaces (CLI, future API,
future Python) are thin adapters. Adding a new algorithm makes it
available from every surface simultaneously, with minimal adapter code.
Algorithm references
| Component | Algorithm | Reference |
|---|---|---|
| Concept generation | NextClosure | Ganter 1984 |
| Implication base | Duquenne-Guigues via NextClosure on pseudo-intents | Stumme 1996 |
| Association rules | Exhaustive subset enumeration | Agrawal et al. 1993 (background) |
| Layout | Sugiyama layered method | Sugiyama, Tagawa, Toda 1981 |
| Covering relation | O(|L|²) naive check | Standard |
| Reduced labeling | Smallest-extent / largest-intent search | Ganter and Wille 1999 |
Phase 2 will add faster algorithms (In-Close5, FCbO, AddIntent) for
large contexts. Phase 3 will add LinCbO and parallel CbO via Rayon.
The ConceptGenerator trait abstracts over the algorithm choice, so
existing code does not change.