Architecture
CadFlow narrows the boundary between application code and OpenCascade. Python expresses modeling intent and structured workflows; a stable C ABI crosses into a C++17 session that owns exact geometry.
Dependency direction
Python frontend → stable C ABI → C++ Session / ShapeHandle → OpenCascade
The modern frontend contains no direct OCC imports. It sees an opaque session token and shape ID, not a TopoDS_Shape. This keeps OpenCascade types and ownership rules out of application code.
Native ownership
Each Model owns one Session, and the session owns every shape created through that model.
A handle cannot cross sessions. Closing the model invalidates its handles. Expensive construction, boolean, topology, tessellation, measurement, and exchange calls remain close to OpenCascade instead of moving geometry across Python one object at a time.
Python frontend
The frontend has two responsibilities:
Model,Shape, andGraphprovide the small handle-based native API.- Public domain facades provide sketches, assemblies, semantics, serialization, inspection, Scene archives, standard parts, and solver-neutral handoff structures.
Domain modules are intentionally thin public facades over the bundled complete feature layer. The import layout can remain stable while geometry-heavy paths migrate behind it.
Native runtime
The native source tree follows this dependency direction:
c_api.cpp → runtime / io / kernel / physics → core
coreowns shape storage and shared types, not modeling algorithms.kernelowns exact geometry construction and inspection.ioowns geometry exchange and serialization formats.runtimeparses and executes native graph batches.physicsmeasures exact face evidence and reduced connector response.c_api.cppis the only installed ABI boundary.
Internal OCCT types and module headers are not public API.
Why some work stays in Python
Expressions, units, constraint systems, assemblies, semantic tags, Model JSON, Scene schemas, and translator policies are primarily structured-data orchestration. Moving them across the ABI would increase complexity without removing a geometry bottleneck.
The architecture is not "everything in C++." It is "geometry-intensive work in C++; policy and structured workflows in Python."
Delivery path
Exact BREP remains the source of truth. Meshes and GLB previews are derived views:
This lets delivery checks compare engineering formats and previews against the same underlying geometry.