So the relay agent appears to have an internal IP that is part of the subnet. The relay agent is also on the router. I think it can also be on the switch, which would support my theory that the DHCP agent is strictly behind the gateway.
The DHCP relay agent receives DHCP Discover and Request messages broadcasted by the PC, and unicasts them directly to the DHCP server.
Lots of sources like this (cf. https://www.netmanias.com/en/post/techdocs/6000/dhcp-network-protocol/understanding-dhcp-relay-agents) talk about the relay agent as if it is in front of the gateway, or is used instead of the gateway.
As far as I understand it, the relay agent detects packets with 0.0.0.0 source IPs, replaces them with the source IP of the relay agent and destination IP with the DHCP server and then passes it to the egress queue on the gateway. Because the gateway and the host should be on the same subnet (unlike in figure 2), the gateway can keep the source IP of the relay agent unchanged and add its MAC address. When the DHCP sever sends back the offer to the relay IP it should be picked up by the gateway as it is on the same subnet. I have no idea why figure 2 shows a changing of the source IP to that of the gateway's when it is not needed as all gateways in the stub domain use RFC 1918 addresses and there is hence no NAT.
Can anyone confirm this, in case I have any misperceptions?