Added src gen api

Refined code structure. (isolated def JSON gen into a separate worker
file)