Yes it's completely possible. There are two parts to making something like this work:
1. The scripts themselves. You can generally script InDesign Server and desktop InDesign exactly the way using ExtendScript. So that's the part of the process where your script receives variables and passes them into the template and replaces something you've identified as variable, whether text or an image or something else (perhaps a color theme, etc.). You should get your scripts running on desktop before playing around with server.
2. The messaging between your web app and the server. Whatever language you are using (i.e. PHP, .Net, Java, Ruby…) there is a way to make a SOAP call to InDesign Server to tell it basically "run this script with these parameters". You should get the "hello world" script running from a SOAP call on the server before using your real variable-driven document.
The documentation of these things is available here:
You need to download the InDesign Server SDK (don't worry if you're on CC and it says CS6, almost nothing changed) and the InDesign Scripting SDK. The Server SDK deals with part #2 above, the Scripting SDK with part #1.
It really isn't that hard. I should warn you, though, that it is addictive and once you do your first one you will become all-powerful and want to do nothing else. :-)
Good luck and don't hesitate to ask questions.
Thank you Max! This is great information and I will definitely see if I can get this up and running!