How to structure my project?

How to structure my project?
0

#1

I’m about to start voting app, this will be first big project where I will have views, styles, libraries, users, polls, DB with different tables, etc.

Instead having all my source code in one file (server.js), how should I organize my project?


#2

There’s no best way - just do something that suits the structure of the way you envision the parts of the app and keeps your source code in nice small chunks.

I didn’t use a frontend framework, which simplifies the structure.

Mine looked something like this:

/views
  /pages
  [contains ejs templates]
  /partials
  [contains ejs partial templates]
/public
  /stylesheets
  /scripts
/routes
[contains all my express routes]
/controllers
[contains my database queries / functions used by routes]
server.js