Search code examples
node.jsangularjsgrailsarchitecturegrails-orm

Grails as single app or different back-end and front end app


We are new to grails and are concerned about the following issues:

  1. scalability concerns

  2. Using same back-end for different applications

So sticking to a single grails is good idea or we should separate concerns and even use other framework like node.js for frontend using rest.

Secondly i am not very clear ,where we should put business logic in grail app.Ideal place should be services i suppose

We are examining Angular.js since it seems to faster than gsp pages,current flavour for frontend and integration with grail is also easier.Wanted to check is this correct option or not.


Solution

  • Grails is very well suited fast paced development needs and you will love it when you get basic understanding of it. You can write a badly performing application in any framework/language. One thing I'd recommend is getting a good understanding of Hibernate which is the underlying persistence library. If you understand how that works, it should help you avoid making any silly mistakes at the DB level.

    For the first part of your question the scalability of your web application won't really depend on what language/framework you choose to use, but rather how your application is built. You can build a scalable web application in Grails, just as you can build an incredibly slow application in C++. If Grails is the framework you would like to use, then use it; you can always rewrite the slow parts in Java or another fast language, if need be. (After all, that's what Twitter did with Scala.)

    In our company what we do is use grails as a client interaction/licensing server and use multiple Node.js servers for analytics. So all what client gives gets stored on grails server and then the functional data is sent to Node.js server cluster for further processing. The analytics data from Node.js server is fetched by grails server using http builder and is used to plot charts and data on dashboard.

    //------------- Updating answer for updated question ----------------------

    • Node.js is server side technology and it doesn't work on front-end i.e. client side
    • In grails you write all incoming(to server) and outgoing(from server) things in controller.
    • While all your business logic/computations/DB queries goes into your service methods. Once done send computed data back to controller via return statement and controller will send/show it on GSP.
    • While regarding your angular JS question I would say you cant replace GSP with angular JS as GSP is nothing but a server side scripting in which you write grails/groovy/java code in script-lets form along with normal HTML code and it gets rendered into full HTML and gets sent onto client side. So you can only enhance its functionality by adding a front end MVC like Angular to it and can't replace it. And functionality wise Angular is superb framework. Add any kind of JS to your GSP's and enjoy them.

    P.S. - You'll start loving GSP once you get hang of GSP tags which are so easy to do many things.