HackSoftware / Django-Styleguide

Django styleguide used in HackSoft projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where to store interfaces/adapters/ports?

skonik opened this issue · comments

Hey

I would like to discuss if you have any thoughts on where to store interfaces/adapters. Let's say you have notification system used in your services. You know that you might change it from expo push API to firebase push API. You have written an interface for that(abstract push notification client). Where would you put abstract and concrete classes of push notification client? Is it good idea to store it inside services or maybe in another place? What would you say?

You have really good styleguide, btw.

@skonik hello 👋

The service layer might not be a good place for what you are describing.

I'd do the following:

  1. If your abstraction around interfaces has nothing to do with any parts of Django - I'll isolate it in a module somewhere. We usually have an integrations app, so I'd do something like integrations/notifications/ and then have the Python implementation there (depending on how you like to structure your Python modules. The simplest would be to place it in __init__.py)
  2. If your notifications are dealing with the ORM, you might want to have a different Django app called notifications/ and put everything there.
    • You might want to have a service layer as the main interface & then call something from the Python module.

That's my take for now.

If you have some codesnippets & more examples, I might be able to be more helpful ✨

I think that's all what I wanted to hear. Thank you!