2023-07-05
2951
#node
Piero Borrelli
8111
Jul 5, 2023 ⋅ 10 min read

Node.js project architecture best practices

Piero Borrelli Fullstack developer. Passionate writer and content producer. Lifelong learner.

Recent posts:

Comparing Mutative Vs Immer Vs Reducers For Data Handling In React

Comparing React state tools: Mutative vs. Immer vs. reducers

Mutative processes data with better performance than both Immer and native reducers. Let’s compare these data handling options in React.

Rashedul Alam
Apr 26, 2024 ⋅ 7 min read
Radix Ui Adoption Guide Overview Examples And Alternatives

Radix UI adoption guide: Overview, examples, and alternatives

Radix UI is quickly rising in popularity and has become an excellent go-to solution for building modern design systems and websites.

Nefe Emadamerho-Atori
Apr 25, 2024 ⋅ 11 min read
Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 ⋅ 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 ⋅ 6 min read
View all posts

13 Replies to "Node.js project architecture best practices"

  1. Great article! Although I’m not sure I agree that you should use promises like that. The async/await style has worked very well for me.

  2. You’ve touched on some points of Clean Architecture, but you could take it even further by having an Application Context file that manages your dependencies that you need to inject. This also makes mocking for tests extremely easy.

  3. Rule #1: Correctly organize our files into folders
    Too obvious for most developers.

    Rule #6: Use dependency injection
    Its not true. It should be well-considered decision and depends on many factors, otherwise can make codebase hard to maintain.

    Rule #11: Always comment your code.
    Its not true. Good variables and functions names are self-documenting. In most cases comments just add noise and decrease code readability.

    Rule #12: Keep an eye on your file sizes
    Usually size is not a problem for server-side code.

    Rule #13: Always use gzip compression
    In general Its preferable to enable gzip compression on nginx, not in Node.js.

    Some points, like linting, code style, unit testing just dont relate to architecture, like article’s title says.

  4. Nice article,thanks for sharing.
    You have to correct the example “A simple basic example of a promise”, it will call both the resolve and the reject

  5. Looks like more of a general set of things you could use in a service rather than an actual guideline how to build a good architecture flow. Unfortunately, it’s possible to follow those and still have quite a bad architecture

  6. Dependency injection makes testing much easier. Combine it with Adapters for your vendor libraries/frameworks and you get a nice decoupled system that can swap dependencies with much less effort.

    It actually increases the complexity of codebase in order to improve maintainability IMO.

  7. Loved this article. As a junior Dev, this is gold. Can you please share any open source github project that is using this particular or a similar architecture so that I can see how its actually implemented in code? It would be very helpful. Thanks!

Leave a Reply