You keep it in your house and charge people to come look at it (SaaS).
Those people sometimes look at it and build a copy (competitor) and that's okay.
You don't have to publish your code, or allow other people to run it.