Clean architecture with node.

903 views
Skip to first unread message

vivek poddar

unread,
Aug 12, 2016, 12:58:53 PM8/12/16
to Clean Code Discussion
Hi,

I am have started a clean architecture based node application. I need some advice or example to get running in the right direction.

What I have done so far:

* Start with a basic directory structure.
* Set up the basic requirements.
* Doesn't care about the details like persistence, UI etc.
* Set up some basic acceptance tests.


Dave Schinkel

unread,
Aug 22, 2016, 10:53:53 PM8/22/16
to Clean Code Discussion
Hey vivek.  I'm not going to claim this is 100% correct when you talk about applying the clean code architecture but I tried at a previous employer when I was building a new Node.js API.  This isn't code but illustrates how I did approach coding the API.

Clean Architecture Diagram Modified to Relate to my Web Service

It probably needs a little work but hopefully this helps.  I've been told by a friend who thinks this is "overarchitecting" but I do disagree with him on it (at least at this point in time until convinced otherwise). This was an API that was critical to the company and going to be used internally and also called externally.

Dave Schinkel

unread,
Sep 23, 2016, 12:31:40 AM9/23/16
to Clean Code Discussion
Note: one correction I need to make on my diagram(s) is that I have an incorrect arrow going from repository to interactor.  It's actually supposed to be pointing down from interactor to repository.  I'll have to update it so that it's more accurate to how I did actually design it and also shows that nothing below is depending on something above which in this case it implies my repositories are talking to my interactors which is just a error on my part in the drawing.

vivek poddar

unread,
Sep 26, 2016, 10:37:20 AM9/26/16
to Clean Code Discussion
Hi Dave,

I appreciate the detailed design and pictorial representations. I am still finding difficult to find some working code where I can see how they are implemented in nodejs. I don't know if you can share code with me but a working prototype would be great.

Thanks,

Ben Pardo

unread,
Sep 26, 2016, 10:40:09 AM9/26/16
to clean-code...@googlegroups.com
Yeah, thank you for the diagram. It's really neat. I too would love to see some code.

--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.
To post to this group, send email to clean-code-discussion@googlegroups.com.
Visit this group at https://groups.google.com/group/clean-code-discussion.

Israel Fonseca

unread,
Oct 26, 2016, 7:21:21 PM10/26/16
to clean-code...@googlegroups.com
@vivek

I missed the concept of the Usecase in your code, I think that the: getRandomQuote(), could be that (you got 3 untested clauses in there). I'm trying to make a concept of the CA in Node too, but using Promises (not quite straight forward).


Maybe It'll give you some ideas, and be free to give me some feedbacks also. :)

@Dave

Nice work with the PDFs!

To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.

--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.

Juan Angel

unread,
Jul 14, 2017, 10:56:39 AM7/14/17
to Clean Code Discussion
Hi @vivek,

if you are still interested in delving into Clean Architecture with Node you can check out this post: 

Where some architecture designs are discussed and you have some code examples of Clean Architecture integrating both a REST and a GraphQL APIs, db connection with MongoDB, and unit tests.

Dave Schinkel

unread,
Jul 25, 2017, 4:28:01 PM7/25/17
to Clean Code Discussion
So...I'm still working on improving my Clean Architecture approach in the backend (so don't take the way I do it as "ideal", I'm sure I can improve on it) but I'll be streaming hopefully to work more on that here in the near future: https://www.twitch.tv/wedotdd

vivek poddar

unread,
Jul 25, 2017, 10:50:43 PM7/25/17
to Clean Code Discussion
Hi Juan,

Thanks for sharing the link but it feels somewhat incomplete to me.
The author says that code is testable but I can't see dependency injection anywhere.

I still think there is a need for someone expert to chime in.

Thanks,
Reply all
Reply to author
Forward
0 new messages