All Projects → bespoyasov → frontend-clean-architecture

bespoyasov / frontend-clean-architecture

Licence: other
React + TypeScript app built using the clean architecture principles in a more functional way · 🧼 🏛 🍪

Programming Languages

typescript
32286 projects
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to frontend-clean-architecture

onion-architecture
My Java implementation example of onion architecture
Stars: ✭ 52 (-97.14%)
Mutual labels:  clean-architecture, onion-architecture
Clean Architecture Manga
🌀 Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
Stars: ✭ 3,104 (+70.93%)
Mutual labels:  clean-architecture, onion-architecture
last fm
A simple app to demonstrate a testable, maintainable, and scalable architecture for flutter. flutter_bloc, get_it, hive, and REST API are some of the tech stacks used in this project.
Stars: ✭ 134 (-92.62%)
Mutual labels:  clean-architecture, layered-architecture
OnionArchitecture
The onion architecture, introduced by Jeffrey Palermo, overcomes the issues of the layered architecture with great ease. With Onion Architecture, the game-changer is that the Domain Layer (Entities and Validation Rules that are common to the business case ) is at the Core of the Entire Application. This means higher flexibility and lesser coupli…
Stars: ✭ 314 (-82.71%)
Mutual labels:  clean-architecture, onion-architecture
Babel Plugin Partial Application
[DEPRECATED] Please use https://github.com/citycide/param.macro
Stars: ✭ 60 (-96.7%)
Mutual labels:  application, functional
archunit-junit5-kotlin
Generic Architecture Tests written in Kotlin using ArchUnit and Junit5
Stars: ✭ 22 (-98.79%)
Mutual labels:  clean-architecture, onion-architecture
Domain Driven Hexagon
Guide on Domain-Driven Design, software architecture, design patterns, best practices etc.
Stars: ✭ 4,417 (+143.23%)
Mutual labels:  clean-architecture, onion-architecture
Android-Clean-Architecture
This is a sample movie list Android application built to demonstrate use of Clean Architecture tools. Dedicated to all Android Developers - (Kotlin, MVVM, Clean Architecture, Rx-Java, Dagger, OkHttp, Unit Testing, SOLID principles, Code Coverage)
Stars: ✭ 268 (-85.24%)
Mutual labels:  domain, clean-architecture
Information collection handbook
Handbook of information collection for penetration testing and src
Stars: ✭ 447 (-75.39%)
Mutual labels:  application, domain
Plastic
This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.
Stars: ✭ 30 (-98.35%)
Mutual labels:  application, clean-architecture
awesome-software-architecture
A curated list of awesome articles, videos, and other resources to learn and practice software architecture, patterns, and principles.
Stars: ✭ 1,594 (-12.22%)
Mutual labels:  clean-architecture, onion-architecture
Param.macro
Partial application syntax and lambda parameters for JavaScript, inspired by Scala's `_` & Kotlin's `it`
Stars: ✭ 170 (-90.64%)
Mutual labels:  application, functional
gochk
Static Dependency Analysis Tool for Go Files
Stars: ✭ 68 (-96.26%)
Mutual labels:  clean-architecture, layered-architecture
neu-ipgw
东北大学校园网网关快速登录,更高效,更实用!
Stars: ✭ 19 (-98.95%)
Mutual labels:  application
android
🌦 Vädret
Stars: ✭ 17 (-99.06%)
Mutual labels:  clean-architecture
simple-wallet
This is a simple wallet REST api that is capable of acount deposits and withdrawals, checking for account balance and providing a ministatement. It follows domain driven design practices. The project uses the DDD architecture approach.
Stars: ✭ 32 (-98.24%)
Mutual labels:  clean-architecture
fast-cartesian
Fast cartesian product
Stars: ✭ 51 (-97.19%)
Mutual labels:  functional
jpass
🔐 Password manager application with strong encryption (AES-256). [Java/Swing]
Stars: ✭ 129 (-92.9%)
Mutual labels:  application
ITL
Sample Web API implementation with .NET Core and DDD using Clean Architecture.
Stars: ✭ 29 (-98.4%)
Mutual labels:  clean-architecture
roove
Dating app based on firebase services and facebook login. MVVM-Kotlin-RxJava-Dagger-Databinding
Stars: ✭ 55 (-96.97%)
Mutual labels:  clean-architecture

Other languages: Russian.

Frontend Clean Architecture

A React + TypeScript example app built using the clean architecture in a functional(-ish) way.

Things to Consider

There are a few compromises and simplifications in the code that are worth to be mentioned.

Shared Kernel

Shared Kernel is the code and data on which any modules can depend, but only if this dependency would not increase coupling. More details about the limitations and application are well described in the article "DDD, Hexagonal, Onion, Clean, CQRS, ... How I put it all together".

In this application, the shared kernel includes global type annotations that can be accessed anywhere in the app and by any module. Such types are collected in shared-kernel.d.ts.

Dependency in the Domain

The createOrder function uses the library-like function currentDatetime to specify the order creation date. This is not quite correct, because the domain should not depend on anything.

Ideally, the implementation of the Order type should accept all the necessary data, including the date, from outside. The creation of this entity would be in the application layer in orderProducts:

async function orderProducts(user: User, { products }: Cart) {
  const datetime = currentDatetime();
  const order = new Order(user, products, datetime);

  // ...
}

Use Case Testability

The order creation function orderProduct itself is framework-independent right now and can't be used and tested in isolation from React. The hook wrapper though is only used to provide the use case to components and to inject services into the use case itself.

In a canonical implementation, the function of the use case would be extracted outside the hook, and the services would be passed to the use case via a last argument or a DI:

type Dependencies = {
  notifier?: NotificationService;
  payment?: PaymentService;
  orderStorage?: OrderStorageService;
};

async function orderProducts(
  user: User,
  cart: Cart,
  dependencies: Dependencies = defaultDependencies
) {
  const { notifier, payment, orderStorage } = dependencies;

  // ...
}

Hook would then become an adapter:

function useOrderProducts() {
  const notifier = useNotifier();
  const payment = usePayment();
  const orderStorage = useOrdersStorage();

  return (user: User, cart: Cart) =>
    orderProducts(user, cart, {
      notifier,
      payment,
      orderStorage,
    });
}

In the sources, I thought it was unnecessary, as it would distract from the essence.

Crooked DI

In the application layer we inject services by hand:

export function useAuthenticate() {
  const storage: UserStorageService = useUserStorage();
  const auth: AuthenticationService = useAuth();

  // ...
}

In a good way, this should be automated and done through the dependency injection. But in the case of React and hooks, we can use them as a “container” that returns an implementation of the specified interface.

In this particular application, it didn't make much sense to set up the DI because it would distract from the main topic.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].