Code Monkey home page Code Monkey logo

grenoble-hands-on-front-clean-architecture's Introduction

Hands-on Frontend Series : Clean Architecture

After having discovered the main frontend application development frameworks through the previous hands-ons, we will now see how to architect our application.

The goal of a good architecture is to gain in testability, scalability and maintainability. We will also see that a good architecture will allow us to depend less on frameworks and tools to develop applications that are more resilient to changing technologies.

The concept of "Clean Architecture", also known as "Hexagonal Architecture" or "Ports / Adapters Architecture" has already proven its worth in the development of backend applications.

While this technique has gained in popularity in recent years, it has not become much democratized in frontend application development.

We therefore invite you to come and discover the fundamentals of Clean Architecture and see how to implement it in a web application.

Through this repository, we redevelop the weather forecast application from the concepts of "Clean Architecture".

Prerequisite

  • nodejs > 10

Install

npm install

Usage

Angular

npm run angular 

React

npm run react

Structure

clean-archi

  • packages/domain : Core of business application (city, weather, port)
  • packages/web/adapters : Class used to make infrastructure communicate with domaine
  • packages/web/infrastructure : Weather app with frameworks usage

Technologies

Langage

  • Typescript

Tools / Libraries

  • Lerna
  • Angular
  • React
  • Jest
  • @testing/library

Other Hands-on

Front

Backend

Contributing

grenoble-hands-on-front-clean-architecture's People

Contributors

mchoraine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grenoble-hands-on-front-clean-architecture's Issues

Problème pour "npm install"

Juste après avoir cloné le dépôt, je lance npm i et j'ai une erreur :

> @grenoble-hands-on/root@ postinstall /xxxx/grenoble-hands-on-front-clean-architecture
> lerna bootstrap

lerna notice cli v3.22.1
lerna info Bootstrapping 5 packages
lerna info Installing external dependencies
lerna ERR! npm install exited 1 in '@grenoble-hands-on/web-adapters'
lerna ERR! npm install stderr:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @grenoble-hands-on/[email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /xxxxx.npm/_logs/2021-04-20T17_46_49_013Z-debug.log

lerna ERR! npm install exited 1 in '@grenoble-hands-on/web-adapters'
lerna WARN complete Waiting for 4 child processes to exit. CTRL-C to exit immediately.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @grenoble-hands-on/root@ postinstall: `lerna bootstrap`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @grenoble-hands-on/root@ postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /xxxx/.npm/_logs/2021-04-20T17_46_49_119Z-debug.log

NPM version : 6.14.4

Merci

[Advice]: Using eslint to prevent dependencies from Domain to Adapters

Hello 👋

I've seen your talk at SnowCamp 2022 and I asked if you used any tools to prevent breaking the rule of the Domain dependencies: no dependencies from Domain to the outside world. I think there is actually a tool that can help with that: eslint and one of its plugins, eslint-plugin-import. You probably already know eslint which is widely-used to lint files and detect problems. eslint-plugin-import has many rules but one rule is of particular interest to this problem: import/no-restricted-paths. It allows you to define "zones" from either a folder or a glob, and define specific restrictions on each zone. You can prevent files from one folder from importing files from other defined folders. Using this rule, we can prevent the Domain from importing files from the Adapters.

Shortly before the talk, I watched your video "Hands-on Front : La clean architecture dans le web" and was really inspired to give it a try. I did not go for the full "Clean Architecture", just "Hexagonal Architecture" for now. Anyway, please check out this example of an .eslintrc file that defines rules to prevent dependencies from the Domain to the Adapters. There are also separate rules for each "type" of adapters to prevent adapters from the UI depending directly on other adapters from REST API for example.
The rules do not prevent all dependencies though: you are still allowed to depend on libs from node_modules. If one wants to completely isolate the Domain from libs, the rule should be refined to make it stricter.

I hope this can help ! 🙂

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.