This page is also published as UI Modding support on the Egosoft wiki.
X4's interface is Lua, and it is moddable without touching the executable. The vanilla code sits in ui.cat: ui/addons/* are the menus, ui/core/* is the HUD, and ui/widget/lua/widget_fullscreen.lua is the widget layer the menus are built on. An extension joins the menus side by shipping a ui.xml of its own; the HUD runs in a second, separate Lua environment that no extension can register a file into.
Either way, a UI mod starts from the global namespace the game hands it.
Every name X4 puts into the global namespace of UI Lua code - origin, availability, version and what vanilla's own code proves about the signature.
Every function and type X4 exposes to UI Lua through ffi.C - signature, where it is declared, which Lua state can see it and which game version has it.
Every callback kuertee's UI Extensions and HUD puts into X4's menus - what dispatches it, what it is handed, what it may return and which release has it.
The channels between UI Lua and the XML side - raise_lua_event, AddUITriggeredEvent, SignalObject and the blackboard - with a working pair of files for each.