Skip to content

Simple app with clean achitecture metodolgy & solid principle. using nodejs for server, typescript for OOP implementation, and docker for container

Notifications You must be signed in to change notification settings

sankester/clean-architecture-clone

Repository files navigation

Clean Architecture Clone

Simple app with clean achitecture metodolgy & solid principle. using nodejs for server, typescript for OOP implementation, and docker for container

Indication

  1. Framework Independent
    • We are trying to implement a server using rest and graphql by using an isolated business process see detail rest and detail graphql
  2. Testable
    • perform a test on each layer using jest
  3. UI Independent
  4. Database Independent
  5. External agency independence

Scripts

This application by default uses Docker and Docker Compose, so make sure Docker and Docker Compose are installed on your system

Script Description
start start server in prod mode execute file after builder, make sure build first
dev start server with development mode
build build script from typescript
watch build script from typescript and start server with dev mode
tests run all tests with jest
tests:co run all tests and generate coverage
dev:up start docker for development
dev:down stop docker for development
prod:up start docker for production
prod:down stop docker for production
localdb:up start docker for database without docker-compose
localdb:down stop docker for database without docker-compose

Command

look in command.md for used command

Layering

Encapsulate entity, application, and adapter layer in folder core, and framework & driver layer in folder backend

Entity

  • Book

Application Use Cases

  • Get All Book
  • Get Book By ID
  • Add Book
  • Update Book
  • Delete Book
  • Add Account
  • Get Account By Email
  • Check Account By Email

Adapter

Controller

  • GetAllBookConttroller
  • GetBookByIdController
  • AddBookController
  • UpdateBookController
  • DeleteBookController
  • SignupController
  • LoginController

Presentation

  • GetAllBookPresenter
  • GetBookByIdPresenter
  • AddBookPresenter
  • UpdateBookPresenter
  • DeleteBookPresenter
  • SignUpPresentation
  • LoginPresentation

Validation

  • validation with composite pattern
  • validation with class-validator & class-transformer

Framework And Driver

Framework

  • Rest - detail doc
    • using express and swagger (for api docs)
  • Graphql
    • using apollo server and graphql-modules

Database

  • Mongodb
  • Redis

Design Pattern

  • Singleton

    ex: in connection database and event dispatcher

  • Factory

    ex: in make controller in framework etc.

  • Abstract Factory

  • Builder

    ex: in HttpBodyBuilder class

  • Adapter

    ex: router, controller etc

  • Composite

    ex: in validation etc

  • Template Method

    ex: in presentasion

  • Proxy

    ex: in validation controller, authentication, auth middleware

  • Mediator

    ex: in logging

  • Observer

    ex: in logging

  • Dependency Injection

    ex: in many comunicated class

  • Reponsitory Pattern

    ex: all transaction with database

Packages

Default & Production

  • bcrypt - for hashing
  • jsonwebtoken - for encrypting
  • body-parser - parsing http body
  • cors - handle cors request
  • dotenv-extended - for configuration
  • dotenv-parse-variables - for parsing configuration variable
  • express - router framework
  • module-alias - aliases module for simple access
  • mongoose - mongodb object modeling
  • morgan - log request
  • morgan-body - log request body
  • winston - custom system logger
  • swagger-ui-express - api documentation
  • class-validator & class-transformer - validate input request
  • apollo-server-express - graphql server
  • gprahpql-modules - toolling manage graphql

For Deveploper

  • typescript
  • tsc-watch - run watch in detach mode
  • nodemon
  • mongodb-memory-server - use mongodb in memory
  • tsconfig-paths - module aliases for typescript
  • eslint, @typescript-eslint/parser, @typescript-eslint/eslint-plugin - linter
  • prettier, eslint-config-prettier, eslint-plugin-prettier - formatter
  • husky - git hook

For Test

  • mongodb-memory-server - mongodb run in memory
  • jest - unit testing
  • ts-jest - jest for typescript
  • faker - mockup helper
  • bson-objectid - mock objectid
  • supertest - request to server

Types package

  • @types/bcrypt
  • @types/jsonwebtoken
  • @types/cors
  • @types/dotenv-parse-variables
  • @types/express
  • @types/morgan
  • @types/node
  • @types/faker
  • @types/validator
  • @types/supertest
  • @types/swagger-ui-express

Reference

Node Clean Architecture -Deep Dive

clean-ts-api

Backend API Server Development with Node.js from Scratch to Production

About

Simple app with clean achitecture metodolgy & solid principle. using nodejs for server, typescript for OOP implementation, and docker for container

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages