Business Scenario -
1. I am required to develop
an application which requires user registration in which
- user id is verified by
an external system (LDAP based)
- loyalty cards are shown to the user on successful registration
2. Variations w.r.t user
registration are -
- User registration via mobile
app
- User registration via web application
- User registration via web application (UI) developed by some other vendor
Solution (as
per my understanding of 3 layered architecture) -
- Have 3 controllers for all the above 3 variations -
- Mobile App API Controller for catering to mobile app
based requests, having mobile specific header info viz. device
information, product version, app version etc
- Web
application Controller tightly coupled with the form (i.e. ModelAttribute
of Spring) as UI is owned by our system
- Web
application API Controller (as web UI is not owned by us) which will have
request parameters with headers specific to browser (i.e. without device
information, product version, app version etc)
- Each
of these controllers call common validation component and then convert the
request object to domain object which is then passed on to the
service/business layer for business workflow processing.
- After
business workflow processing, service/business layer passes domain object
to LDAP Adapter component which then converts domain object as per the
LDAP contract and sends it to LDAP system
- LDAP
on successful user verification, gets the loyalty cards associated with
the user from other backend system. LDAP Adapter converts loyalty card
data to domain object and then control returns to service / business layer
with domain object of loyalty cards. Thereafter service / business layer
passes user info domain object and loyalty card domain object to
repository for persisting in database.
- Repository
first converts both the domain object (i.e. user profile and loyalty
cards) to db entity (as per the underlying OR framework) and then persists
in to the database.
- On
successful creation of user profile and its related loyalty cards, control
returns from repository to service / business layer. Business layer then
returns to controller along with loyalty card domain object
- Respective
controller converts the loyalty card domain object to appropriate response
object as per the source of request i.e. either mobile app or web
application owned by our system or web application (UI) developed by some other vendor.
Query
Based on my limited understanding this implementation is not aligning
with clean architecture. Hence I would appreciate if clean code aficionados can
help me understand how can I achieve above solution in such a way that it
aligns with clean architecture principles using Entity - Boundary - Interactor
pattern?
Thanks in advance.