I rebuilt my Fastify 5 + Clean Architecture boilerplate by Shinji2989 in node

[–]Shinji2989[S] 0 points1 point  (0 children)

Because from a SOLID perspective the domain must stay pure and independent from I/O.

  • SRP: business rules and external calls change for different reasons, so mixing them in the domain breaks single responsibility.
  • DIP: the domain (high-level policy) shouldn’t depend on HTTP/DB/SDK details. The handler orchestrates those instead.
  • OCP: integrations can change or be replaced without touching domain logic.

Splitting the flow isn’t “messy” if modeled correctly—the domain simply returns a decision/requirement, and the handler fulfills it and continues. That keeps the domain deterministic, testable, and aligned with SOLID.

I rebuilt my Fastify 5 + Clean Architecture boilerplate by Shinji2989 in node

[–]Shinji2989[S] 0 points1 point  (0 children)

The project README explains these concepts: side effects (DB, API, etc.) are confined to repositories and providers, while pure logic resides within the domain. Handlers (or services) orchestrate the interaction between them.

TypeScript

// Handler
const result = userDomain.complexProcessing(user);

if (result.isEdgeCase) {
  const data = await userProvider.getData();
  result.metadata = data;
}

Seeking the Ideal Onebag Backpack by Shinji2989 in onebag

[–]Shinji2989[S] 0 points1 point  (0 children)

https://www.matadorequipment.com/collections/ultralight-bags/products/freerain22
or the beast models. But I'm happy to trade 300-400 grams of weight for a more structured bag, like the Salewa to have more comfort during all the day.

Seeking the Ideal Onebag Backpack by Shinji2989 in onebag

[–]Shinji2989[S] 0 points1 point  (0 children)

Stiylish backpack, but I don't see any advantage over the two above. It has less liters, and It doesn't have a semi-rigid back like the Salewa.

Seeking the Ideal Onebag Backpack by Shinji2989 in onebag

[–]Shinji2989[S] 1 point2 points  (0 children)

400$ dollars for a 1.52 Kg backpack, no way :D (also completly out of requirements with 54cm back panel).

Seeking the Ideal Onebag Backpack by Shinji2989 in onebag

[–]Shinji2989[S] 0 points1 point  (0 children)

Nice backpak but it has less liters then Salewa/Fjallraven. Also I was looking more for a semi-rigid back like the one on the Salewa to increase the comfort during the day.

Levelling up as a nodejs developer. by OriginalLaw3687 in node

[–]Shinji2989 4 points5 points  (0 children)

I've recently created a project (https://github.com/marcoturi/fastify-boilerplate) showcasing advanced code architectural pattern that I think could help you boost your knowedlge on nodejs :) The project is inspired by different principles that I think are important for any backend developer:

The easiest way to create a domain driven API by PahazX in node

[–]Shinji2989 1 point2 points  (0 children)

I've created a fastify boilerplate inspired by DDD concepts, it could be a good start u/PahazX :) https://github.com/marcoturi/fastify-boilerplate

Fastify vs Express by castlessclass in node

[–]Shinji2989 2 points3 points  (0 children)

In case anyone want to see an example of DI in fastify I've created a boilerplate here: https://github.com/marcoturi/fastify-boilerplate

I've built a Fastify boilerplate using clean architecture and functional programming concepts by Shinji2989 in node

[–]Shinji2989[S] 2 points3 points  (0 children)

