I have mechanical disk brakes in my XC bike and in the process of replacing the brake pads, I completely opened the insides of the brake caliper. There were three ball bearings and a spring attached to the brake lever. Now I have no idea how to put them in position, I tried assembling once but there is no any braking action to the wheels. I think I assembled it wrong. Can anybody help me with this issue?
Here's a version of you picture with labels on the parts I'm probably not using the correct names but these will work for this purpose.
I'm assuming you know where each part generally fits but are having trouble getting the caliper to function correctly when assembled.
The caliper basically works by rotating the plunger. The ball bearings fit into the detents in the main body and plunger (marked by red circles). When the plunger rotates the balls ride up out of the detents on little ramps forcing the plunger to move through the body and press the pad against the rotor.
I think you probably went wrong in getting the ball bearings in the right place. When you put the balls in they should sit in the detents in the body, and the plunger should sit on the balls so that the balls are in the plunger detents. You should apply some grease to the moving parts and this will help stick the balls in place during reassembly. Be careful to keep grease away from where it could get on the pad though.
The spring serves to rotate the lever and retract the pads when there is no pull from the brake cable. There is a little spur of wire at each end of the spring that fits into a hole in the lever and main body (marked with red squares). Make sure the spurs are engaged in the holes. It's not clear which way around the spring goes from the picture but it should clear to you when you put it in place.
I'm not sure what 'part X' is. Perhaps a seal? Hopefully you remember how that fits.
Several ideas are below.
You can try to find the vendor of your brakes by net-searching for your bicycle name and model year and then looking after the parts list that comes with the bike.
To help you figure out how to assemble parts, you can look at another already assembled caliper. You have two identical calipers on your bike and you've touched only only of them, right?
If you have another caliper assembled, you can look at it as a reference of at least how externally visible parts should be connected.
You can find reassembly manuals for other vendors' calipers and use them as an inspiration material. That would not help you directly but it may simplify understanding of how things are supposed to work. After all, the operation principles of mechanical brakes are the same. For example, Avid BB5/BB7 disassembly/reassembly manuals are available on the net.
Lastly, I do not think these are all details that you show on the picture. It seems like two bolts holding the caliper body together are missing, and I cannot find the part that might be dedicated to a pad position adjustment.