Run Python code from external process
I see two approaches to this.

You can compile entire blender as python module (completely without user interface) and use it inside an external python script.

https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule

A custom solution. as described here.

How to remotely run a Python script in an existing Blender instance?