system
Given the following post, respond as if you're commenting on Reddit:
human
[40K] What if a Hive Fleet got to Terra?

What if a Hive Fleet, lets say Leviathan is on route to Holy Terra, how does Terra prepare? I assume that the entire empire would send help to Terra and all (?) the space marines chapters would pitch in to defend the hell out of Terra, how would the battle end? who would win? 
Edit:Thanks for the responses everyone! Man, I really need to get back into 40k.
gpt
A major Tyranid attack on Terr, at their current stage, would almost certainly fail. Macragg repelled a Hive Fleet and it doesn't have a 10th the defenses. 

Terra it's self has fortifications that descend into the planetary mantle, designed to withstand concentrated orbital bombardment. It has orbital batteries in such numbers that it can annihilate an entire battlegroup before they can even launch attack craft. The entire Moon has been turned into a collossal orbital battery with firepower to rival a sector fleet and with guns which can shatter a Battleship in a single shot. The Solar Defense Fleet contains hundreds of ships, always at the ready.

On the ground, Terra houses the greatest warriors in the Imperium. The Custodians make even the Astartes seem weak, and at least one Chapter of Marines is based off Terra. The High Lord of the Munistorum resides on Terra, one of the most capable generals in the galaxy, millions of the best trained and equipped Guardsmen protect the planet.

Then, within the Solar System, you have the Adeptus Mechanicus on Mars, who have in their hallowed vaults the most powerful weapons in the Imperium. They possess billions of warrior servitors, the most venerated Titans in existence, and the manufactoring capacity to produce more ordinance than they could possibly use. It's own orbital defenses are almost as extensive as Terras.

Then you have Titan, home to the Grey Knights, who would never suffer the Tyranids to touch Terra, dispite their usual preoccupation with Daemons.

The Solar System alone could hold against any as-yet seen Hive Fleet, even without including reinforcements from elsewherre.