How to write remote cli module (no client-side python) right way?

I cannot to find out how to write a module to controle remote device via SSH. Please can you help me with the example?
I have several roles using the “raw” module but I’d like to write my own module to have the complex logic hidden inside it.
I’ve looked through some storage modules - all of them use external optional python libraries. I’ve looked through network modules - they are very complex for me.
Please need help.