# rwth-e3d/ifc2tso architecture

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

- Interactive diagram: https://gitdiagram.com/rwth-e3d/ifc2tso
- Repository: https://github.com/rwth-e3d/ifc2tso

## Overview

##### Project Type and Purpose
- This is a modular, command-line pipeline application (IFC2TSO) written in Python 3.7. It ingests IFC (Industry Foundation Classes) building models, transforms them into an internal graph representation, enriches and simplifies that graph, and finally exports a technical system ontology (TSO).
- The “modules” directory contains three independent pipeline stages (IFC2GRAPH, GRAPH, GRAPH2TSO), each with its own conda environment. The top-level “src” directory provides a unified entry point (src/main.py) that calls all stages in sequence.

##### Core Components
a. Input Layer
- IFC Models on disk (user-supplied .ifc files)
b. Processing Modules (each a Python package + environment)
1. IFC2GRAPH
- Parses IFC via ifcopenshell
- Builds an initial NetworkX graph of building elements
2. GRAPH
- Analyzes, enriches, reduces graph topology (helper_analyse.py, helper_enrich.py)
3. GRAPH2TSO
- Converts graph → TSO ontology using rdflib, yields RDF/XML or JSON-LD
c. Orchestrator
- src/main.py with argparse handles user flags, invokes each module in order
d. Output Layer
- Text logs, JSON, BCF files, RDF/OWL produced in the model path

##### Relationships & Data Flow
- Logging and intermediate storage occurs at each stage (TXT, JSON, BCF)

##### Architectural Patterns & Design Principles
- Pipeline pattern: discrete, reusable stages that can run independently or chained
- Modular packaging: each module has its own conda env (reproducibility, isolation)
- Single-responsibility: helpers are separated (analyse, enrich, convert, check)
- CLI façade: unified interface with fine-grained flags

##### Key Technologies
- Python 3.7.12
- Conda environments (env/environment.yml, modules/*/env/environment.yml)
- ifcopenshell (IFC parsing)
- NetworkX (graph handling)
- Rtree, trimesh, NumPy (spatial queries)
- rdflib (ontology serialization)
- lxml (BCF file creation)

##### Must‐Include
- Clear component names (IFC2GRAPH, GRAPH, GRAPH2TSO, Orchestrator)
- Modules (blue rectangles)
- Orchestrator (orange hexagon)
- Annotations of file formats and major helper scripts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input
    IFC["IFC Models (.ifc)"]:::data

    %% Pipeline Modules
    subgraph "IFC2GRAPH Module" 
        direction TB
        IFC2GRAPH_main["IFC2GRAPH\nmodules/ifc2graph/src/main.py\n(ifcopenshell, NetworkX)"]:::module
    end
    subgraph "GRAPH Module"
        direction TB
        GRAPH_main["GRAPH\nmodules/graph/src/main.py\n(helper_analyse.py, helper_enrich.py)"]:::module
    end
    subgraph "GRAPH2TSO Module"
        direction TB
        GRAPH2TSO_main["GRAPH2TSO\nmodules/graph2tso/src/main.py\n(rdflib, lxml)"]:::module
    end

    %% Outputs
    Logs["Logs (TXT)"]:::data
    JSON["JSON (NetworkX)"]:::data
    BCF["BCF (lxml)"]:::data
    RDF["RDF/OWL"]:::data

    %% Orchestrator
    Orchestrator["Orchestrator CLI\nsrc/main.py"]:::orchestrator

    %% External Libraries
    ExtLibs["Shared Libraries\nNumPy, Rtree, trimesh"]:::external

    %% Data Flows
    IFC -->|IFC| IFC2GRAPH_main
    IFC2GRAPH_main -->|NetworkX Graph| GRAPH_main
    GRAPH_main -->|Reduced Graph| GRAPH2TSO_main
    GRAPH2TSO_main -->|RDF/XML| RDF
    GRAPH2TSO_main -->|JSON-LD| JSON
    GRAPH2TSO_main -->|BCF| BCF
    IFC2GRAPH_main -->|Logs| Logs
    GRAPH_main -->|Logs| Logs
    GRAPH2TSO_main -->|Logs| Logs

    %% Orchestration
    Orchestrator -.->|invoke| IFC2GRAPH_main
    Orchestrator -.->|invoke| GRAPH_main
    Orchestrator -.->|invoke| GRAPH2TSO_main

    %% Dependencies
    IFC2GRAPH_main --> ExtLibs
    GRAPH_main --> ExtLibs
    GRAPH2TSO_main --> ExtLibs

    %% Click Events
    click Orchestrator "https://github.com/rwth-e3d/ifc2tso/blob/master/src/main.py"
    click IFC2GRAPH_main "https://github.com/rwth-e3d/ifc2tso/blob/master/modules/ifc2graph/src/main.py"
    click GRAPH_main "https://github.com/rwth-e3d/ifc2tso/blob/master/modules/graph/src/main.py"
    click GRAPH2TSO_main "https://github.com/rwth-e3d/ifc2tso/blob/master/modules/graph2tso/src/main.py"

    %% Styles
    classDef module fill:#ADD8E6,stroke:#000
    classDef data fill:#90EE90,stroke:#060
    classDef orchestrator fill:#FFA500,stroke:#000
    classDef external fill:#F0E68C,stroke:#000
    class IFC2GRAPH_main,GRAPH_main,GRAPH2TSO_main module
    class IFC,Logs,JSON,BCF,RDF data
    class Orchestrator orchestrator
    class ExtLibs external
```
