4

I see that there is already an answer to this question but I feel its outdated. Many things have changes since then. There are now modules, cloud_endpoints and webapp2. What should be the good directory structure for my project which allows me to add/modify features easily.

For example I should be able to manage:

  1. Modules.
  2. Cron jobs.
  3. Task queues.
  4. Cloud endpoints.
Community
  • 1
  • 1
vivek
  • 2,807
  • 5
  • 31
  • 44
  • 1
    I'd also add third party libraries that are potentially used by more than one module and testing code. – new name Feb 24 '16 at 17:56

2 Answers2

3

I'd first take a look at modules, at least for these reasons:

  • modules really are in many respects (almost) equivalents to entire (single-module) apps in older docs/references, so once a module's position in the app's hierarchy is clarified various posts referencing an app-context can usually be extrapolated to just a module-only context.
  • nowadays an app can use different languages/sandboxes for different modules (see Run both Java and PHP on google app engine project) or even for different versions of the same module (see Google App Engine upgrading part by part)

Personally I'd stick with the recommended multi-module app structure - each module having its own directory, one level below the app's directory:

enter image description here

The app's top dir would hold the per-app configs (which aren't applicable to a particular module): dispatch.yaml, cron.yaml, index.yaml, and queue.yaml. Note that the cron jobs and task queues definitions belong here (but nothing stops you from routing/dispatching various cron jobs to various modules based on the requested paths).

I'd also place in the app's top level dir any files/directories I'd like to share across multiple modules in the DRY way. These files/dirs would be shared by a module by symlinking them inside the respective modules so that the module gets its own copy at deployment. Almost anything that can exist as a separate file or directory can be shared this way:

Finally the recommended files/dir structure of a particular module may further depend on the module language/sandbox, the framework(s) used, the developer's style/preferences, etc. I don't think it's possible to provide a one-size-fits-all recommendation which would be effective/acceptable in all cases.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • I haven't yet used Endpoints, so take this with a grain of salt - based on a brief scan of the docs. Because Endpoints include client-side code which doesn't run on GAE they shouldn't be under a module dir (otherwise that code would, by default, be deployed on GAE). I'd say either side-by-side with the modules' dirs or, even cleaner (especially if the app includes multiple endpoints), under some "Endpoints" (?) dir placed side-by-side with the modules' dirs. From there symlink inside the applicable modules' dirs whatever Endpoint files/dirs need to be deployed for backend operation (if any). – Dan Cornilescu Mar 02 '16 at 17:05
0

Endpoints are just RPC (strongly typed) versions of basic REST url's with the added advantage that they can be used to Generated client side libraries. So the endpoint config and definitions belong in the SAME directory as the module (ie mobile-backend) as their REST counterpart would. In other words, if you have (or would have) a REST endpoint in Module1 for "user login", then you should put the "user login" Endpoint in the module1 directory. Further, if you don't like the symlink approach, you can move your module1.yaml file UP one level and then that whole module can import from a "common" directory.

Dewey
  • 756
  • 6
  • 17