Bottom line - this should be a make/buy choice, with only one real option. It's ugly, messy, ultimately user-facing, and been solved over and over and over. Please, please don't do it once again from first principles. You're going to need to buy hardware anyway, and they all come with software.
At least I hope you're not going to reinvent the hardware ...