Could i build a router and server out of the same PC?

would put a long-arse story here but I'm on my phone.

Forgot to mention I would like to use Pfsense

It's best to mitigate the router and server apart. This will help with any diagnostics in the future and it keeps the operation into a single unit. A router could have workloads as much as a "server" that you're mentioning. But what's the server going to be?