How corona-warn-app/cwa-server works
1. Overall shape
This repository is a multi-module Maven backend for the Corona-Warn-App. It is not a single service; it contains several independently deployable Spring Boot services plus shared libraries and protocol definitions. The main runtime boundary is between the API-facing services and the shared infrastructure they all use: PostgreSQL, S3-compatible object storage, and external federation/verification services.
2. Top-level shared layers
The common/ modules hold reusable building blocks:
- common/persistence contains the shared domain model, repositories, services, validation, and Flyway migrations for PostgreSQL.
- common/protocols contains protobuf schemas for the binary payloads exchanged or published by services.
- common/federation contains shared HTTP clients and config for federation gateway interactions.
- common/shared provides utility code, and common/jupiterHelpers provides test support.
These modules are the main cohesion point across services and define most of the cross-service data contracts.
3. Submission service
services/submission exposes the user/device-facing submission API. Its job is to accept diagnosis submissions and event/check-in data, validate and normalize payloads, verify TANs or OTPs, and persist accepted data into PostgreSQL. It also contains monitoring and health indicators. Architecturally, it is an ingress service: request validation and verification happen before data reaches the shared persistence layer.
4. Submission data flow
Submission requests flow through controller and validation layers, then into domain-specific check-in logic and verification components. The service depends on:
- PostgreSQL for storing submissions and related state
- external verification services for TAN/SRS verification
- shared persistence services for normalization and database access
This service is stateful because it writes submission records and monitoring counters.
5. Download service
services/download is the federation intake processor. It pulls batches from the federation gateway, normalizes keys, applies retention and filtering rules, and persists downloaded federation data. It is batch-oriented and designed around a processing pipeline rather than synchronous user requests. It also contains logic to switch download strategies over time, including callback-based versus date-based downloads.
6. Download data flow
The download flow starts with fetching federation batches from external gateways via the shared federation client layer. The service then:
- audits or processes the batch
- normalizes federation keys
- filters by validity/retention policy
- stores results in PostgreSQL
This service acts as the consumer side of the federation exchange and is sensitive to batch lifecycle and error handling.
7. Upload service
services/upload prepares diagnosis key batches for federation upload. It reads diagnosis keys from persistence, assembles batches, signs payloads, and sends them through a federation upload client. It also includes test-data upload paths for different federation targets. This service is the producer side of the federation exchange.
8. Upload data flow
The upload pipeline is: read diagnosis keys from the database, batch and transform them, sign the output, and call the federation upload endpoint. The service uses separate client implementations for production and test modes. Its core architectural boundary is between database-backed key selection and outbound federation publishing.
9. Distribution service
services/distribution is the most complex service. It assembles and publishes downloadable artifacts for apps and backend consumers. It produces structured archives and files such as:
- exposure app configuration
- diagnosis key packages
- trace time interval warnings
- DCC revocation data
- statistics and local statistics
- digital certificate and rule data
The service is largely a build-and-publish engine: it aggregates data from internal files, databases, and external sources, then publishes signed artifacts.
10. Distribution assembly model
Distribution is organized around “structure providers,” “builders,” and “decorators.” These layers create directory/file/archive layouts on disk, add checksums and signatures, and then hand the resulting artifacts to publishing. This makes the service diagram materially different from a request/response web service: the main object is a generated artifact tree, not a live API response.
11. External content sources used by distribution
Distribution integrates with several external sources and domains:
- DCC business rules, value sets, and signing certificate/trust list services
- object storage for publishing artifacts
- PostgreSQL for some persisted metadata and retention-related data
- cryptographic signing infrastructure via a vault/private key
It also contains parsers/validators for YAML, JSON, protobuf, and CBOR-like mappings, reflecting its role as a content assembly and verification service.
12. Callback service
services/callback handles federation callback registration and delivery. It is an HTTP service that coordinates callback-related state and validation, including certificate checks and registration workflows. It is smaller than the distribution service but important as an integration endpoint for federation processes.
13. Shared persistence and database boundary
PostgreSQL is the primary durable store across the backend. The shared persistence module defines most tables and repositories for diagnosis keys, federation batches, revocation entries, statistics, trace warnings, and check-in protected reports. Flyway migrations live under common/persistence/src/main/resources/db/migration and service-specific test migrations appear in each service. This means the database schema is a shared architectural boundary, not service-local storage.
14. Object storage boundary
The distribution service publishes artifacts to an S3-compatible object store, and the repository includes local test secrets and docker-compose support for Zenko CloudServer. In the architecture diagram, this object store is the public artifact distribution layer: services write generated files there, and downstream consumers retrieve them from there rather than directly from the services.
15. Protocol and artifact contracts
The protobuf definitions in common/protocols are central to the backend’s binary content model. They define the shapes of app configuration, exposure parameters, statistics, DGC-related data, and other published payloads. For a diagram, this module should be shown as a shared contract layer between producers like distribution and consumers such as mobile apps or downstream services.
16. Build, packaging, and operational model
The repository is built with Maven and deployed as separate Spring Boot applications, each with its own Dockerfile and environment-specific profiles. The included GitHub Actions workflows indicate static analysis, security, license, and Maven build checks. Operationally, the services are designed to run in a docker-compose-based local stack with PostgreSQL and S3 storage, while production deployments rely on externalized configuration and signing secrets.
Main entry points: pom.xml Root build · persistence Persistence · submission Submission · distribution Distribution
Components 24
Shared modules
Reusable contracts, persistence, and utilities shared by multiple services.
- Root build · Aggregates the repository into shared modules and deployable services.
pom.xml - Persistence · Shared PostgreSQL domain model, repositories, services, and Flyway migrations.
common/persistence - Protocols · Binary payload definitions shared across services and downstream consumers.
common/protocols - Federation client · Reusable federation gateway clients, config, and hostname handling.
common/federation - Shared utils · General-purpose helpers for IO, security, serialization, and functional patterns.
common/shared - JUnit helpers · Reusable test-time JUnit extensions and conditions.
common/jupiterHelpers
Runtime services
Deployable Spring Boot applications that handle submission, federation, and publication workflows.
- Submission · Accepts diagnosis submissions and check-ins, validates payloads, verifies TAN/OTP, and persists accepted data.
services/submission - Submission API · Controller and exception boundary for incoming submissions.
services/submission/src/main/java/app/coronawarn/server/services/submission/controller - Verification · Verifies TANs and SRS OTPs via external verification services.
services/submission/src/main/java/app/coronawarn/server/services/submission/verification - Check-ins · Validates and filters event/check-in data before persistence.
services/submission/src/main/java/app/coronawarn/server/services/submission/checkins - Download · Fetches federation batches, normalizes keys, applies retention rules, and stores results.
services/download - Download pipeline · Coordinates batch fetch, audit, normalization, filtering, and persistence.
services/download/src/main/java/app/coronawarn/server/services/download - Upload · Reads diagnosis keys, assembles signed batches, and publishes them to federation targets.
services/upload - Upload payload · Selects keys, builds batches, and signs upload payloads.
services/upload/src/main/java/app/coronawarn/server/services/federation/upload/payload - Distribution · Builds and publishes signed downloadable artifacts for apps and backend consumers.
services/distribution - Assembly · Structure providers, builders, and decorators that create archive/file layouts.
services/distribution/src/main/java/app/coronawarn/server/services/distribution/assembly - Data sources · Fetches business rules, DCC data, statistics inputs, and other source content.
services/distribution/src/main/java/app/coronawarn/server/services/distribution/dgc - Object store · Publishes generated artifacts to S3-compatible storage with retention handling.
services/distribution/src/main/java/app/coronawarn/server/services/distribution/objectstore - Callback · Handles federation callback registration, delivery coordination, and certificate validation.
services/callback
External systems
Durable stores and third-party services the backend integrates with.
- PostgreSQL · Shared relational database for submissions, batches, statistics, and metadata.
- Federation gateway · Upstream/downstream federation endpoint used by download and upload flows.
- Verification svc · External TAN/SRS verification and related redemption services.
- DCC sources · Business-rule, certificate, trust-list, and value-set providers consumed by distribution.
- S3 storage · S3-compatible object store used as the public distribution layer for generated files.
Connections 31
- Root build → Persistence: builds · Root Maven build includes shared persistence module.
- Root build → Protocols: builds · Root Maven build includes protobuf contracts.
- Root build → Federation client: builds · Root Maven build includes shared federation client module.
- Root build → Shared utils: builds · Root Maven build includes common utility module.
- Root build → Submission: builds · Root Maven build includes submission service.
- Root build → Download: builds · Root Maven build includes download service.
- Root build → Upload: builds · Root Maven build includes upload service.
- Root build → Distribution: builds · Root Maven build includes distribution service.
- Root build → Callback: builds · Root Maven build includes callback service.
- Submission → Submission API: serves · Exposes HTTP submission endpoints.
- Submission → Check-ins: validates · Processes and normalizes check-in payloads.
- Submission → Verification: verifies · Delegates TAN and OTP verification.
- Submission → Persistence: writes · Stores accepted submissions through shared persistence.
- Submission → Verification svc: calls · Uses external verification/redemption services.
- Download → Download pipeline: runs · Batch download service is centered on a processing pipeline.
- Download → Federation client: uses · Fetches batches via shared federation client layer.
- Download → Persistence: stores · Persists downloaded federation data and batch state.
- Upload → Upload payload: assembles · Builds signed upload payloads from persisted keys.
- Upload → Persistence: reads · Reads diagnosis keys and upload metadata from shared persistence.
- Upload → Federation client: publishes · Sends upload batches through federation clients.
- Distribution → Assembly: builds · Generates archive and file structures.
- Distribution → Data sources: fetches · Consumes DCC rules, certificates, statistics, and related content.
- Distribution → Object store: publishes · Writes signed artifacts to object storage.
- Distribution → Persistence: reads · Uses persisted metadata and retention-related data.
- Distribution → Protocols: emits · Produces protobuf-shaped published payloads.
- Data sources → DCC sources: integrates · Loads business rules, trust lists, and value sets from external DCC systems.
- Object store → S3 storage: stores · Publishes artifacts into S3-compatible storage.
- Callback → Federation client: uses · Coordinates federation callback interactions.
- Callback → Persistence: stores · Persists callback registration and related state.
- Persistence → PostgreSQL: targets · Shared persistence layer is backed by PostgreSQL.
- Federation client → Federation gateway: calls · Shared client talks to federation gateway endpoints.