Yes, a sunroom can be built on a deck or patio. You will want to make sure you get a building permit and follow the local rules regarding the construction, but this is a viable option as long as the deck can support the additional weight from the sunroom.
We’d recommend this for decks on concrete slab foundation. I’m not sure an elevated wood frame deck would be suitable, but this is going to depend on many factors beyond an overarching general guide.
If you are considering this, we highly suggest hiring a licensed contractor or construction professional in your area who can help you determine exactly what you’ll need to add a sunroom to your deck.