2

There is already similar question at Folder structure for a Node.js project but answer to that post seems to be purely for nodejs, does not consider the angularjs.

Folder Structure

I dont need view folder mentioned in above post as I will be using view inside app folder for angularjs.

Can anyone please help me with better folder structure...like where to put route logic, where to business logic. folder should be segregated by functionality or feature...etc?

1 Answer 1

9

If you are building application using both Node JS and Angular JS, then your folder structure should be like below.

  • /App - Folder that Contains your angular js applications

    • /AppName - Folder containing files related to specific application.

      • /contorllers - Folder containing controllers related to specific app.

        • abcController.js - JS file containing logic for abcController.
      • /directives - Folder containing directives related to specific app.
      • /animations - Folder containing animations related to specific app
        . . .
      • /services - Folder containing services related to specific app.

      • app.js - JS file containing your routes handled by this app, application initialization and configs.

      • /views - Folder containing html view files.

    • /commonDirectives - Folder containing common directives.

      • OverlayDirective.js - JS containing logic for overlay directive.
    • /commonViews - Folder containing common html view files.

    • coreApp.js - JS file containing your core app initialization, configurations and routes that are common for all apps (for example dashboard, aboutus, contactus etc.)

  • /server - Folder containing your node js server.

    • /libs - Folder containing your custom libraries.

    • /models - Folder containing schemas for your database models (like in mongo db -define different schemas for different document).

    • /routes - Folder containing routes handled by node js server.

    • /plugins - Folder containing your custom plugins (like database plugin, processRequest plugin etc.)

    • /spec - Folder containing specifications.

    • /tests - Folder containing test applications

    • server.js - JS file containing your server logic.

    • package.json - Package.json file.

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

2 Comments

Thanks Ravi for quick answer ..looks good...will try in this way.
Glad to help :). I have updated answer, added folder for angular views and commonViews

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.