7

I have some GAE apps which I am thinking to separate into three modules: default(www), mobile and api but I am having some difficulties understanding Modules and how to organize the code.

According to the image found here this is how an app should look like. Google's Suggested GAE App structure

This is the simplifed structure I came up with so far:

gae-app/
├── modules
│   ├── api
│   │   ├── app.yaml
│   │   └── src
│   │       └── main.py
│   ├── mobile
│   │   ├── app.yaml
│   │   └── src
│   │       └── index.html
│   └── www
│       ├── app.yaml
│       └── src
│           ├── main.py
│           └── templates
├── cron.yaml
├── index.yaml
└── queue.yaml


  • The api module provides bunch of API functions and works fine on its own.

  • The mobile module is just a bunch of html+js which is working just fine with the api module via ajax.

  • The default(www) module will someday become just like the mobile module containing only html+js files and working with api module via ajax but for now most of the templates are generated server side via jinja2 which is causing some questions.


Questions:

  1. Since both api and default(www) modules are working server side with Datastore for now, where do I keep my Datastore models in this image/structure? In addition to that they both share some libraries, where do I keep them? Do I create a new "lib" folder in app's root folder and store the common/shared files there and then symlink it to each module? I am looking for some best practices.

  2. What's the best way to make all this work with separate git repos? I would want each of my modules to have its own repository. How would that work with shared models/libs from Q1? GAE apps with Modules seem to allow only one dispath.yaml / cron.yaml / index.yaml / queue.yaml / etc per app (not per module) so which repo would have those files?

I realize that there isn't a single correct answer to the questions but I am looking for best practices. Note that I just started working with Modules earlier today so my understanding how they work might be completely wrong.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Mihail Russu
  • 2,526
  • 1
  • 17
  • 27
  • 1
    This a very broad answer and the least you could do (if it's not going to be closed) is to skip the second question completely as it has nothing to do with your initial problem.. or GAE related problem.. – Lipis Oct 15 '14 at 18:26
  • @Lipis, none of this is likely a GAE problem, probably just my misunderstanding how Modules work. Second question is related to my initial issue as it's still about how the code should be organized. What do you suggest? Create a separate question for Q2? Ask elsewhere? – Mihail Russu Oct 15 '14 at 18:33
  • 1
    I think the [configuration](https://cloud.google.com/appengine/docs/python/modules/#Python_Configuration) is pretty clear and basically your architecture is right.. What you are asking I believe is on how to organise the code within the modules which is something very broad and really depends on the needs. As for the second question this might help you: http://stackoverflow.com/questions/1811730/how-do-i-work-with-a-git-repository-within-another-repository – Lipis Oct 15 '14 at 18:47

1 Answers1

2

About the first question: Yes, you can create a /lib folder, put it at the root of your folder structure, and reference all the common code from there. Both the www and api modules should be able to access (share) this code.

The second question was answered by @Lipis: check out this link: How do I work with a git repository within another repository?

Community
  • 1
  • 1
svpino
  • 1,864
  • 17
  • 18