How bhits/document-validator works
Project Type and Purpose
• Type: A standalone RESTful microservice (no UI) built on Spring Boot + external Tomcat, packaged as a WAR/Docker image.
• Purpose: Exposes a REST API for validating C32 and C-CDA clinical documents by invoking MDHT libraries, returning schema and schematron validation results. It is consumed by clients like the DSS (Document Segmentation Service).
Main Components
A. External Clients
– DSS or any HTTP client that submits a document for validation
B. Network/API Layer
– Spring MVC Controller (DocumentValidationController)
– REST endpoints under /document-validator context path
C. Business Logic Layer
– DocumentValidationService (service interface + impl)
– DocumentTypeResolver (identifies schema/CCDA version)
D. Infrastructure/Validation Engine
– CcdaValidator (interface + impl) wrapping MDHT libraries
– MDHT JARs (schema + schematron engines)
E. Configuration
– Spring Cloud Config Server (external)
– Local bootstrap.yml & application.yml
F. Application Server & Packaging
– Apache Tomcat 8 (external container)
– Docker image bhits/document-validator:latest
G. Deployment Artifacts
– WAR file document-validator.war
– Docker image, mounted SSL keystore & custom cacerts
H. Logging
– logback-spring.xml (for structured logs)
Relationships & Data Flows
1. Client → HTTP POST /validate
2. Controller invokes
→ DocumentValidationService
3. Service uses
→ DocumentTypeResolver to detect document type
→ CcdaValidator to perform MDHT validation
4. CcdaValidator loads MDHT schema + schematron rules, returns ValidationResponseDto
5. Controller returns HTTP response with ValidationResponseDto JSON
6. At startup, application fetches external config from Config Server (or falls back to local YML files)
7. Packaging path: source → Maven build → WAR → deploy to Tomcat OR Maven‐Docker plugin → Docker image
Architectural Patterns & Design Principles
• Layered (Controller → Service → Infrastructure)
• Dependency Injection via Spring Boot
• Externalized Configuration (Spring Cloud Config + bootstrap.yml)
• Adapter/Wrapper for MDHT libraries
• Dockerization for consistent deployment
• No persistent datastore—stateless service