Constructing scalable smart contract

Earlier in my question “questions about smart contract application”, I was told the maximum number of applications opted-in to one smart contract is 10.

I think I need a solution to construct the contract able to opt-in around 1k -10k users.
Does anyone have ideas or any existed code/repo for my reference?

Luckily, the pyteal docs provided some simple examples about stateful applications. Does examples provided in the the doc website able to hold that number of opted-in users?

“Application” and a “stateful smart contract” are essentially synonym on Algorand.

There is no limit on the number of accounts that can opt-in to a given application.
All the accounts on the blockchain can opt-in to the same application.

There are however two limits:

  • a given account can opt-in to at most 10 applications
  • a given account can create at most 10 applications

Regarding examples of applications, you can look at for example: