I'm developing a complex environment which involves a web application, a mobile app and a real time middleware system which accesses the DB for on-site tag readings. Currently, the web application exposes some services over a REST API, which are accessed by the mobile app to let it perform its business work (in this case, time delay is not critical). However, for my middleware system, I access the DB directly (through a ORM), in order to provide faster responses.
Am I doing it right or should I take advantage from the REST API to access the information to be processed in the middleware system too? Actually, this system, the web application and the DB belong to the same physical server.
Any recommendation about that will be welcomed!