Think node, except the other direction. They write their backend in OCaml, and then they also write their web ui in OCaml with a translation layer
Or think of gwt (java) awhile back