The 877 is not really big enough to do what you want but can do it. I think you need a hardware solution. I'd go with the QR reader using a software UART on D6 & D7. To store your codes, use an I²C memory (24C1024 is 131k) on RC3 (SDA) and RC4 (SCL) - move your LEDs to port A. An alternative method is to have the QR code contain a 64 bit number along with other stuff, check the other stuff is correct and then check the 64 bit number against your database - only 8 locations per record required.
Mike.