For the most part, airsoft guns are very similar in their function, there is a gearbox inside the base of the gun that compresses air and releases it firing the bb forward.
There are 4 separate gears that travel from the motor to the piston which allows air to flow through the nozzle propelling the bb forward. The motor head has a small pinion gear that interacts with the bevel gear which interacts with the spur gear which interacts with the sector gear that pulls the piston back and springs forward which compresses air and releases that through the air nozzle at the top right of the gearbox.
The air is compressed by a piston with a rubber seal being pulled back by the sector gear then shot forward by the spring. By replacing the spring you can increase or decrease the fps (feet per second) of the bbs. The stronger the spring is the faster the bb will travel.