6

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.

5
  • Even if you use Angular with Node, you have to use Express AFAIK because it is built into Node as the web framework to expose the API endpoints. It is like Angular can do a lot of routing, but then things really get handed over to Express to handle the backend to Node. Also you will most likely want to follow a good Angular scalable pattern as opposed to worrying about Node and Express scalability Commented Aug 22, 2015 at 4:40
  • that's why i'm using John Papas guide, Express routing doesn't have anything to do with Angular routing? @TomStickel Commented Aug 22, 2015 at 5:03
  • @feniixx, it would be cool if you could provide an update of this question with what folder structure you decided to go with? I see your angular organization and it makes sense. But what about the node/express side? how did you organized your code there? Commented Mar 24, 2016 at 13:50
  • @codePlusPlus hey there, long time since this post has an update, I'll answer it tomorrow maybe, but to be short, I only used express for a restful service, since app logic was on angular side, also my app structure currently is pretty diff from this, but it depends always on the size of the project Commented Mar 25, 2016 at 6:47
  • @feniixx considering that angular is doing your real app routing on client side, when we discuss express routing what we're really referring to is determining API endpoints, right? Commented Jun 7, 2016 at 17:31

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

hmmm, not sure if that repo describes the structure of a mean app, but what i want to know is what are the express files and folders needed when working with angular...
It describe an express/node ("E" and "N") app structure that makes sense regardless of what database ("M") or front end framework ("A") you are using. You have your client-side routes under app/client/users/users.routes.js. Put the express user API routes in app/server/users/users.api.js and follow that pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.