Clean architecture with nodeJs express : practical example in node.js

  Рет қаралды 17,620

Code with Jay

Code with Jay

Күн бұрын

How to build Nodejs Microservice with Kafka. It's an advanced course on Microservice development using Nodejs and Kafka. Where we will learn everything about the communication between services and Elastic search integration using typescript.
Diagram:
whimsical.com/...
Clean Architecture Episode Repository:
github.com/cod...
Repository:
github.com/cod...
Discord Channel:
/ discord
What are the key concepts you can learn from this course?
- Software Development Estimation process
- Clean Architecture
- Kafka in Node.js with a practical example
- Elastic Search integration
- Prisma implementation as ORM
- How to cover test cases
#nodejsdevelopment #express #javascriptframework #backenddeveloper

Пікірлер: 68
@viralmoney8619
@viralmoney8619 24 күн бұрын
Hi sir.. if you don't mind.. could you please make one large application or creating apid for it by this way.. including authentication dto,types and type orm with mogodb testing?❤😊🎉
@sharaths2294
@sharaths2294 2 ай бұрын
database is not working. i created clean_architecture database and defined table but cant create or find ?
@abayomioloyinde
@abayomioloyinde 9 ай бұрын
How are you my friend? Happy new year in advance, I will watch this after my holiday, i know it's a goody as usual
@codewithjay
@codewithjay 9 ай бұрын
Thanks a lot my friend! Wish you Happy new year!
@adeniyitaofik3832
@adeniyitaofik3832 5 ай бұрын
link to the previous episode
@aabhishakemishra
@aabhishakemishra 9 ай бұрын
Great content ❤
@pranav7478
@pranav7478 9 ай бұрын
Jay , what is your opinion about nestjs
@codewithjay
@codewithjay 9 ай бұрын
Yes, You can use NestJS that's an wonderful framework! But not recommended for all the use cases. Example some times its overkill when we have simple requirements and specially when we are not dealing with Microservice or big project requirements. But if you really want to structure project without put your hands to create structure like in our current video. You can go with NestJS. Cheers!
@shravanology
@shravanology 9 ай бұрын
Love it
@awesomeguy6427
@awesomeguy6427 9 ай бұрын
what's ur vs code font I love it
@codewithjay
@codewithjay 9 ай бұрын
JetBrains Mono
@shravan2891
@shravan2891 9 ай бұрын
I was waiting for this after watching first part. Good to see some unique advance stuff on KZbin. Good work brother ✨
@kemalsogut9342
@kemalsogut9342 8 ай бұрын
as I new learner, i learned clean architecture in c#. Actually did not create many projects with c# but i understood the clean architecture thanks to the teacher. I recently started learning node.js and was about to create my own project after tutorials. The think that stopped me was actually clean architecture. As I learned it from the c# courses I felt that somethings were going wrong in the node.js tutorials, then i searched clean architecture in node.js and found your video. It is very helpful and understandable as a beginner/low-intermediate. Thank you very much!
@codewithjay
@codewithjay 8 ай бұрын
Thank you for your kind words. Stay tuned to our channel and join our discord channel for Job offer announcements and updates. Cheers!
@ArnabDas-q9f
@ArnabDas-q9f 12 күн бұрын
nest js
@NathanielBabalola
@NathanielBabalola 9 ай бұрын
Don't you think every Entity having it's own folder is better..... then they have their own files inside their folder.... controller, service, repository, interface e.t.c
@codewithjay
@codewithjay 9 ай бұрын
It's up to you how you organize your files. Only matters to follow the principal and Enterprise and Application business rules should not affect when we change UI and framework along with Data Access Layer.
@technoinfoworldwide2329
@technoinfoworldwide2329 9 ай бұрын
Also make another video by following functional based not classed based and used orm prisma
@mohit84604
@mohit84604 8 ай бұрын
Will there be any videos releated to Hexagonal architecture and Onion architecture because i have some doubts releated to them. Are they same except their name.
@codewithjay
@codewithjay 8 ай бұрын
They are not same. It is sharing common principles like separation of concerns in layers, and clean dependency pattern, Inversion of controls etc. Each architecture has it's own emphases and implementations based on use cases. Overall if you at least know one of them you are good to go. I will release some videos in future based on these concepts.
@erickweil4580
@erickweil4580 3 ай бұрын
I'm trying to implement this architecture to one of my projects but using nodejs without the typescript thing, and the dependency injection thing of having a instace of the interactor seems not necessary, If I want to test with a mock I can override the static class instance of the methods in the interactor itself.
@codewithjay
@codewithjay 3 ай бұрын
Hi, Thank you for writing. Here we just want to give an overview of how clean architecture works by keeping loose coupling of the layers and dependencies. It's up to you to follow the pattern or maybe you can shape it as per your application needs by revoking extra layers. You do not necessarily need to use interactors in the case of Javascript it is out of the question. In functional programming, you can get rid of it and hook up with your dedicated function to replace the functionality. You can watch our latest episodes for references. Cheers!
@Riflijones01
@Riflijones01 8 ай бұрын
HI Jay. Are you still going to be creating the frontend for the microservices masterclass series? would be great to see even a basic design on the frontend to see how it all goes together
@codewithjay
@codewithjay 8 ай бұрын
Hey Thank you for writing! Certainly I will cover that in part 2. As soon as we covered this series Elastic Search Functionality.
@eR1cK92
@eR1cK92 4 ай бұрын
If I want to add any middleware for example I have jwt and the request needs the token, where can I add the middle ware for each requesg and how ??
@codewithjay
@codewithjay 4 ай бұрын
You can add it in the route file example: // Authentication middleware (example) const authMiddleware = (req: Request, res: Response, next: NextFunction) => { // Placeholder for actual authentication logic with jwt const isAuthenticated = true; // Replace with real authentication check if (!isAuthenticated) { return res.status(401).json({ message: "Unauthorized" }); } next(); }; // Apply middleware to all routes router.use(loggerMiddleware); or if specific endpoint needs authentication you can use like below: router.post( "/products", authMiddleware, async (req: Request, res: Response, next: NextFunction) => { try { const { errors, input } = await RequestValidator( CreateProductRequest, req.body ); if (errors) return res.status(400).json(errors); const data = await catalogService.createProduct(input); return res.status(201).json(data); } catch (error) { next(error); } } ); Hope it will help you :) Cheers!
@khaledmansour59
@khaledmansour59 Ай бұрын
"Right?" *100000
@chess4964
@chess4964 4 ай бұрын
If you are going to implement this on Nodejs why not use Nestjs instead?
@codewithjay
@codewithjay 4 ай бұрын
Thank you for writing and your opinion. We are focusing on to understand the mechanism only not the a framework. You can use NestJS if you know how it works behind the scene. Note: This tutorial series made based on viewers request how to build such system using NodeJs not NestJS.
@kranthikumarvitta
@kranthikumarvitta 9 ай бұрын
Great work Jay! What should be the industry practice using orm models like sequelize,prisma erc. or raw queries as per tutorial? And what are your thoughts about using nestjs which has already using singleton or repository pattern
@abayomioloyinde
@abayomioloyinde 9 ай бұрын
@Jay you response on this will be appreciated
@codewithjay
@codewithjay 9 ай бұрын
Hey thanks a lot for writing! TBH there are no such silver bullet points as Industry best practices. But it's depends on your project requirements and how your team decide what to follow. I would recommend to use some ORM to save your time and complexity. Behind the scene all ORM is used raw sql only and it gives flexibility to deal with Database queries and execution using high level abstractions. You can use TypeORM or Prisma that is widely used in NodeJS ecosystem. You can use NestJS that's an wonderful framework! But not recommended for simple requirements and specially when we are not dealing with Microservice or big project requirements. But if you really want to structure project without put your hands to create structure like in our current video. You can go with NestJS. Note: We have not implemented any ORM on this Episode just for shake of time but we have already implemented ORM (Prisma) for our this series you will see very soon in coming videos. Cheers!
@codewithjay
@codewithjay 9 ай бұрын
please follow the answer!
@hfmohammad
@hfmohammad 7 ай бұрын
Hi, Thank you for this tutorial. How we can avoid dependency injection? Example: AService.ts const AA = () => { BService.BB(); } const CC = () => { // some code } BService.ts const BB = () => { AService.CC(); } Note: we don't want use methods together Only services import to together
@devPloy
@devPloy 5 ай бұрын
Hi Jay, first of all thank you so much for share this proffessional knowledge, your channel is amazing. Sincerely the best and precise course of node that I ever had. I have a question my friend, in what layer should the repository be? I see that the product repository uses the external library "pg" and also it comunicates with Product entity. I am a little confuse about this, can you explain me? please.
@ishanbhawantha
@ishanbhawantha 2 ай бұрын
How do you write the entity validator ? In that case how to avoid the couple between node packages for validation.
@codewithjay
@codewithjay 2 ай бұрын
To write an entity validator in TypeScript while avoiding direct coupling to specific node packages, you can adopt an abstraction approach. This involves defining your own validation interfaces and using a strategy pattern to apply various validation implementations. In our case we are using AJV and typeBox with generic to disconnecting the coupling.
@ishanbhawantha
@ishanbhawantha 2 ай бұрын
@@codewithjay Thank you !
@sharaths2294
@sharaths2294 2 ай бұрын
clean architecture is all great but why the need of dependency injection. I have never used so confused why used here ?
@techpassion5680
@techpassion5680 Ай бұрын
I have a legacy nodejs project written 4 years. I recented update to clean articture. Thanks!
@ShaunEk1
@ShaunEk1 3 ай бұрын
I’ve been poking around KZbin and the inter webs for node/typescript specific examples of clean architecture and I gotta say I think your video is the *best* at showing the principles through a legit project, with code!! I do like how you simplified the tutorial, eliminating non essentials like an orm and messaging libs. Calling “use cases” by the name “interactors” is something I have not heard before. The only thing that I felt was truly missing was the interaction with the domain layer… you did create a domain object but then ignored it for the rest of the tutorial. Since it was such a small/simple project maybe it didn’t warrant calling any domain methods though, but would have been nice to mention that. Amazing video. Subscribing now.
@codewithjay
@codewithjay 3 ай бұрын
Thank you for your appreciation. Some time it's not easy to cover all the edge cases. But I will take a note on your suggestion. Cheers!
@bollo_omar
@bollo_omar 9 ай бұрын
I like the way you explained Clean architecture well but if I may ask, aren't just adding more abstractions and spreading code across multiple folders/files?
@codewithjay
@codewithjay 9 ай бұрын
Hi thanks a lot for your opinion! It's up to you how you organize your codes but in this project we tried to decoupled by keeping essential layers only as per the principal. If you understood the concept you can minimize your code accordingly. In this case if we not spreading the codes to layers it belongs to and not injected dependencies properly to perform the operation in the loosely couple way then it will be not meaning full to implement Clean architecture anymore. Cheers!
@thebeginner613
@thebeginner613 3 ай бұрын
Thanks bro ....
@marcelee124
@marcelee124 5 ай бұрын
Hey thank you so much.
@coder_one
@coder_one 8 ай бұрын
Does every refactoring on "clean architecture" have to end up writing OOP? Why didn't you stay with the functional approach?
@codewithjay
@codewithjay 8 ай бұрын
It's not about ended with Object Oriented Programming! It's about the removing dependencies and utilize of layered architecture that Domain and Application business logic not to tightly dependent on framework and drivers etc. If you understand the concept correctly you can utilize it on functional programming as well. We following Class pattern just to make people understand easy way. If you are following this series you will see the functional usages with clean architecture in future lactures. Cheers!
@akashdanva
@akashdanva 8 ай бұрын
Great Video. Can you please explain what was the need of .bind, why the constructor was not being called properly?
@codewithjay
@codewithjay 8 ай бұрын
Thank you for writing. In javascript and typescript bind returns a new function with the bound "this". Example: in our case router.post("/products", controller.onCreateProduct.bind(controller)); Here bind method is used to ensure that the onCreateProduct function is called with a specific this context, which is the controller object in this case. The bind method creates a new function that, when called, has its this value set to the provided argument. In this example, controller.onCreateProduct.bind(controller) creates a new function where the this value inside onCreateProduct will refer to the controller object.This is commonly done in the context of setting up routes in web frameworks, where you want to ensure that the controller methods are called with the correct context. Hope it will help! Cheers!
@mohamadyousef2129
@mohamadyousef2129 7 ай бұрын
Thanks a lot man
@ericsiddiq7634
@ericsiddiq7634 9 ай бұрын
Thanks ❤
@sebastianlpoliak
@sebastianlpoliak 5 ай бұрын
Amazing video!!
@codingroom1230
@codingroom1230 7 ай бұрын
There are many ways to achieve clean architecture. In my opinion, it is good to use a framework.
@codewithjay
@codewithjay 7 ай бұрын
Yes you can. But you need to understand how it works at least while we are facing coding interviews the framework will not help to convince interviewers :)
@_NguyenTuanAnh-nr4ee
@_NguyenTuanAnh-nr4ee 8 ай бұрын
Great Video
@vyteniskuciauskas
@vyteniskuciauskas 6 ай бұрын
For those many files needed for just one entity you need to introduce a generator :)
@codewithjay
@codewithjay 6 ай бұрын
You can use one as per your convenient. Cheers!
@BarakAlmog
@BarakAlmog 7 ай бұрын
Great video! Thanks so much for your efforts.
@codewithjay
@codewithjay 7 ай бұрын
My pleasure!
@aabhishakemishra
@aabhishakemishra 9 ай бұрын
Sir will u apply Kafka in this project?
@codewithjay
@codewithjay 9 ай бұрын
Yes this series is based on Kafka & Elastic Search, Prisma and Clean Architecture!
@zuenirclaudio4941
@zuenirclaudio4941 3 ай бұрын
Thanks great tutorial. it helped a lot
@codewithjay
@codewithjay 3 ай бұрын
I'm glad the tutorial was helpful for you! Cheers!
@abdullahsevmez42
@abdullahsevmez42 9 ай бұрын
İt's very clear. Thank you Jay!
@codewithjay
@codewithjay 9 ай бұрын
Glad it was helpful!
@VerdijtHanati
@VerdijtHanati 9 ай бұрын
Great work
@codewithjay
@codewithjay 9 ай бұрын
Thank you so much 😀
When to use ORM in nodejs ?
7:59
Code with Jay
Рет қаралды 2,2 М.
Chia sẻ kiến trúc - Giải thích Clean Architecture
11:04
Việt Trần
Рет қаралды 17 М.
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 3,8 МЛН
Worst flight ever
00:55
Adam W
Рет қаралды 26 МЛН
The Tools I Use to Build Products in Laravel
19:00
Josh Cirre
Рет қаралды 31 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 650 М.
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 46 М.
Microservices Architecture - Implementation with Example - Part 1
3:18
Five Minute Tech
Рет қаралды 23 М.
I built an app using a single index.php file, here's how it went
32:42
Andrew Schmelyun
Рет қаралды 59 М.
Solid Programming - No Thanks
32:00
ThePrimeTime
Рет қаралды 303 М.
Ditch your Favorite Programming Paradigm
6:08
Code Persist
Рет қаралды 183 М.
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 3,8 МЛН