Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Richard Nash
Richard Nash
24,862 Points

Modular JSON in MVCs?

Hi everybody :-)

I'm considering using Angular, Ember, Backbone, etc. for data binding for a blog based web app that I am building and I want to be able to use my JSON data efficiently and intelligently.

So I want to know if these frameworks support this data model idea that I have, or even if it is a good idea to begin with. So here goes:

I want to have every piece of data represented only once in my web app, so that each blog entry would only be written once and the data of each blog entry would be referenced as many times as needed throughout the web app, which is what MVC frameworks are basically for.

The thing is, I don't want to have one absolutely enormous JSON file which contains every single blog post that I write. I would much rather have a dedicated JSON file for each blog post, and then have all blog post JSON files feed into a master JSON manifest file that would act as a router of information across the web app.

My question is two-fold: are MVCs like Angular, Ember, Backbone, etc. capable of doing this? And is this data model the best idea, or are there a better ways of handling this use case?

I assume that this has come up before, but I simply do not know where to find out more about this use case. Also, keep in mind that I am currently learning how to use Angular, Ember, Backbone, etc. right now so my knowledge is limited at this point. So if this is a basic question that I will eventually run into in my learnings, then I apologize in advance.

Anyway, any advice that the treehouse community can share will be greatly appreciated.

Thank you :-)

4 Answers

To answer your question, front end MVC library/frameworks like Angular, Ember, and Backbone cannot create files on your server alone. You need to use a server-side language like PHP to create a new file (which is not hard)

My suggestion though, is to use a database instead of storing JSON files on your server. With your server-side scripting language you can query your database and return a JSON file to you MVC to create the blog post.

You might want to do a chunk of research into creating a blogging app to get better ideas, or search for others that have already been made using the MVC you prefer and looking into how and what they do to store their data.

Richard Nash
Richard Nash
24,862 Points

And the MEAN Stack is basically the same idea then? As you said, these things are covered, but across many different courses. The course I'm thinking about would walk through each stage of the process and compare and contrast all of the options as unbiasedly as possible.

  1. Badge 1 would be the client side (HTML, CSS, Javascript)
  2. Badge 2 would dev tools (CLI, Text Editors[Sublime, Brackets, Atom], Task Runners[Grunt, Gulp], Package Mangers [NPM, Bower], Generators[Yeoman], etc... and how they all work together as a team.
  3. Badge 3 could be layout frameworks (Bootstrap, Foundation, Ionic, Polymer, etc...)
  4. Badge 4 could be Data Frameworks (Angular, Ember, Backbone, etc...)
  5. Badge 5 could be Server-side Languages (PHP, Python, Ruby, Javascript, etc...)
  6. Badge 6 could be Server-side frameworks (Django, Ruby on Rails, Node.js. etc...)
  7. Badge 7 could be database languages (SQL, myQSL, noSQL, etc...)

The whole point would be to give people a high level overview of how everything fits together and how data flows, where it starts and ends, where it's stored, etc, etc, etc... It's rather tough piecing all of this together for a beginner (which is me) and making sense of it all. I know I would appreciate this a bunch, and I have a feeling that other people would as well.

Anyway, that's my two cents :-)

Merry Christmas!!! XD

Richard Nash
Richard Nash
24,862 Points

OK, so correct me if I'm wrong anywhere here:

The database (SQL, mySQL, noSQL, Firebase, etc...) on the server is accessed via the server-side programming (PHP, Ruby, Python, Node.js, etc...) which is queried by the client-side programming (HTML, CSS, Javascript, Angular, Ember, Backbone, and every other thing that people use to make websites on the front end) and the data from the database is converted into JSON by the server-side programming which is then sent to the client-side programming as JSON which is then parsed and turned into HTML and rendered on the page of the client-side users device(s) by the HTML, CSS, Javascript, MVC frameworks, etc... and the user(s) see the data on their device?

It would be nice if Treehouse created a course that walked through everything that it takes to make a web app from soup to nuts (A to Z) and named what every tool is and where it fits in the process. I'm gaining a slow understanding through piecing together my own research, but this would be great, indeed.

It sounds like you have a decent overview understanding of how many of these pieces fit together.

While Treehouse does not have a single course that covers all these layers, they do teach most of the content your asking about, although it is spread across many of their courses. The PHP development track covers most of what you need to develop a full project using the LAMP stack. If you combine that with what you learn about an MVC JS framework, I think you will be in a good place. You probably have a lot of the tutorials from that track completed already too.

Alternatively, Treehouse has a Ruby on Rails track that will cover similar things as the PHP track, but using the Rails stack.

I hope this helps give you some more direction! :D