Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize GAE Modules app structure and code?

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.

like image 468
Mihail Russu Avatar asked Oct 15 '14 18:10

Mihail Russu


1 Answers

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?

like image 143
svpino Avatar answered Oct 15 '22 01:10

svpino