chingu-x / chingu-dashboard

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

Refactor/hexagonal pattern poc v2 #235

Open Dan-Y-Ko opened 1 week ago

Dan-Y-Ko commented 1 week ago

hexagonal architecture updated

some notes:

I first changed it to follow this folder structure

application
domain
infrastructure

couple reasons why I didn't like this

so the change is what I like better

application
ports
adapters

One other issue I came into was properly implementing the primary port (the primary adapter). Ideally it'd be the service acting as the adapter but first problem is we can't use classes in next with server component / actions. The second issue was that I couldn't really get the transformation to work while also keeping the interface in the port intact. The only solution I could think of is to return the normal response (instead of async response) from the adapter / service and add another layer to do the response transformation but Idk if there's much benefit to this. Instead I just decided to have the usecase implement the port, which I don't think 100% aligns with the architecture but I think it's fine, given the restraints with the tech stack.

I couldn't get the tsyringe resolve to work in the component so I instantiated the classes manually.

btw, I didn't go over the changes in depth because I figured you'd know this already but if you need to me to go over it, I can

vercel[bot] commented 1 week 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 Sep 4, 2024 3:54am
Dan-Y-Ko commented 1 week ago

so one issue I saw. The cache and token isn't being enforced here. I am pushing a "solution" but it's not great because it's fragile. However, I'm not sure what else could be done....would be possible if classes were useable. But that also comes with an issue of adding more code