Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Package structure for projects

Ajay Divakaran edited this page Jul 28, 2017 · 2 revisions

Package structure for projects

Refer Hexagonal architecture for an introduction to this concept.

Package structure

  • domain
    • exception
    • model
    • service
  • persistence
    • dto
    • repository
    • entity
  • web
    • adapters
      • error
    • controller
    • contract
  • consumer
    • listener

Summary of the package structure

  • The domain package should have classes that are only responsible for domain logic. This layer is agnostic of web, data stores (PostGres, Redis) or messaging (Kafka).

  • The persistence package is responsible for adapting the domain models to data store specific representations and vice-versa. Interactions to other HTTP services via RestTemplate are also done using the Repository pattern. The dto package houses the request and response classes from upstream services.

  • The web package is responsible for adapting the domain models to web contract classes and vice-versa. Exceptions raised by the domain layer are transformed by error adapters to web contract specific error responses.

  • The listener package houses the Kafka listener.