This is the relevant mempool code https://github.com/mempool/mempool/blob/master/backend/src/api/common.ts#L523
The >=5 inputs and outputs heuristic might miss JoinMarket coinjoins, which I believe are intentionally designed to be harder to detect. Maybe a good starting point nonetheless.