# project-gemmi/gemmi architecture

> Architecture diagram of the GitHub repository project-gemmi/gemmi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/project-gemmi/gemmi
- Repository: https://github.com/project-gemmi/gemmi

## Overview

##### Project type and purpose
- This is “gemmi”: an open‐source C++ library (C++14) for macromolecular crystallography and CIF/STAR file handling.
- It provides core functionality (read/write structures, symmetry, maps, reflections), plus:
- Command‐line tools (C++ executables under prog/)
- Python bindings (python/ + pyproject.toml)
- Fortran interface (fortran/)
- WebAssembly bindings (wasm/)
- Documentation (docs/)
- Use cases include library integration, interactive scripting, batch CLI processing and in‐browser demos.

##### File structure
- Top‐level directories:
- /gemmi & src/…: the core C++ library implementation
- prog/: CLI executables built on the library
- python/: Python extension modules (C++ glue + stubs)
- fortran/: Fortran wrappers, Makefile
- wasm/: Emscripten‐based WASM build, JS glue, TypeScript definitions
- docs/: Sphinx documentation source, code examples
- examples/: standalone demos in Python and C++
- tests/: unit and integration tests
- third_party/: bundled dependencies (PEGTL parser, zlib, doctest, etc.)
- tools/: helper scripts for release, CI, data generation
- Build and configuration: CMakeLists.txt at root; CI scripts in .github/workflows; pyproject.toml and setup.cfg for Python packaging; readthedocs.yaml for docs.

##### README for additional insights
- Confirms multi‐interface library: C++, Python, Fortran, WASM.
- Mentions online tools, documentation site, continuous integration, citation.

##### Diagramming recommendations
- Orange for CLI tools
- Yellow for Documentation system
- Gray for third‐party dependencies
- Purple for CI/CD & packaging pipeline
- From source directories into the build system
- From CI nodes to publish destinations (PyPI, ReadTheDocs)

##### Details without over‐splitting
- Major modules (include/, src/, prog/, python/, wasm/, fortran/, docs/, tests/, third_party/, tools/).
- Build pipeline: single CMake invocation producing library, executables, bindings, WASM.
- How tests and benchmarks consume the library.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core C++ Library"
        Core["Core C++ Library"]:::core
    end

    subgraph "Language/Platform Bindings"
        Python["Python Bindings"]:::binding
        Fortran["Fortran Interface"]:::binding
        Wasm["WebAssembly Bindings"]:::binding
    end

    subgraph "CLI Tools"
        Cli["CLI Tools (prog/)"]:::cli
    end

    subgraph "Documentation System"
        Docs["Documentation Site"]:::docs
    end

    subgraph "Examples & Demos"
        Examples["Examples & Demos"] 
    end

    subgraph "Tests & Benchmarks"
        Tests["Tests (tests/)"]:::test
        Bench["Benchmarks"]:::test
    end

    subgraph "Third-Party Dependencies"
        ThirdParty["Third-Party"]:::third
    end

    subgraph "Helper Scripts & Tools"
        Tools["Helper Scripts & Tools"] 
    end

    subgraph "CI/CD & Packaging"
        CI["CI/CD Pipelines"]:::ci
        CMake["CMake Build"]:::ci
        PyPI["PyPI Publishing"]:::ci
        RTD["ReadTheDocs Publishing"]:::ci
    end

    %% Relationships
    CI -->|triggers build| CMake
    CMake -->|builds| Core
    CMake -->|builds| Cli
    CMake -->|generates| Python
    CMake -->|generates| Fortran
    CMake -->|emscripten| Wasm
    Core -->|link| Python
    Core -->|link| Fortran
    Core -->|link| Wasm
    Core -->|link| Cli
    Core -->|used by| Tests
    Core -->|used by| Bench
    Docs -->|Sphinx→| RTD
    CI -->|publish| PyPI
    CI -->|publish| RTD

    %% Click Events
    click Core "https://github.com/project-gemmi/gemmi/tree/master/include/gemmi/"
    click Cli "https://github.com/project-gemmi/gemmi/tree/master/prog/"
    click Python "https://github.com/project-gemmi/gemmi/tree/master/python/"
    click Fortran "https://github.com/project-gemmi/gemmi/tree/master/fortran/"
    click Wasm "https://github.com/project-gemmi/gemmi/tree/master/wasm/"
    click Docs "https://github.com/project-gemmi/gemmi/tree/master/docs/"
    click Examples "https://github.com/project-gemmi/gemmi/tree/master/examples/"
    click Tests "https://github.com/project-gemmi/gemmi/tree/master/tests/"
    click ThirdParty "https://github.com/project-gemmi/gemmi/tree/master/third_party/"
    click Tools "https://github.com/project-gemmi/gemmi/tree/master/tools/"
    click CI "https://github.com/project-gemmi/gemmi/blob/master/.github/workflows/ci.yml"

    %% Styles
    classDef core fill:#cce5ff,stroke:#2f5d9e,color:#000;
    classDef binding fill:#d4edda,stroke:#276838,color:#000;
    classDef cli fill:#ffe5b4,stroke:#997404,color:#000;
    classDef docs fill:#fff9c4,stroke:#9e8c03,color:#000;
    classDef test fill:#f0f0f0,stroke:#888888,color:#000;
    classDef third fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef ci fill:#e0bbff,stroke:#5e348b,color:#000;
```
