Skip to content

Conversation

@timothyrusso
Copy link
Contributor

@timothyrusso timothyrusso commented Aug 22, 2024

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:

  • Service: Contains API calls where necessary.
  • Repository: Handles data modeling and adapts the services when needed.
  • Use Cases: Retrieve services or repositories and encapsulate client-specific logic.

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:

  • Added a unified API client to handle API requests.
  • Implemented a new IdeationService using TypeScript exclusively.
  • Created client use cases for interacting with the ideation API.

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@timothyrusso timothyrusso requested a review from Dan-Y-Ko as a code owner August 22, 2024 07:17
@vercel
Copy link

vercel bot commented Aug 22, 2024

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

@timothyrusso timothyrusso changed the title Feature/exagonal pattern poc Feature/exagonal-pattern-poc Aug 22, 2024
@Dan-Y-Ko
Copy link
Contributor

Dan-Y-Ko commented Aug 31, 2024

I went ahead and made a draft pr with some (that ended up being a lot of) changes. #235

@Dan-Y-Ko Dan-Y-Ko marked this pull request as draft October 23, 2024 23:21
@Dan-Y-Ko Dan-Y-Ko closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants