How I Structured My NodeJS Projects

Architecture — Photo from Pexels

I had a hard time marrying my knowledge back then with the idea of a server-side JavaScript application.

Struggle was REAL


There are thousands of ways to skin a cat. But we won’t be doing one here.

  1. Modularize Components
  2. Expose APIs
  3. Simplify Configurations
  4. Fetch Logs Easily
  5. Output Webpages
- project
- src
- components
- api
- modules
- config
- logs
- node_modules
- public
- assets
- css
- img
- js
- routes
- util
- app.js
- server.js
- package.json

Project Structure


  1. The api directory will contain the API controllers, these controllers will call the necessary service modules. It’s expected that you group your contents by functionality. In this way, you can take advantage of working on related APIs altogether.
  2. The modules directory will contain atomic services. These services will be consumed by the different API and page controllers that will render the data for consumption.




  1. The assets directory will contain all of the HTML views, CSS, JS and media. The HTML views will render the data retrieved from the different services. The page controllers will be handling the incoming requests for processing, and for rendering the corresponding HTML views.



Final Thoughts





Software Development. Indie Hacker. Startups. Tech.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How you can plan three days ahead with React

React Top 10 Articles For the Past Month (v.Oct 2017)

Using jQuery Document Traversal Features

Choosing the Right JavaScript Bundler in 2020

Weather or not — here we come!

Getting Started with Rails 6 and React

For Loops vs While Loops

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Software Development. Indie Hacker. Startups. Tech.

More from Medium

Application Framework — SE3040

Why Is Node.js a Good Choice for Enterprise App Development?

node.js for enterprise app development

Supercharge your app with runtime type-checking using ZOD

Top Frontend Development Trends Enterprises to Embrace in 2022

Top Frontend Development Trends Enterprises to Embrace in 2022