How flexible is elgg?

I know it has great out-of-the-box features but is it easy to customize?

Like when I query stuff from the database or change css layouts.

Is it faster to create my own modules for it or just go on and write everything from scratch using frameworks like Cake