Rusty chain and back cassette – Replace or repair? Reference of the chain: KMC Z51
Reference back freewheel: Shimano TZ21 14-28 Teeth 7 Speed
Reference of the bike: BTWIN Rockrider 340



I recently acquired a second-hand bike and decided to repair it:
The chain and the freewheel cogs are in very poor condition and rusty as you can see in the pictures below:

 

The bike has not been used for a year by the former owner. As I don't have that much knowledge about it; 



I was wondering: Should I change the chain or repair it? as for the freewheel, can I even repair it?
If I have to repair them how can I achieve it?
As long as the crank arms, chain and freewheel turn freely and all as one. Without clunk's, slipping or sticking at any point there should be no need to replace any of it. The surface rust will not prevent it being fit for purpose and should wear off with use and some decent lubricant. You could always try a wire brush to remove surface rust without having to disassemble any parts and also just for reference if you do decide to change your "cassette" be advised that is a freewheel and not a cassette they are not interchangeable so avoid disappointment ordering a part that will not fit. The part you would need to order if you decide to is a 7speed freewheel not a 7speed cassette.