Coder Social home page Coder Social logo

clean-architecture-example's Introduction

Node.js + Typescript + AVA + Clean Architecture starter kit

This starter kit is build on top of Node.js + Typescript + AVA for testing + Clean Architecture. The idea behind Clean Architecture is to have several distinct layers, so that you and your team's development time stays clean, modular and linear, wether your code base is small or large. For a more detailed explanation about Clean Architecture see here.

Clean Architecture divides your code to 4 main layers:

  • Entities - These are your contracts, types, abstract classses and interfaces
  • Use-Cases - These are your application specific business rules, like AddToCart which does several things.
  • Implementations - This is where you prepare your use cases for the upper layer(frameworks-drivers), for example, you create an http implementation of AddToCart which wraps your AddToCart and expects a request.body which only exists when working with http.
  • Frameworks-Drivers - This is where you call all of your dependencies, initiate all of your concrete classes and connect everything.

Note that each layer can only talk to the layer beneath it and only it! This way your code will always stay modular and you can easily replace implementations of use-cases to whatever input/output you would like.

Adding a new use-case:

  1. Create appropriate entities
  2. Create your use-case with your application specific logic
  3. Pass all dependencies of your use-case through the constructor only!
  4. Create a new implementation which extends your use-case, like HttpAddToCart or gRPCAddToCart or whatever you like
  5. Create your frameworks-drivers web.ts or gRPC.ts if you dont have that already.
  6. Initiate all your implementations for that frameworks-drivers
  7. Tests!!!

clean-architecture-example's People

Contributors

yuraxdrumz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.