It has been quite a while since I left programming. But ever since, I have always had an inclination towards the programming thing and time and again keep on exploring new platforms and technologies.
In my quest to start some programming back, I wanted to go with the something which had mainly three features: cross-platform, real-time and easy learning curve. After going through several new platforms, I found Meteor to be something which was comparatively bit easy to start with and at the same time had a lot of features and new platforms running up. The best part I liked about Meteor was a single place to write client-side and server-side code.
Though Meteor makes it pretty easy to do full-stack development, writing code without proper directory structure can become messy and dirty in the wrong run. As a result, I planned to write an article on Meteor directory structure, in an easy and simple form for beginners like me.
client
This is the directory which Meteor uses to pull any code that needs to be run on client-side. Keep in mind that any code put here is accessible to clients when they use the application.
server
Similar to the client directory, server is the default reference directory for Meteor to search for code that needs to be run only on the server side.
import
As client folder by default loads all files on client-side, it might not be a good option to throw all client code there. It is always better to load only the piece that is actually needed. import older serves that purpose. Any files don’t go either on server or client side and are kept for loading in other files, as and when required.
public
This is the folder accessible publicly by other files to access. As this is public, items within this folder can be easily accessed by either direct file name (in case it is on the root of this directory) or using the relative path from the directory in which it is located in this public folder.
This folder can be best used to keep client side assets like: CSS files, images, fonts etc.
private
As the name implies, code kept here has very restricted access. Files within private folder can only be accessed by server side code by using Assets API.
lib
It is always better to keep libraries in a single directory.The lib directory serves this purpose and this is something which Meteor very well takes care of. Before the client/server code starts, files in this directory get loaded.
node_modules
This directory is not loaded directly by Meteor. This is a directory to keep node.js packages that might be required in your project and then load them via import statement when required.
tests
This directory helps in keeping the files that needs to be used for testing the code written. Meteor has certain built-in test tools that can help one run multiple test scenarios.
thank you for your meteor directory structure post