r/GoogleAppsScript • • Sep 09 '21

Question Approach when GAS project gets too big

Hi All,

Over the past 3 years, I have built an application using GAS for my small business. It started off as a few little scripts and has accidently grown to be an application with a mySQL database and about 30 or so web pages which perform various functionality. Essentially a client database with a whole bunch of data and the users can go and automate the creation of all sorts of Googler Docs - various reports and contracts etc. The users love using it and it is worth it's weight in gold in terms of time saving. I have cobbled together the scripts using the built in JS editor and use JQuery/Bootstrap etc . I have enjoyed using it but

  • I am about to embark on a doubling of the functionality (maybe even x3)

  • Some of other people I am friends with would like to start using it in their companies

  • I sometimes find it tricky to debug

So I am thinking GAS has reached it shelf life for this app and I want to migrate it to an Industry Standard dev stack and make it into a multi-tenanted application so other companies can use it also. Perhaps they will pay me some money if they like it.

Ideally I would like to keep the system in the Google Cloud for simplicity sake. I am not so worried about having to pay a bit extra to do this (as the MySQL currently costs me ~$20 per month). I would prefer to use a platform where I need to do the least possible to maintain it's upkeep and as much as possible it is looked after for me.

So my research points to using possibly Google App Engine. I would hook that up to my existing mySQL server but would need to rewrite the logic/backend/frontend code. If I need to pay someone to help me, then it would use fairly standard languages like Go or Java and I could use a nice clean UI framework. I would need to think about if other companies used it, would it hook into their google Docs/Drive or would I just store everything on mine and it gets shared with them.

Has anyone done anything like this before and how did it end up?

Do you think I am on the right track?

6 Upvotes

13 comments sorted by

4

u/DVC888 Sep 09 '21

Why don't you use NodeJS in Google App Engine? At least then it's all Javascript so you wouldn't have to rewrite as much.

You may be able to save yourself a lot of trouble by making your current functions API executable or switch them to run on doPost/doGet, meaning that you wouldn't necessarily have to port them to your hosted app at all.

2

u/johndavies112233 Sep 14 '21

Hi, Do you mean that my existing "backend" style code which access the database and creates the documents etc would stay as it is and I would simply call those functions from a NodeJS frontend which is on AppEngine? If so, are there any examples/instruction websites of how I would do this?

2

u/DVC888 Sep 14 '21

That's exactly what I mean. You may eventually want to move the functions to the new app but that could be a way to set things up in the meantime.

Look up the doPost and doGet functions in Google Apps Script. These will make it possible to receive http requests and trigger functions. At the moment, you are using google.script.run to call the functions but this would change to an API call.

NodeJS is server-side. Your current frontend would likely need very little updating other than swapping out the google.script.runs for API calls. The NodeJS server will be able to serve the same HTML files that you already have.

Any NodeJS tutorial should be OK to help you get most of this set up. The basic logic is going to be very similar to what you are already doing. The user presses a button on the front end and this calls a function on the backend, which then passes back a value. The only difference here is that the API calls will be more explicit and you will use fetch/axios/request or some other http library instead of google.script.run.

Try to set things up in such a way that you can move everything over to your new app eventually without breaking everything. Here is an example :

User submits a form to create a record in the frontend. The onclick method calls the function addRecord.

The addRecord function in the frontend includes an http request to the endpoint /addRecord in your node server.

When the request is received at /addRecord, another request is sent to your existing GAS project, which adds the record and then the results are returned back to the frontend.

When you have time, you can move the functionality from the addRecord method in your GAS project into the hander for /addRecord in node. The frontend wouldn't need to change at all at this point.

1

u/chiliphrosting Sep 10 '21

I agree. Imo the Google App Engine would probably be the easiest. One of the issues would be managing the quota usage to reduce the number of Api calls, becuz that could potentially jack up the cost to use them.

2

u/johndavies112233 Sep 14 '21

Thanks for the reply... how much $$ are we talking about? My app saves tens of thousands of dollars per year in staff time. At the moment I pay $20 per month... I would be happy to pay $100/month or more if need be

1

u/chiliphrosting Sep 14 '21

To tell you the truth, I am trying to understand it myself. Here is an article i found that may be helpful: https://www.techrepublic.com/article/how-to-calculate-the-cost-of-google-cloud-platform-services/.

And GAS limit: https://developers.google.com/apps-script/guides/services/quotas?hl=pt-br

Definitely great to know that GAS has cut costs for you and your team!

Hope the info helps!

2

u/ubiquae Sep 09 '21

If you rely a lot on the Libraries/Services available in google script, then the migration could be a bit harder, since you need to start from scratch using other libraries. Google Script offers a lot integrated services (calendar, drive, docs, and so on... even triggers) that are not present in other platforms without using third party libraries.

Other than that, yes, the natural approach would be google app engine.

Anyway, if you are not facing limits in google script, such as execution times or performance, consider the cost of opportunity (you plan to invest time starting from scratch. Instead you improve the existing solution).

1

u/johndavies112233 Sep 11 '21

Thanks for your input ubiquae. I have used the Drive service to make copies of template docs and move them, make new folders etc and with the Docs service I use that quite a lot to add tables and text to documents, headings, search and replace text in documents, Add images in documents. Would all that capability be available if we used App engine?

1

u/ubiquae Sep 11 '21

I think there is an SDK available, built on top of the Drive API.

https://developers.google.com/drive/api/v3/quickstart/python

1

u/johndavies112233 Oct 03 '21

Well, As fate would have it, On Sep 1 google introduced some "updates" to GAS which means that many of my pages are now broken. They modified the iFrame sandbox security. There is no way for me to fix it. So it has just given me a shove along to pick a different platform - one where I have more control and someone cannot just turn things off on me and leave me helpless.

1

u/ubiquae Oct 03 '21

Ouch, what a nightmare... Do you have any links with more information about those changes?

4

u/mttbil Sep 09 '21

I have cobbled together the scripts using the built in JS editor and use JQuery/Bootstrap etc

If you find you don’t want to do a full rewrite, you could keep the code in GAS but make the development a little easier / more standard. If you use clasp you can deploy code from a local copy to a specific script or scripts. You can use modern JS tooling like webpack and even typescript. And the biggest win IMO is that you can easily keep the code under source control.

https://github.com/google/clasp

1

u/Oneandaharv Sep 09 '21

I’d recommend taking a look at AppSheet- not necessarily the perfect solution but I reach a simile point with a system inbuilt and this provided an incredible front end solution that requires minimal upkeep