Middleware layer for application