Some simple fireworks, like sparklers, are safe enough to make at home. They are basically gunpowder recipes with added iron or aluminum to make the sparks, and some sugar or starch in water to make a paste that sticks on the wire.
Firecrackers are gunpowder packed into cardboard tubes that act as the closed container needed to make noise. A fuse is often just gunpowder wrapped in tissue paper. The fuse burns slowly enough to let you get away from the firecracker before the gunpowder in the cardboard tube ignites and explodes.
Rockets are also often simple cardboard tubes filled with gunpowder, but with one end capped with a clay nozzle instead of being completely closed. When lit, the powder burns instead of exploding, and the hot gas comes out the nozzle. The force that creates pushes the rocket away.
Mortars are small cannons made of cardboard tubes. A complex explosive device called a shell is lit and dropped into the tube. The bottom of the shell is a firecracker that explodes. This pushes the rest of the shell out of the tube into the air, where it can explode high above the spectators. It often has little bits of gunpowder called stars. These create the flower shapes as they burn brightly in the air after the shell explodes. The stars can have additives that make them burn brighter, or burn in different colors.