Custom App Server Script

i want to add server script for my custom app,
where to add server script in backend (In Which File) ?

Thank you

Check the hooks concept.