# simplifiedlogic/creoson architecture

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

- Interactive diagram: https://gitdiagram.com/simplifiedlogic/creoson
- Repository: https://github.com/simplifiedlogic/creoson

## Overview

##### Project type and purpose
- This is not a classic three-tier web app but an open-source automation “micro-server” (CREOSON) for PTC’s CREO Parametric.
- It exposes a JSON/HTTP API (and a lightweight web UI) so any language or script can drive CREO via the free JLINK interface.

##### File structure
Top-level folders each build to a JAR (via Ant):
- creoson-core   – low-level JLINK call wrappers, data models, JNI bridges
- creoson-intf   – Java interfaces and data classes used to marshal JLINK results
- creoson-json   – JSON parsing/templating, command dispatch to jShell providers
- creoson-json-const – typed request/response parameter classes for JSON
- creoson-server – HTTP server (MainServer.java), REST/JShell endpoints, static web assets (UI + docs)
- creofuncs & creo4funcs – example “functions” built on top of jShell to expose common tasks (ExportPDF, ExportGeometry, etc.)
- jshell_native  – C++ JNI native library that bridges Java jShell calls through the PTC JLINK DLL into CREO

Root contains build scripts (build-all.xml, build-zip.xml, build-javadoc.xml), README, license, release notes.

##### README for insights
- CREOSON listens for JSON requests over HTTP, translates them via a jShell interface into JLINK calls, and returns JSON responses.
- The “geeky” section confirms the layering: JSON ⇄ jShell ⇄ JLINK ⇄ CREO.

##### Main architectural layers and components
a. Client layer
- Any JSON-capable client (curl, Python, JS front-end, custom script)
- Web UI in creoson-server/web (HTML + JS + Ace Editor)

b. HTTP/JSON API layer (creoson-server)
- MainServer.java starts an HTTP listener
- ServerHttpHandler, JsHellHttpHandler, FileHttpHandler route requests
- Static asset handler serves the UI/docs

c. JSON dispatch layer (creoson-json + creoson-json-const)
- JShellJsonHandler orchestrates:
– parse incoming JSON into typed request objects (requests in creoson-json-const)
– locate the correct JLJson*Handler to handle the command
– build a JSON response object (typed response classes)

d. Business logic / jShell provider layer (creoson-intf + creoson-core)
- JShellProvider interface (creoson-core/src/.../JShellProvider.java)
- Default implementation uses the JNI C++ library from jshell_native or the pure-Java JLINK wrapper
- creoson-core packages (“calls” + “impl”) encapsulate every JLINK operation as a CallXXX object with arguments

e. Native JNI bridge (jshell_native)
- JCConnection.cpp, JCFeature.cpp, etc.: native C++ code that loads the JLINK DLL and marshals calls into CREO
- Exposes a “jshell_native.dll” that the Java layer loads

f. External system
- PTC CREO Parametric running on the same machine
- JLINK API (a PTC-provided DLL)

