# Architecture-related question (Multi-Layer App)



## Scholle (10. Jun 2009)

Hi All,

I have a question regarding architectural related issues.

I am planning an application that will have a considerable amount of business logic. There will also be different ways for different target groups to access this logic, e.g. web application1 and mobile application1 for target group1 and web application2 and mobile application2 for target group2. I think its reasonable to split the overall functionality into diffferent lighter-weighted apps rather than implementing one heavy-weighted app because the functionality to be implemented in each app is quite different. To sum up, there are several smaller applications in the presentation layer and a big application in the backend layer. Of course, apps will be added from time to time. At the beginning, there will be only the app in the backend and web application1 for target group1.

I was thinking about what technologies to be used. There is a strong experience in Java. However, basic knowledge in Groovy, Ruby, PHP has been gained in smaller projects.

Thus, I was thinking about the following design alternatives:

1.) Using Spring-based app in the backend app and Grails/Rails for the web app. Grails/Rails will interact with the backend based on RESTful Webservices - a service-oriented architecture so to say. In this case, there will be now dedicated  database for the web-app. All data would be requested from the backend using services. Choosing such an architecture allows for independent scalability which is quite important because the app in the backend will get more demanding the more apps in presentation layer will be added or the more user will consume the application. 

2.)  Using Grails app and putting the backend functionality (as spring beans) into the grails framework. I personally think this is the worst alternative because the business logic supposed to be used by different apps could not be deployed independently from the grails app. Furthermore, all the other web apps would have to access the grails app. 

3.) I have heard about OSGI but I am quite unsure whether and how it might be applied to the scenario mentioned above.

I actually prefer alternative 1 because it fosters loose coupling between the different apps (that will be added from time to time), allows for scalability and re-use of the functionality of the backend provided as services. I prefer an architecture using Spring for the backend and Grails for web apps. Using RESTful services for communicating between bot backend and presentation is only one solution. I am not quite sure about performance related issues because there will be quite a lot communication between the web-apps and the backend.

Give anyone give some feedback regarding the alternatives proposed? Does anyone see an alternative regarding how to realize communication between independent grails and spring apps?

Thanks, 
Scholle


----------



## Noctarius (10. Jun 2009)

I would expect a 4th situation which is indeed a mixture of scenario 1 and 3.

Running a Spring based backend on base of OSGi but making different OSGi bundles for splittable business logic to be in the position to make partiell updates of the backend.
For the Frontend you can use a simple Tomcat with some Groovy/Rails or whatever framework code which interacts to the backend over REST or JMS for example.


----------



## Scholle (10. Jun 2009)

Hallo Noctarius,

danke für dein Feedback....

Bezüglich OSGI, man kann ja Spring Beans als OSGI Services publishen. Diese werden in der OSGI Registry registriert. Dann wäre es ja prinzipiell auch möglich, aus dem Grails Framework auf dieses Services zu zugreifen? Mein Gefühl sagt mir, dass diese Art der Kommunikation für meinen Zweck geeigneter sein könnte. Macht so etwas überhaupt Sinn?

Nehmen wir mal an, es wird Spring MVC für die Web Schicht eingesetzt. Damit bleiben wir in der Spring-Familie. Dann würden wir die Kommunikation mit der Business Logic, die ebenfalls vom Spring Framework unterstützt wird, doch nicht mit Services realisieren? 

Wie macht man das denn normalerweise, wenn es verschiedenen Applikation in der Präsentationsschicht gibt, die auf ein gemeinsames Backend zugreifen?

Scholle


----------

