# yesint/molar architecture

> Architecture diagram of the GitHub repository yesint/molar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yesint/molar
- Repository: https://github.com/yesint/molar

## Overview

MolAR is a Rust molecular modeling and molecular-dynamics analysis library, with Python bindings and companion force-field, command-line, membrane, and optional Gromacs-plugin packages. The main workflow is to read molecular structure or trajectory data into a system, select atoms, then analyze or modify the system and write results. The graph preserves documented capabilities such as periodic-boundary handling, SASA, fitting, and trajectory tasks. Several source modules were not sampled, so their documented roles are shown without speculative internal call relationships.

Main entry points: [`molar_python/src/lib.rs`](https://github.com/yesint/molar/blob/master/molar_python/src/lib.rs) (Python API), [`molar/src/topology.rs`](https://github.com/yesint/molar/blob/master/molar/src/topology.rs) (System and topology), [`molar/src/io.rs`](https://github.com/yesint/molar/blob/master/molar/src/io.rs) (Structure and trajectory I/O), [`molar/src/selection.rs`](https://github.com/yesint/molar/blob/master/molar/src/selection.rs) (Atom selections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Molecular core"]
  node_system["System and topology<br/>[topology.rs]"]
  node_atoms["Atom model and storage<br/>[atom.rs]"]
  node_bonds["Bond model and storage<br/>[bond_storage.rs]"]
  node_periodic["Periodic box<br/>[periodic_box.rs]"]
end

subgraph group_analysis["Selection and analysis"]
  node_selection["Atom selections<br/>[selection.rs]"]
  node_distance["Distance search<br/>[distance_search.rs]"]
  node_measure["Geometry and fitting<br/>[measure.rs]"]
  node_sasa["SASA analysis<br/>[sasa.rs]"]
  node_dssp["Secondary structure<br/>[dssp.rs]"]
  node_tasks["Trajectory analysis tasks<br/>[analysis_task.rs]"]
end

subgraph group_io["Files and trajectories"]
  node_io["Structure and trajectory I/O<br/>[io.rs]"]
  node_gromacs["Gromacs TPR/CPT plugin<br/>[lib.rs]"]
end

subgraph group_extensions["Modeling extensions"]
  node_perception["Chemical perception<br/>[perception.rs]"]
  node_smiles["SMILES chemistry<br/>[smiles.rs]"]
  node_forcefield["GAFF and charges<br/>[charge.rs]"]
  node_amber["Amber mechanics<br/>[amber.rs]"]
  node_membrane["Membrane analysis<br/>[lib.rs]"]
end

subgraph group_interfaces["User interfaces"]
  node_cli["Molecular utilities<br/>[main.rs]"]
  node_python["Python API<br/>[lib.rs]"]
  node_pyfiles["Python file interface<br/>[file_handler.rs]"]
  node_pyselection["Python selections<br/>[selection.rs]"]
  node_pysystem["Python system and state<br/>[system.rs]"]
  node_pyatom["Python atom access<br/>[atom.rs]"]
  node_pybox["Python periodic box<br/>[periodic_box.rs]"]
  node_pyforcefield["Python force fields<br/>[force_field.rs]"]
  node_pytopology["Python topology and state<br/>[topology_state.rs]"]
end

node_user(("Molecular analyst"))
node_result["Analysis or output"]

node_user -->|"opens files"| node_io
node_io -->|"loads structures"| node_system
node_system -->|"stores atoms"| node_atoms
node_system -->|"stores bonds"| node_bonds
node_user -->|"selects atoms"| node_selection
node_selection -->|"binds to system"| node_system
node_user -->|"searches distances"| node_distance
node_user -->|"measures and fits"| node_measure
node_user -->|"calculates SASA"| node_sasa
node_user -->|"analyzes structure"| node_dssp
node_user -->|"runs trajectory tasks"| node_tasks
node_user -->|"uses PBC"| node_periodic
node_user -->|"perceives chemistry"| node_perception
node_user -->|"uses SMILES"| node_smiles
node_user -->|"assigns types and charges"| node_forcefield
node_user -->|"uses Amber mechanics"| node_amber
node_user -->|"analyzes membranes"| node_membrane
node_user -->|"runs utilities"| node_cli
node_cli -.->|"processes molecular files"| node_io
node_user -->|"uses Python API"| node_python
node_python -->|"registers file API"| node_pyfiles
node_pyfiles -->|"reads and writes"| node_system
node_python -->|"registers selections"| node_pyselection
node_python -->|"registers systems"| node_pysystem
node_python -->|"registers atoms"| node_pyatom
node_python -->|"registers boxes"| node_pybox
node_python -->|"registers force fields"| node_pyforcefield
node_python -->|"registers topology and state"| node_pytopology
node_user -.->|"enables TPR/CPT support"| node_gromacs
node_gromacs -.->|"provides optional format support"| node_io
node_io -->|"writes files"| node_result
node_distance -->|"returns pairs and distances"| node_result
node_measure -.->|"produces measurements"| node_result
node_sasa -->|"produces surface areas"| node_result

click node_system "https://github.com/yesint/molar/blob/master/molar/src/topology.rs"
click node_atoms "https://github.com/yesint/molar/blob/master/molar/src/atom.rs"
click node_bonds "https://github.com/yesint/molar/blob/master/molar/src/bond_storage.rs"
click node_periodic "https://github.com/yesint/molar/blob/master/molar/src/periodic_box.rs"
click node_io "https://github.com/yesint/molar/blob/master/molar/src/io.rs"
click node_gromacs "https://github.com/yesint/molar/blob/master/molar_gromacs/src/lib.rs"
click node_selection "https://github.com/yesint/molar/blob/master/molar/src/selection.rs"
click node_distance "https://github.com/yesint/molar/blob/master/molar/src/distance_search.rs"
click node_measure "https://github.com/yesint/molar/blob/master/molar/src/measure.rs"
click node_sasa "https://github.com/yesint/molar/blob/master/molar/src/sasa.rs"
click node_dssp "https://github.com/yesint/molar/blob/master/molar/src/dssp.rs"
click node_tasks "https://github.com/yesint/molar/blob/master/molar/src/analysis_task.rs"
click node_perception "https://github.com/yesint/molar/blob/master/molar/src/perception.rs"
click node_smiles "https://github.com/yesint/molar/blob/master/molar/src/smiles.rs"
click node_forcefield "https://github.com/yesint/molar/blob/master/molar_ff/src/charge.rs"
click node_amber "https://github.com/yesint/molar/blob/master/molar_ff/src/amber.rs"
click node_membrane "https://github.com/yesint/molar/blob/master/molar_membrane/src/lib.rs"
click node_cli "https://github.com/yesint/molar/blob/master/molar_bin/src/main.rs"
click node_python "https://github.com/yesint/molar/blob/master/molar_python/src/lib.rs"
click node_pyfiles "https://github.com/yesint/molar/blob/master/molar_python/src/file_handler.rs"
click node_pyselection "https://github.com/yesint/molar/blob/master/molar_python/src/selection.rs"
click node_pysystem "https://github.com/yesint/molar/blob/master/molar_python/src/system.rs"
click node_pyatom "https://github.com/yesint/molar/blob/master/molar_python/src/atom.rs"
click node_pybox "https://github.com/yesint/molar/blob/master/molar_python/src/periodic_box.rs"
click node_pyforcefield "https://github.com/yesint/molar/blob/master/molar_python/src/force_field.rs"
click node_pytopology "https://github.com/yesint/molar/blob/master/molar_python/src/topology_state.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_system,node_atoms,node_bonds,node_periodic toneBlue
class node_selection,node_distance,node_measure,node_sasa,node_dssp,node_tasks toneAmber
class node_io,node_gromacs toneMint
class node_perception,node_smiles,node_forcefield,node_amber,node_membrane toneRose
class node_cli,node_python,node_pyfiles,node_pyselection,node_pysystem,node_pyatom,node_pybox,node_pyforcefield,node_pytopology,node_user,node_result toneIndigo
```

## Components

### Molecular core

- [System and topology](https://github.com/yesint/molar/blob/master/molar/src/topology.rs): `molar/src/topology.rs`
- [Atom model and storage](https://github.com/yesint/molar/blob/master/molar/src/atom.rs): `molar/src/atom.rs`
- [Bond model and storage](https://github.com/yesint/molar/blob/master/molar/src/bond_storage.rs): `molar/src/bond_storage.rs`
- [Periodic box](https://github.com/yesint/molar/blob/master/molar/src/periodic_box.rs): `molar/src/periodic_box.rs`

### Selection and analysis

- [Atom selections](https://github.com/yesint/molar/blob/master/molar/src/selection.rs): `molar/src/selection.rs`
- [Distance search](https://github.com/yesint/molar/blob/master/molar/src/distance_search.rs): `molar/src/distance_search.rs`
- [Geometry and fitting](https://github.com/yesint/molar/blob/master/molar/src/measure.rs): `molar/src/measure.rs`
- [SASA analysis](https://github.com/yesint/molar/blob/master/molar/src/sasa.rs): `molar/src/sasa.rs`
- [Secondary structure](https://github.com/yesint/molar/blob/master/molar/src/dssp.rs): `molar/src/dssp.rs`
- [Trajectory analysis tasks](https://github.com/yesint/molar/blob/master/molar/src/analysis_task.rs): `molar/src/analysis_task.rs`

### Files and trajectories

- [Structure and trajectory I/O](https://github.com/yesint/molar/blob/master/molar/src/io.rs): `molar/src/io.rs`
- [Gromacs TPR/CPT plugin](https://github.com/yesint/molar/blob/master/molar_gromacs/src/lib.rs): `molar_gromacs/src/lib.rs`

### Modeling extensions

- [Chemical perception](https://github.com/yesint/molar/blob/master/molar/src/perception.rs): `molar/src/perception.rs`
- [SMILES chemistry](https://github.com/yesint/molar/blob/master/molar/src/smiles.rs): `molar/src/smiles.rs`
- [GAFF and charges](https://github.com/yesint/molar/blob/master/molar_ff/src/charge.rs): `molar_ff/src/charge.rs`
- [Amber mechanics](https://github.com/yesint/molar/blob/master/molar_ff/src/amber.rs): `molar_ff/src/amber.rs`
- [Membrane analysis](https://github.com/yesint/molar/blob/master/molar_membrane/src/lib.rs): `molar_membrane/src/lib.rs`

### User interfaces

- [Molecular utilities](https://github.com/yesint/molar/blob/master/molar_bin/src/main.rs): `molar_bin/src/main.rs`
- [Python API](https://github.com/yesint/molar/blob/master/molar_python/src/lib.rs): `molar_python/src/lib.rs`
- [Python file interface](https://github.com/yesint/molar/blob/master/molar_python/src/file_handler.rs): `molar_python/src/file_handler.rs`
- [Python selections](https://github.com/yesint/molar/blob/master/molar_python/src/selection.rs): `molar_python/src/selection.rs`
- [Python system and state](https://github.com/yesint/molar/blob/master/molar_python/src/system.rs): `molar_python/src/system.rs`
- [Python atom access](https://github.com/yesint/molar/blob/master/molar_python/src/atom.rs): `molar_python/src/atom.rs`
- [Python periodic box](https://github.com/yesint/molar/blob/master/molar_python/src/periodic_box.rs): `molar_python/src/periodic_box.rs`
- [Python force fields](https://github.com/yesint/molar/blob/master/molar_python/src/force_field.rs): `molar_python/src/force_field.rs`
- [Python topology and state](https://github.com/yesint/molar/blob/master/molar_python/src/topology_state.rs): `molar_python/src/topology_state.rs`

### Other components

- **Molecular analyst**
- **Analysis or output**

## Connections

- Molecular analyst → Structure and trajectory I/O: opens files (evidence: `README.md`)
- Structure and trajectory I/O → System and topology: loads structures (evidence: `README.md`)
- System and topology → Atom model and storage: stores atoms
- System and topology → Bond model and storage: stores bonds (evidence: `molar/src/bond_storage.rs`)
- Molecular analyst → Atom selections: selects atoms (evidence: `README.md`)
- Atom selections → System and topology: binds to system (evidence: `README.md`)
- Molecular analyst → Distance search: searches distances (evidence: `README.md`)
- Molecular analyst → Geometry and fitting: measures and fits (evidence: `README.md`)
- Molecular analyst → SASA analysis: calculates SASA (evidence: `README.md`)
- Molecular analyst → Secondary structure: analyzes structure (evidence: `README.md`)
- Molecular analyst → Trajectory analysis tasks: runs trajectory tasks (evidence: `README.md`)
- Molecular analyst → Periodic box: uses PBC (evidence: `README.md`)
- Molecular analyst → Chemical perception: perceives chemistry
- Molecular analyst → SMILES chemistry: uses SMILES
- Molecular analyst → GAFF and charges: assigns types and charges
- Molecular analyst → Amber mechanics: uses Amber mechanics
- Molecular analyst → Membrane analysis: analyzes membranes (evidence: `molar_membrane/src/lib.rs`)
- Molecular analyst → Molecular utilities: runs utilities (evidence: `molar_bin/src/main.rs`)
- Molecular utilities → Structure and trajectory I/O: processes molecular files
- Molecular analyst → Python API: uses Python API (evidence: `README.md`)
- Python API → Python file interface: registers file API (evidence: `molar_python/src/lib.rs`)
- Python file interface → System and topology: reads and writes (evidence: `molar_python/src/file_handler.rs`)
- Python API → Python selections: registers selections (evidence: `molar_python/src/lib.rs`)
- Python API → Python system and state: registers systems (evidence: `molar_python/src/lib.rs`)
- Python API → Python atom access: registers atoms (evidence: `molar_python/src/lib.rs`)
- Python API → Python periodic box: registers boxes (evidence: `molar_python/src/lib.rs`)
- Python API → Python force fields: registers force fields (evidence: `molar_python/src/lib.rs`)
- Python API → Python topology and state: registers topology and state (evidence: `molar_python/src/lib.rs`)
- Molecular analyst → Gromacs TPR/CPT plugin: enables TPR/CPT support (evidence: `README.md`)
- Gromacs TPR/CPT plugin → Structure and trajectory I/O: provides optional format support (evidence: `README.md`)
- Structure and trajectory I/O → Analysis or output: writes files (evidence: `README.md`)
- Distance search → Analysis or output: returns pairs and distances
- Geometry and fitting → Analysis or output: produces measurements
- SASA analysis → Analysis or output: produces surface areas
