The source hot is spliced to the red wire which is connected to the bottom terminals on the switch at the other end. The black wire is connected to the top terminal on the switch which runs power back to the fan where it is spliced to both the black and blue fan wires.
The hot source is spliced to the black, fan wire and the black wire running to the dimmer. At the other end, the black cable wire is spliced to one of the hot dimmer wires, it doesn’t matter which one. The other dimmer wire is spliced to the red wire in the switch box which is spliced to the blue, light wire at the other end.
This diagram illustrates wiring a GFCI receptacle and light switch in the same outlet box, a common arrangement in a bathroom with limited space. The hot source is spliced to the LINE terminal on the receptacle and to the bottom terminal on the light switch. The neutral and ground wires are spliced together and run to each device in the circuit.
In this diagram, a light switch and receptacle are wired in the same box. Both devices are spliced to the same hot source and the neutral to the neutral on the receptacle, and through to the light fixture located in a separate box.