So my group and i are right at the entrance of a big room where there are a bunch of enemies. We were talking to one of the enemies, everybody's alert getting ready for initiative. While we're talking one enemy comes up behind us from around the corner, and right before initiative somebody casts web on us that we can't see who is either invisible or hiding behind something. Does he get to cast web or is it initiative before that? No one rolled a check to see the one guy coming up behind us or to see or hear the invisible guy.
Yes, that is the DM's prerogative. The enemy can get the drop on the characters if the DM wants so.
Let's address your points one by one:
No one rolled a check to see the one guy coming up behind us or to see or hear the invisible guy.
That is why characters have a passive perception. When the DM needs to make an opposed test (stealth vs perception in this case) without tipping the characters that something is going on, DM rolls against the characters passive perception. DM can call for a roll from the players, but only if the DM wants it.
and right before initiative somebody casts web on us
There is no need for suprised parties (or those that will enter combat later on) to roll initiative right at the beginning of the combat. So since this caster had a "free turn" on your characters, you get to roll initiative on round 2. Its normal. Again, calling for initiative sometimes put players on combat/murderhobo mode, so it might be better to avoid one, sometimes.
We were talking to one of the enemies, everybody's alert getting ready for initiative.
Even if there were not obviously hostile creatures in sight, it is a safe bet to assume characters of a fantasy world are always on their toes and always trying to spot trouble before it gets to drop on them. Everybody declaring they are on alert has little mechanical effect on the game. But is still a nice thing to do, to keep immersion.
This is within the DM prerogative to decide how it all goes.
The way I would rule it is that due to the circumstances, everyone was ready for battle, so surprise is not possible for the same reason that a new participant entering an ongoing battle cannot gain surprise. So nobody will miss an action, and effects that depend on surprise (like an assassin's automatic critical on a hit) would not apply.
I would have rolled the attacker's Stealth against everyone's Passive Perception to begin, to see if said spellcaster was able to get close enough to cast without being spotted, and was able to cast a spell without being noticed during the process of casting.
If the Stealth roll succeeded, the casting of the Web would be the trigger for everyone rolling initiative, and then each creature (including the Webcaster) would act in initiative order from that point onward (starting with his saving throw against the Web spell if he's in the area of effect, unless said Web is dispelled or burned off before his turn). So yes, the instigator gets to cast the Web, but no one misses any actions due to surprise. If the situation was not so tense, with everyone on alert and "getting ready for initiative", then surprise might also apply.
Also note that I would play this both ways. If it was a PC who was hiding, and started the fight by casting the Web (or a Hex spell, or shooting an arrow [with advantage and Sneak Attack, since no others will have acted yet, and this ability does not depend on Surprise], etc.), I would give the person initiating the hostilities that first action, and then everyone rolls initiative and acts in order. The place where this can really make a difference is if ambushing a major foe, and the hiding caster casts a Hex and specifies disadvantage on Dex checks – then in the initiative rolls immediately following, the target gets a disadvantage to his initiative, since that’s a Dex check.