Skip to content

Instantly share code, notes, and snippets.

@dirodrigues
Last active September 7, 2016 15:59
Show Gist options
  • Save dirodrigues/3fcc1202fcf38f4a2f1476d3662d0636 to your computer and use it in GitHub Desktop.
Save dirodrigues/3fcc1202fcf38f4a2f1476d3662d0636 to your computer and use it in GitHub Desktop.

TitanApi Structure

Proposed Structure

  • api
    • config
    • lib
    • priv
    • web
      • routes
        • surnames
          • controllers
          • views
          • adapters
        • tree
          • controllers
          • views
          • adapters
        • members
          • controllers
          • views
          • adapters
        • fmp
          • controllers
          • views
          • adapters
        • layout
          • templates
          • views
      • shared
        • parsers
          • json
      • plugs
      • channels

Explaining the proposed structure

/lib

This folder should be used for static shared code that doesn't change often, mostly because phoenix hot reloader excludes /lib precisely so you can have a folder to put long-lived code.

  • /lib structure
    • we are getting rid of /src and what is in /domain will be moved to /web/shared.
    • /environment will be moved to /web/shared but ideally we want to remove it all together
    • pre-library will be removed, and what is inside it will just go up one level (i.e. /lib)

/test

We'd have the test files next to the actual files we are testing so that there is less navigation.

/web

This is where the most change is suggested.

  • We would like to have all code for a specific "domain" to be in it's own folder, we have called that /routes. That way, whenever we have to change something related to surnames all we need to do is open /surnames folder.
    Each route should then subsequently have the following structure:

    • /controllers
      • controllers get data from adapters, pass it on to views which template and return.
    • /views
      • these will be mainly json views which will take in data and template it.
    • /adapters
      • adapters will gather the data and return it.

    This would make sure we all follow the same pattern.

  • We then would have /shared where we would have "helpers" like json parsers.

To be removed from /web

  • /queries
  • /service_wrappers
  • /templates
  • /adapters
@jbachhardie
Copy link

On /lib: it's not really usher run hot that's the issue, it's the phoenix hot reloader which excludes /lib precisely so you can have a folder to put long-lived code. Also, I thought we'd agreed to get rid of the pre-library folder and move those contents into either /lib or /web/shared depending on their nature.
On /test: we don't need to compromise anymore! 🎉
On /web: might want to add definitions of what we think should be in each folder. i.e. controllers get data from adapters, pass it on to views which template and return.

@jbachhardie
Copy link

Also we'd talked about the /shared structure for say the JSON library to be a bit more like /web/shared/parsers/json.ex rather than a folder for each helper module. At least that's how I understood it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment