A delegates at the party's national convention
Each state has either a primary election or a caucus. Various rules apply, but in general the majority winner either takes all primary votes or there is proportional allocation to which the delegates then pledge to follow. There is a chance the delegates that are pledged to vote a certain way can still vote against the popular vote. However, this is very rare and does occur at a rate that will affect the final outcome.