Skip to content

Code structure

Yoom Lam edited this page Oct 20, 2022 · 15 revisions

Open this project in an IDE, like IntelliJ.

Initial things to review

Gradle Subproject Dependencies

Based on build.gradle files in each directory, here's the rough subproject dependencies (based on PR #50):

  • app - main @SpringBootApplication
    • api - annotated API, used to populate OpenAPI doc; defines request and response POJOs
    • controller - defines @RestController classes (which implement api classes) and @Mapper classes (which convert service.model objects from/to request/response POJOs)
      • api
      • service:provider
      • service:spi
    • persistence:model - defines DB @Entity classes and DB query methods (the implementation of which is in persistence:impl)
    • persistence:impl - implements DB Repository interfaces
      • persistence:model
    • service:provider - implements service:spi; persists service.model objects to/from DB using @Entity classes
      • persistence:model
      • service:spi - used by controllers
      • tests-data-factory - provides factories used in tests
    • service:spi

service-ruby subproject

UPDATE: has since been removed

Added in PR #63 as a separate container for Ruby services from the RRD prototype. Contains the code for the abd_vro-service-ruby package (container image).

Gradle projects

List the microservices (which each have an associated Gradle project):

  • 2 python assessors
  • 1 python pdf generator
  • 1 Java client for LH API svc-lighthouse-api
  • 1 Java client for MAS API svc-mas-api (in development)

Since the Python microservices have common code, it is extracted into a shared library:

  • service-python/main-consumer.py

And we have our big services:

  • Postgres + db-init
  • RabbitMQ
  • Redis

Plus we have our MVC layers initially set up by LH Starterkit:

  • api defining VRO's API
  • controller for the API
  • persistence:model defining DB Entity classes
  • service:db for DB interactions
  • service:spi containing Java interface and model definitions
  • service:provider containing Camel configurations

A shared folder where code for common (Java) libraries can be placed (so that the top-level directory isn't more cluttered):

MVC layers

There are tests in LayeredArchitectureTest to check for undesirable dependencies:

Rule 'Layered architecture consisting of
layer 'API' ('gov.va.starter.example..api..')
layer 'API-Requests' ('gov.va.starter.example..api..requests..')
layer 'API-Responses' ('gov.va.starter.example..api..responses..')
layer 'Controllers' ('gov.va.starter.example..controller..')
layer 'SPI' ('gov.va.starter.example..service.spi..')
layer 'Services' ('gov.va.starter.example..service.provider..')
layer 'Persistence' ('gov.va.starter.example..persistence..')
where layer 'API' may only be accessed by layers ['Controllers']
where layer 'API-Requests' may only be accessed by layers ['Controllers', 'API']
where layer 'API-Responses' may only be accessed by layers ['Controllers', 'API']
where layer 'Controllers' may not be accessed by any layer
where layer 'SPI' may only be accessed by layers ['Controllers', 'Services']
where layer 'Persistence' may only be accessed by layers ['Services']'

For more description, check out LHDI's doc on project structure.

Clone this wiki locally