Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folder structure for a Express.js and Angular.js project

I'm starting a new project under M*EAN Stack (MySQL) and was wondering about how to structure it, i'll use John Papa's Style Guide for an Angular project, it's pretty cool though, specially for the LIFT principle.

What is making a bit of trouble is Express, it has it's own MVC structure, it can handle routes, models, views, etc... but i want to handle that with Angular, i want Express just as a RESTful API.

A folder structure that i've been thinking to use is:

├── node_modules
├── app
│   ├── client
│   │   ├── app.module.js
│   │   ├── app.config.js
│   │   ├── users
|   │   │   ├── users.module.js
|   │   │   ├── users.config.js
|   |   |   ├── admins.view.html
|   |   |   ├── admins.controller.js
|   |   |   ├── registered.view.html
|   |   |   ├── registered.controller.js
|   |   |   ├── guests.view.html
|   |   |   ├── guests.controller.js
|   |   |   ├── profile.directive.html
|   |   |   ├── profile.controller.js
|   |   │   └── users.routes.js
│   │   ├── questions
|   │   │   ├── questions.module.js
|   │   │   ├── questions.config.js
|   |   |   ├── list.view.html
|   |   |   ├── list.controller.js
|   |   |   ├── ask.view.html
|   |   |   ├── ask.controller.js
|   |   |   ├── detail.view.html
|   |   |   ├── detail.controller.js
|   |   │   └── questions.routes.js
│   │   └── 
│   ├── server
│   |   └── ?
│   └── libs
|       ├── angular
|       ├── bootstrap
│       └── jquery
|
|
└── server.js

But actually i'm pretty sure if work with it like that, i really need a scalable structure, the application is pretty laaarge!. Some of my questions are:

  • What if i want to split Node(Express) server configuration to be able to scale? What would be an appropriate folder structure for that?
  • What does client and server folders mean in an app (i took them from some structures i saw for Express)?
  • If i use Angular, what is Express made for?

NOTE: I haven't include folders and files for bower, gulp, grunt, or things like that, i want to keep it as clean as possible, i know they simplify a lot of things, but i don't want to use them now, of course, if someone has a great argument to use them, please tell me.

like image 317
Jonathan Solorzano Avatar asked Aug 22 '15 03:08

Jonathan Solorzano


1 Answers

I structure my express apps as described in Express Code Structure. I think the grouping you have under app/client looks good and you could just mirror that for the express server side portions of your app.

like image 58
Peter Lyons Avatar answered Nov 14 '22 23:11

Peter Lyons