##### Final advice
– Capture the end-to-end flow of data: Client → JSON → calls → CREO → back
– Show extension points: where to drop in new command handlers or alternative JShellProviders

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        CLI["JSON-capable Client"]:::client
        UI["Browser UI (HTML5, JS, Ace)"]:::client
    end

    %% API Server Layer
    subgraph "API Server (creoson-server)" 
        direction TB
        MS["MainServer.java"]:::api
        SH["ServerHttpHandler.java"]:::api
        JH["JshellHttpHandler.java"]:::api
        FH["FileHttpHandler.java"]:::api
        StaticUI["Static Web Assets"]:::api
    end

    %% JSON Dispatch Layer
    subgraph "JSON Dispatch (creoson-json + creoson-json-const)"
        direction TB
        JJH["JShellJsonHandler.java"]:::json
        JC["JLJsonCommandHandler.java"]:::json
        FT["FunctionTemplate.java"]:::json
        BR["BaseRequest.java"]:::json
        BS["BaseResponse.java"]:::json
    end

    %% Business Logic / jShell Providers Layer
    subgraph "Business Logic / jShell Providers"
        direction TB
        IJS["IJShellProvider.java"]:::business
        SP["JShellProvider.java"]:::business
        JLCon["JLConnection.java"]:::business
    end

    %% JLINK Wrappers Layer
    subgraph "JLINK Wrappers & Calls (creoson-core)"
        direction TB
        CallsPkg["Call Packages"]:::business
        CA["CallAssembly.java"]:::business
    end

    %% JNI Native Bridge Layer
    subgraph "JNI Native Bridge (jshell_native)"
        direction TB
        JCConnCPP["JCConnection.cpp"]:::native
        JCFtrCPP["JCFeature.cpp"]:::native
        JSNcpp["jshell_native.cpp"]:::native
        Hdr["com_simplifiedlogic_nitro_jlink_cpp_JCConnection.h"]:::native
    end

    %% External CREO
    subgraph "External System"
        direction TB
        CreoApp["CREO Parametric"]:::external
        JlinkDLL["PTC JLINK DLL"]:::external
    end

    %% Connections
    CLI -->|JSON request| MS
    UI -->|AJAX| SH
    MS --> SH
    SH --> JH
    SH --> FH
    JH --> JJH
    FH --> StaticUI
    JJH --> JC
    JC --> FT
    JJH --> BR
    JJH --> BS
    JJH --> IJS
    IJS --> SP
    SP --> JLCon
    JLCon --> CallsPkg
    CallsPkg --> CA
    CA --> JCConnCPP
    JCConnCPP --> CreoApp
    JCConnCPP --> JlinkDLL

    %% Click Events
    click CallsPkg "https://github.com/simplifiedlogic/creoson/tree/master/creoson-core/src/com/simplifiedlogic/nitro/jlink/calls"
    click CA "https://github.com/simplifiedlogic/creoson/blob/master/creoson-core/src/com/simplifiedlogic/nitro/jlink/calls/assembly/CallAssembly.java"
    click JLCon "https://github.com/simplifiedlogic/creoson/blob/master/creoson-core/src/com/simplifiedlogic/nitro/jlink/impl/JLConnection.java"
    click SP "https://github.com/simplifiedlogic/creoson/blob/master/creoson-core/src/com/simplifiedlogic/nitro/jlink/intf/JShellProvider.java"
    click IJS "https://github.com/simplifiedlogic/creoson/blob/master/creoson-intf/src/com/simplifiedlogic/nitro/jlink/intf/IJShellProvider.java"
    click MS "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/src/com/simplifiedlogic/nitro/jshell/MainServer.java"
    click SH "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/src/com/simplifiedlogic/nitro/jshell/ServerHttpHandler.java"
    click JH "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/src/com/simplifiedlogic/nitro/jshell/JshellHttpHandler.java"
    click FH "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/src/com/simplifiedlogic/nitro/jshell/FileHttpHandler.java"
    click StaticUI "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/web/index.html"
    click StaticUI "https://github.com/simplifiedlogic/creoson/blob/master/creoson-server/web/assets/creoson_stuff/creoson_js/common_creoson_ajax.js"
    click JJH "https://github.com/simplifiedlogic/creoson/blob/master/creoson-json/src/com/simplifiedlogic/nitro/jshell/json/JShellJsonHandler.java"
    click JC "https://github.com/simplifiedlogic/creoson/blob/master/creoson-json/src/com/simplifiedlogic/nitro/jshell/json/handler/JLJsonCommandHandler.java"
    click FT "https://github.com/simplifiedlogic/creoson/blob/master/creoson-json/src/com/simplifiedlogic/nitro/jshell/json/template/FunctionTemplate.java"
    click BR "https://github.com/simplifiedlogic/creoson/blob/master/creoson-json-const/src/com/simplifiedlogic/nitro/jshell/json/request/BaseRequest.java"
    click BS "https://github.com/simplifiedlogic/creoson/blob/master/creoson-json-const/src/com/simplifiedlogic/nitro/jshell/json/response/BaseResponse.java"
    click JCConnCPP "https://github.com/simplifiedlogic/creoson/blob/master/jshell_native/jshell_native/JCConnection.cpp"
    click JCFtrCPP "https://github.com/simplifiedlogic/creoson/blob/master/jshell_native/jshell_native/JCFeature.cpp"
    click JSNcpp "https://github.com/simplifiedlogic/creoson/blob/master/jshell_native/jshell_native/jshell_native.cpp"
    click Hdr "https://github.com/simplifiedlogic/creoson/blob/master/jshell_native/jshell_native/com_simplifiedlogic_nitro_jlink_cpp_JCConnection.h"

    %% Styles
    classDef client fill:#D4E157,stroke:#888,stroke-width:1px
    classDef api fill:#42A5F5,stroke:#333,stroke-width:1px
    classDef json fill:#66BB6A,stroke:#333,stroke-width:1px
    classDef business fill:#FFA726,stroke:#333,stroke-width:1px
    classDef native fill:#EF5350,stroke:#333,stroke-width:1px
    classDef external fill:#B0BEC5,stroke:#333,stroke-width:1px
```
