How ministryofjustice/laa-ccms-data-api works
Project Type and Purpose
• This is a backend API microservice split into two Gradle subprojects:
– data‑api: a thin layer generated from an OpenAPI spec (YAML) containing request/response models and interface stubs.
– data‑service: a Spring‑Boot application that implements those interfaces, providing controllers, services, repositories, mappers and JPA entities to talk to an Oracle (or H2 for tests) database.
• It is packaged into a Docker image, deployed to Kubernetes via the kubectl_deploy manifests, and has CI/CD pipelines in GitHub Actions that run builds, tests, Snyk scans, and deployments.
High‑Level File Structure & Architectural Patterns
– Top‑level modules:
• data‑api: holds the OpenAPI spec and generated code
• data‑service: holds the Spring‑Boot application
– Typical layered architecture in data‑service:
• controller layer (uk.gov.laa.ccms.data.controller)
• service layer (uk.gov.laa.ccms.data.service)
• data access layer:
· repository interfaces (JPA/EntityManager)
· mappers (MapStruct or manual XML mappers)
· entity classes (JPA @Entity)
– Configuration & Infra:
• application.yml variants, Dockerfile, Kubernetes manifests (kubectl_deploy/)
• CI/CD config (.github/workflows, .snyk)
Key Insights from README
– data‑api is auto‑generated; keep open-api-specification.yml in sync
– data‑service implements the generated interfaces
– Uses common Spring Boot plugins & starters from the LAA CCMS common library
– CI/CD runs Snyk scans on main and feature branches
Components & Their Relationships
A. External Client(s): Postman, front‑end apps, other services
↓ invoke
B. API Interface Layer (data‑api stub):
• Exposes REST endpoints as defined in open-api-specification.yml
• Models (DTOs) and interface definitions
↓ invokes
C. Core Application (data‑service):
1. Controllers map HTTP requests to service calls
2. Services contain business logic and orchestrate data access
3. Mappers convert between entity and DTO models
4. Repositories talk to the database via JPA/Hibernate or raw SQL
↓ persists/queries
D. Database: Oracle (production), H2 (integration tests)
E. CI/CD & Infra:
• GitHub Actions: build/test, Snyk scan, deploy to Kubernetes
• Dockerfile: builds the service image
• Kubernetes: ingress + service definitions