chingu-x / chingu-dashboard

https://chingu-dashboard.vercel.app
GNU General Public License v3.0
9 stars 2 forks source link

Feature/exagonal-pattern-poc #204

Open timothyrusso opened 2 months ago

timothyrusso commented 2 months ago

Description

🚨----WORK IN PROGRESS----🚨

This pull request introduces a variation of the hexagonal architecture, starting with the IdeationService.

image

The core logic is structured as follows:

The primary idea is that everything within the module should be reusable across different TypeScript-based applications, except for the usecases folder, which contains client-specific logic. The goal is to create a separate package that will contain the Modules folder, while the usecases folder will remain within the client application.

The aim is to encapsulate business logic within the modules, with the client application utilizing only the use cases.

For the IdeationService:

There are two ways to use the use cases within the application.

Server components:

import resolveInjection from '@di/resolveInjection';

export const ServerComponent = async () => {

const { ExampleUseCase } = resolveInjection();

const result = await ExampleUseCase().execute()

return { result }
}

Client components:

import useInjection from '@hooks/useInjection';

export const ClientComponent = () => {

const { ExampleUseCase } = useInjection();

useEffect(() => {
ExampleUseCase().execute()
}, [])
}

Feel free to comment or suggest any modifications/improvements.

This is a proof of concept and will be modified before merged.

Issue link

Fixes # (issue)

Type of change

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
chingu-dashboard βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Aug 22, 2024 7:40am
Dan-Y-Ko commented 2 months ago

I went ahead and made a draft pr with some (that ended up being a lot of) changes. https://github.com/chingu-x/chingu-dashboard/pull/235