## Required installer behaviour The installer must support installing: - one selected HealthApp service; - multiple selected services; - all HealthApp services on the same machine. Each application service must still run as an independent systemd service/process. ### PostgreSQL Where an installed service requires PostgreSQL persistence, the installer must: - detect whether PostgreSQL is already available; - install PostgreSQL when necessary on supported Linux distributions; - create the required database(s); - create dedicated database user credentials; - generate suitable passwords rather than using hard-coded credentials; - assign only the permissions required by the owning service; - configure the application service to use its database; - run any required database migrations. Patient Profile and Observation persistence must remain separately owned. Installing both services on the same PostgreSQL server is allowed, but they must use separate databases and service credentials. Services without persistence must not receive databases. ### Application/service credentials The installer must generate the credentials needed for communication between the deployed HealthApp services. Credentials must: - not be hard-coded in the repository; - be generated during installation; - be stored in files or configuration readable only by the appropriate service account/root where practical; - be configured automatically into the relevant services. The administrator should not have to manually invent and distribute inter-service credentials for a normal installation. ### HTTPS certificates The installer must configure HTTPS for the installed services. For the prototype, certificates do not need to be publicly trusted. The installer may generate a local/self-signed certificate or a small local certificate authority and issue certificates from it. The goal is encrypted HTTPS communication, not public PKI validation. The installer must: - generate the required certificate/key material if none is supplied; - configure each installed service to use HTTPS; - configure the relevant local trust relationships required for HealthApp services to communicate successfully; - protect private key material using appropriate filesystem permissions. It should remain possible to replace the generated prototype certificates with externally supplied trusted certificates later. ### Service configuration The installer must generate the configuration necessary for the selected deployment, including as applicable: - listening address; - HTTPS port; - URLs of dependent HealthApp services; - database connection strings; - database credentials; - inter-service credentials; - certificate paths; - environment-specific configuration. A normal installation must not require manually editing application configuration files after installation. ### Linux service installation For each selected HealthApp service, the installer must: - install/publish the application; - create the necessary service account where appropriate; - create its systemd unit; - enable the service; - start the service; - verify that it starts successfully. ### Verification At the end of installation, perform an installation verification that checks at minimum: - each selected systemd service is running; - each selected service is listening on its configured HTTPS endpoint; - required PostgreSQL databases are reachable; - service-to-service communication works for the installed topology; - representative application functionality works when the complete system is installed. If installation or verification fails, report clearly which step failed. ## Deployment principle The installer should make the selected topology work. For example: Machine A: - API Gateway - Patient Profile - Observation - Insights - Health Overview - PostgreSQL or: Machine A: - API Gateway Machine B: - Patient Profile - PostgreSQL Machine C: - Observation - PostgreSQL Machine D: - Insights Machine E: - Health Overview The application binaries and architectural boundaries must remain the same in either case. Do not require the administrator to manually create PostgreSQL databases, application credentials, or prototype HTTPS certificates as a prerequisite for installation.