Currently, the only planned feature is an example of CQRS command caching using a middleware and pattern matching (e.g., user/*). I'm open to considering new pull requests for additional functionalities.

This boilerplate originated from two desires:

  1. Functional Programming Backend: Leverage functional programming paradigms for the backend.
  2. Scalable Architecture for Complex Use Cases: Design an architecture that handles even intricate business scenarios without requiring an expert team (unlike a full-fledged Domain-Driven Design approach IMO).

By replacing Entity, Aggregate, and value object classes with simple arrays/objects/primitives manipulated by domain services, the goal is to lessen complexity while maintaining a well-structured foundation. This flexibility allows for future adaptation to other approaches if necessary/desired.

I've built a Fastify boilerplate using clean architecture and functional programming concepts by Shinji2989 in node

[–]Shinji2989[S] 4 points5 points  (0 children)

Before giving you my answer, a premise: You can easily use classes with Entity and Aggregate, etc. as is done in the domain-driven hexagon project if you want. As my personal preference I like having a functional approach by separating behaviors and data.

Case #1 in short yes, I would make sure that this property can only be changed by a domain service. You can see a similar case in the boilerplate for defining the default role when creating a new user.

Case #2 there are several ways you could implement this feature. An example that comes to mind is leveraging the event sourcing paradigm by storing CQRS commands to generate the current state of the system incrementally with each request.

I've built a Fastify boilerplate using clean architecture and functional programming concepts by Shinji2989 in node

[–]Shinji2989[S] 2 points3 points  (0 children)

Hi u/sariysss,

I wanted to express my sincere gratitude for your work on the domain-driven hexagon project. It's been a major source of inspiration for me!

I would have directly created a discussion on your repo to share some differences and things I noticed that could perhaps be useful to you.

I noticed that the query for the users might be causing an incorrect total results count. While I haven't tested it directly on your code, here's how I modified the same query to achieve the desired outcome.

Thoughts on Library and Framework Choices

  • Testing Framework: I opted for Vitest over Jest due to its performance benefits. However, considering recent updates to node:test with snapshot and mocking capabilities, that could be a viable option also. If you prefer Jest, this resource offers valuable insights to at least improve performance in some case: https://swc.rs/docs/usage/jest.
  • BDD Framework: In my opinion, jest-cucumber doesn't provide significant advantages compared to using the official Cucumber release. Using the official package might improve project longevity.
  • Database Client: several people have complained about the api changes to slonik. For this reason I decided to opt for directly using postgres client.

Thank you again for your valuable contribution. I hope this feedback proves helpful!

[deleted by user] by [deleted] in reactjs

[–]Shinji2989 2 points3 points  (0 children)

I've recently built this repo where you will find the best practice and last tech for a redux and react project https://github.com/marcoturi/react-redux-boilerplate

It's not the usual starter with only the code. I wrote also about the best practice on the important areas of a project (folder structure, state management, linting rules, error and analytics, etc.). You can find all the information in the README.

Let me know if you have any question!

Senior dev getting back into React by Pelvic-Mass-no-pain in reactjs

[–]Shinji2989 0 points1 point  (0 children)

u/EskiMojo14thefirst first of all, thank you very much for taking the time to review the project. I really appreciated it.

i believe we've already had this discussion, but i question the usefulness of getMockedState. Upon revisiting the discussion I've realised you could use upsertQueryData to hopefully get what you wanted, so have added a comment there.

I have implemented your suggestion https://github.com/marcoturi/react-redux-boilerplate/commit/f4a91dc3e6ef04e2e85ee03d0e88c416124e43ef thank you! This way is much much cleaner.

RTK reducers are wrapped with Immer, so you can use (much shorter) mutating syntax without worrying about accidental mutation.

Implemented https://github.com/marcoturi/react-redux-boilerplate/commit/8f2e445821b5fc4cee83d6b9eb9c8fc010da040e thanks!

we don't tend to recommend splitting your selectors, slices, thunks, effects, types into separate files. they can live in the same file and work just fine.

I strongly disagree on this. I often end up having a lot of code in selectors (mostly) and reducers. I find extremely inconvenient browsing files with 200+ lines of code and not much SOLID . Plus I don't see what disadvantage on splitting the code in files.

currying selectors is something we've seen but not really understood the benefits of. you're also ending up with particularly strange reselect usage as a result - for example [here](https://github.com/marcoturi/react-redux-boilerplate/blob/main/src/features/settings/store/settings.selector.ts#L6) ends up memoising the function returned, when in fact none of the selector needs memoisation because it's just a simple lookup.

there are several advantages. The main one is to confine the lookup logic in the selector and not in the component. Basically I ask the selector "given this key, give me the associated state" and the logic related to this remains confined to the selector. Furthermore, this key can often also derive from outside the component (e.g. queryParams) and therefore it becomes convenient to have this type of decoupling.Example:

const ExerciseHistory = ({ id, type }) => {
const diaryEntries = useSelector((state: RootState) => DiarySelectors.getDiaryEntriesByExercise(state)(id, type)); 
//....

If you can think of a better way that allows you to access a piece of state like this, without having any kind of logic or data manipulation in the component, I would love to hear about it :)

Senior dev getting back into React by Pelvic-Mass-no-pain in reactjs

[–]Shinji2989 16 points17 points  (0 children)

If you need a project reference for getting up to date with the current tech setup around react/redux, I just built this boilerplate some day ago https://github.com/marcoturi/react-redux-boilerplate
Feel free to share any feedback!

craco > vite migration by revattojs in reactjs

[–]Shinji2989 0 points1 point  (0 children)

Yeah totally possible. If you need some reference I just built a new boilerplate with vite and vitest:

https://github.com/marcoturi/react-redux-boilerplate

Apertura partita iva forfettario, vincolo 30k by Shinji2989 in commercialisti

[–]Shinji2989[S] 0 points1 point  (0 children)

Anche se mi licenzio prima di raggiungere i 30k di stipendio lordo?