Can all your troops be used on defence when being attacked or is the total amount limited to a research level?
There is no limit to wall defenders. All of your troops (that aren’t off somewhere else) will be defending your town. You can upgrade your garrison cap and your city defender cap through research. Garrison is just the troops that will never be killed or injured (default 5000). City defender allows more troops from clanmates to defend your base.