Structuring a Node.js and AngularJS application

Things are getting easier as time goes on. I’ve used Yeoman for the AngularJS front-end, and it makes life much easier: http://yeoman.io/

Option 1, MEAN.io

MEAN is an awesome acronym! I prefer the MEAN stack directory structure. Let’s use convention people! Just use the directory structure from mean.io. MEAN is handy too because it throws in all the goodies like Grunt, Bower, etc.

Enter image description here

Option 2, Angular-seed + Express.js

I’ve searched GitHub for Node.js/AngularJS projects (probably not hard enough) and not seen anything really great for a starting directory structure. So I’ve merged the Node.js Express.js (running Express.js from the command line using neither EJS nor Jade/Pug) skeleton with the angular-seed project (clone it from GitHub). Then I moved a ton of stuff around. Here’s what I came up with:


  • developer – stuff only the developer(s) will use. Does not need to be deployed.
    • config – karma configuration files and others.
    • scripts – developer scripts (build, test, and deploy)
    • test – e2e and unit tests.
  • logs
  • node_modules – this Stack Overflow answer recommended to put this in Git. However this may now be obsolete.
  • public – This comes almost straight from the angular-seed app folder.
    • css, img, js, lib, partials – pretty obvious and nice and short.
  • routes – Node.js routes.
  • server – server-side “shebang” Node.js programs, daemons, cron programs, whatever.
  • server.js – renamed from app.js just to make it more obvious this is server side.

Enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)