If I would take a backup via TRWP, does it include all my apps, app data, messages, contacts or it would just take backup of the ROM only, so I could get a fresh ROM with factory restored when I restore it ?
To my knowledge, TWRP does a nandroid backup. As you can read in the tag wikis of the mentioned tags (nandroid, backup), a Nandroid backup takes images of your partitions. It's not a backup on the file level, but on partition level. So it includes everything stored on those partitions. Doing a full Nandroid backup of your system thus includes the entire system, one file per partition. There are only very few things not contained, such as the radio-firmware.
So to put it as a short direct answer to your question: Yes, a full Nandroid backup would include all your apps, app data, messages, contacts.
Though it might be complicated to extract them separately (Nandroid can't do that, it's always an "all-or-nothing". But e.g. Titanium Backup can read data from Nandroid backups. Just in case you'll need that :)
It is very important to answer this question correctly as many people rely on this backup. Until when you actually need it, you realize that it is not exactly what you think it is, which is disastrous.
Let me answer this question very clearly for everyone: TWRP backup does include apps and their data BUT skips media files such as your pictures, videos and music!
I took a full TWRP backup before I sent my phone to service. When it was back, I restored the backup. My phone started like it was before. Soon after I realized that my photos and music was completely gone. I looked everywhere in my phone but there was nothing left from my pictures! Luckily, I for some reason had a hunch about it and copied my photos separately. And music can be restored easily. (Although I remembered that after 3 weeks that I made a separate copy of my photos). It really hurts!
It backs up data partition but for some reason skips the /data/media folder.
TWRP does NOT backup internal media. TWRP specifically states it will not backup /data/media. See https://twrp.me/faq/backupexclusions.html.
"To be absolutely clear when you do something like this:
Creating a full backup in TWRP (including /data partition) Factory resetting your phone Restoring your previously taken full backup Result: all your saved data will be there but your data on the internal storage gets LOST!
You can backup System,Data,Boot,Recovery,Cache,efs
System , Data , Boot are selected by default which includes your ROM , Apps , Appdata , Kernel and you can choose to backup Recovery , Cache , efs which bundles things on your internal SD card like your contacts and photos and videos. TWRP also provides compression which is pretty handy if your backup becomes large.