I ran this exact scenario -- the Caves of Chaos attacking the Keep on the Borderlands -- and it was the most fun we ever had.
For preparation, here's what I did.
1) Drew my own map of the Keep. In particular, I plotted the interior of the Keep's dunjeon (main tower), and decided on escape tunnels.
2) Stat'd out every resident of the Keep. Since it was AD&D rules, this was pretty simple. With a population of 50 or so, it's doable (but harder) even in 3.5. At the very least, determine Class, Level, HP, and basic combat equipment for all combatants and potential combatants, and make detailed stats for leaders. Also, I stat'd a few people with unusual stats -- a 1st level paladin and a 1st level mage, who were teenagers whose abilities were not yet know to the Keep's rulers.
3) Determine what defensive supplies the Keep has. In particular, healing potions and Greek fire proved pivotal. Where extra arrows, shields, etc. are is also important.
4) Decide where the militia members and PC's are at the beginning of the fight. I had the assault start in the middle of the night, so the PC's were mostly asleep.
5) Divide up the attacking forces and give them various assignments.
After that, I just ran the whole thing as a huge combat. Every single round (something like 240 rounds) happened in simultaneous real time for everybody -- let the PC's run the good guy NPCs. It took a LONG time, but it was extremely fun.
I'm not sure if it's doable in 3e, but I suspect it is and would be fun.
In the end, the PC's and the survivors of the militia were in the Great Hall of the Keep's dunjeon, fighting off attacks on two different doors, using Greek fire over the tops of overturned tables. The won, just barely, with about a third of the militia killed.
For inspiration on castle battles, you might try Medieval II Total War. For inspiration on actual castles, read up on some of the great ones like Caernarfon, Edinburgh Castle, Krak de Chevaliers, and the Tower of London. Those are all much more impressive than the Keep should be, but they'll give you ideas about defenses like murder holes and cliffsides and so forth.