Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:14:38+00:00 2026-05-23T11:14:38+00:00

I am writing a NodeJS based server- and client-side JavaScript application. I have Controllers,

  • 0

I am writing a NodeJS based server- and client-side JavaScript application. I have Controllers, Models, Views and Presenters. The problem I am facing is that some parts of the code need to be only server-side, some client-side and some both.

For example, Controllers are pure server-side thing for me so they should not be available client-side. Presenters, on the other hand, are pure client-side thing so should be available in client-side.

Take a look at my current bad structure:

project\
project\public\index.js
project\public\images\
project\protected\controllers\
project\protected\models\
project\protected\views\
project\protected\presenters\

The problem I face is that public folder is the document root and protected is outside of the document root. I need to be able to use Views in both client- and server-side. So, my Views can’t be in protected. The same applies to models and tons of other things. I need to be able to access them client-side too.

I am starting to think I have to put the entire structure under document root with the exception of some configuration file. Is this what I should do? Are there any problems with this approach? I am asking because most web frameworks (Django, Zend Framework) work the way that the framework is outside of the document root.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:14:39+00:00Added an answer on May 23, 2026 at 11:14 am

    My github structure (out-dated)

    -- Main level
    project\
    -- Your main app. Keep light
    project\app.js
    -- All your configuration, development/production setups
    project\app-configure
    -- Your server-side controllers/routing. Keep light
    project\controllers\
    -- Any WebSocket specific code.
    project\socket-io\
    -- Server side test
    project\test\
    -- Your public folder. Client side can access these files.   
    -- Serve this folder as static content
    project\public\
    -- I keep my backbone collections here. Used on both server & client
    project\public\collections
    -- public css files
    project\public\css
    -- public js files. Including a main.js to bootstrap the router
    project\public\js
    -- public models used on both server & client.
    project\public\models
    -- client side router, used to router hashbang urls. Can use same routing
    -- logic as the server. This is virtually a second set of controllers around
    -- All your models
    project\public\routers\
    -- public tests. QUnit based
    project\public\test\
    -- View files
    project\public\views
    -- Templates used to render HTML. Used on client & server
    project\public\views\templates
    -- Backbone view files. Used to code up interaction, and business logic
    -- This uses templates to render HTML and DOM events to handle interaction
    project\public\views\backbone-views
    

    This is based on express and backbone. Controllers are express-controllers public\routers are client-side routing using davis

    Basically because the MVC is so heavily re-used across client and server, the only thing that’s not public are server-side tests and the server-side controllers. As well as the configuration settings and any socket-io based code.

    My advice is simple anything that’s used in both goes in \public\

    Because MVC re-use on both the client and the server is a new thing, there aren’t any examples you can look at. Apart from hunting for big open source node.js websites on github.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've heard much good about nodejs and writting client-server application with it. But I
With the creation of node.js and various other utilities for writing server side javascript
I'm writing an event-driven publish/subscribe application with NodeJS and Redis. I need an example
I am writing a java application. I have a class named Node. I have
I'm writing a Java EE application using JBoss AS 6 and I have a
Typically when writing a web-app we want to perform validation on both client side
I am writing a coordinate conversion library for javascript (for both NodeJS and browser
I'm writing a Java Tree in which tree nodes could have children that take
Writing my first Linq application, and I'm trying to find the best way to
Writing a test app to emulate PIO lines, I have a very simple Python/Tk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.