Separate middleware component into services(Business Logic) and persistence (Hibernate DAO objects)

Hello Everyone,

We have a requirement to separate business logic and database objects into separate servers.
We are currently using GUI and REST API modules that are interacting with core module.
For scaling and security reasons we need to separate the database objects into a separate server.
Please help us in how this can be achieved.

Thank you.

Hi, could you elaborate on it, please?

Do you want to deploy GUI and REST to a separate server or do you want to split the core module, extract and run business logic as a separate application?

The first case is simple, just follow the documentation: Application Scaling - CUBA Platform. Developer’s Manual

If you want to split the core module, you’ll probably need to create an additional CUBA application that will execute business logic and fetch data from the database via an additional REST API.

Thanks Andrey for the reply. I was looking for second case where I want to split core module as below.

How will the authentication, data populating will be handled in GUI and REST API. Could you please elaborate more on your second approach.

Hi,

Thanks for the diagram, now it is clear.

Implementing this approach with CUBA will be a long process. We heavily rely on the core module in GUI in the CUBA’s architecture.

For your case, it looks like you can implement a separate CUBA application for data access with REST API, and then you will be able to consume it similar to this example.

As for the security, you may need to set it up separately for your data access application, e.g. use CUBA’s OAuth2 and your business logic application will authorize users against the data access application before the communication starts.

In conclusion: this approach is possible, but not easy to implement with CUBA because it contradicts the framework architecture.

Thanks Andrey for the reply. I will work on it and get back to your for any further questions.
Appreciate your support.

1 Like

@belyaev – You have suggested to have a separate CUBA application for data access. When I create the first CUBA application how can I create it without database. The first CUBA application needs to get users, access control, entities everything from the data access application.

Could you please help me in creating CUBA application without database and data for the first application will be retrieved from second CUBA application using REST API

I told you it is not going to be easy. You’ll need to replace base CUBA services with your own ones to pass all requests for the business logic layer to the DB access layer.

Right now I’m not sure I have enough time for this exercise since it contradicts the CUBA Architecture. But I think you can create the Business Logic API layer with Spring Boot, expose proper REST API and implement a GUI application with CUBA that will consume this REST API.

I think it will be simpler than trying to remove DB from the CUBA Application

Thanks Andrey for the reply.
As for as our requirement GUI application server should not interact with RDS only the data layer system should interact with RDS.

Could you please tell me what are the base CUBA services that need to be replaced to create a CUBA application without a database.

Thank you so much for the support

I advise you not to go on this path :slight_smile: You’ll have to override more than half of the framework, it would be much faster and cheaper to implement business services with Spring or Spring Boot. I’d suggest this architecture for your application. Hope it becomes a bit more clear.