🖥️Architecture Overview
SPICE is a modular, service-based health platform. Frontline health workers capture clinical data on a mobile app that works without connectivity. Administrators configure the platform through a web portal. Backend services store clinical data as standard FHIR resources. A reporting and analytics pipeline turns that data into reports and dashboards.
This page gives the big picture. The detailed pages are:
System context, containers and key components, with diagrams
How clinical data is modelled and stored as FHIR, and which standards SPICE uses
How the mobile app works offline and synchronises with the backend
Authentication, authorisation, roles and data protection
Languages, frameworks and data stores by layer
Architecture at a glance

The diagram shows the capabilities of the platform and the services that provide them. Service and database interactions are simplified. The System Architecture (C4) page has the detailed views.
Platform components
Mobile app
Native Android application
Used by health workers in the field and at facilities to register households and members, screen, assess, prescribe and follow up. Stores data in an encrypted local database and synchronises in the background.
Admin web portal
Single-page web application
Used by administrators to manage the organisation and geography hierarchy, facilities, users and roles, clinical metadata (medications, lab tests) and workflow configuration.
Reporting web app
Single-page web application
Used by programme and facility managers to browse, filter and download reports.
Backend services
Java microservices
REST APIs for authentication and users, administration, clinical workflows, offline synchronisation, notifications, facility registry and report queries.
FHIR mapper and FHIR server
Java services
Translate the platform's clinical data into FHIR R4 resources and store them in a FHIR server (HAPI FHIR JPA server).
Reporting and analytics pipeline
Python ETL plus an optional data platform
Flattens clinical and administrative data into reporting schemas, and optionally feeds a larger analytics stack (orchestration, batch processing, query engine, dashboards).
How the components fit together
Clients never talk to a service's database directly. The mobile app and both web applications call the backend over HTTPS through a reverse proxy or API gateway, which routes each request to the right service.
Sign-in and users. The authentication service issues tokens after sign-in. The user service owns users, roles and organisations. Every other service validates the caller's token and applies role-based access to the request.
Administration. The admin portal calls the admin service, which manages the geographic and facility hierarchy, programmes, clinical workflows, medication and lab-test catalogues and customisation settings. The mobile app downloads this configuration and uses it to drive screens and forms.
Clinical data capture. The mobile app records each action in its local database first. The offline sync service receives the app's uploads, processes them asynchronously through a message queue, and calls the clinical workflow service (called the SPICE service in the code base) and other services to apply them. It also assembles the data the app downloads when it syncs. The clinical workflow service validates records, applies business rules such as risk calculation, and stores the operational record in PostgreSQL. It then calls the FHIR mapper, which converts the record into FHIR R4 resources and writes them to the FHIR server, the clinical store of record.
Notifications. The notification service sends SMS and email through configurable external providers, for example to users and to patients.
Reporting. The reporting ETL runs as a scheduled batch job. It reads administrative data from the platform database and clinical data from the FHIR database, and writes flat, denormalised reporting tables to a reporting database. The facility registry and report service queries that database and serves the reporting web app. Organisations that need larger-scale analytics can feed the same data into the optional analytics stack.
Supporting infrastructure is deliberately small: PostgreSQL databases, a Redis cache, a message queue (RabbitMQ) for asynchronous offline-sync work, and object storage for files.
Deployment flexibility
Cloud or on-premise. Nothing in the platform requires a specific cloud provider. Every runtime dependency (PostgreSQL, Redis, RabbitMQ, object storage, an SMTP or HTTP SMS gateway) can be self-hosted or consumed as a managed service.
Containers. Each backend service, the web applications and the ETL job are built as container images. They can run under Docker Compose for small or single-host installations, or under a container orchestrator such as Kubernetes for larger ones. The FHIR server ships with Helm charts.
Independent scaling. Each service is a separate deployable unit, so heavily used services (for example the offline sync service) can be sized separately from the rest.
Optional pieces. The analytics stack, the clinical decision-support (CQL) service and the notification providers are optional and can be left out of a minimal installation.
See the Deployment Guide for installation instructions.
Design principles
Offline-first
The mobile app is fully usable without connectivity. Reads and writes go to an encrypted on-device database, and a background worker synchronises when a network is available. See Offline Sync.
FHIR-based clinical store
Clinical data is persisted as HL7 FHIR R4 resources in a standards-compliant server, so it can be exchanged with other health systems. See FHIR and Standards.
Role-based access
Users are assigned roles and are scoped to the organisation, geographic areas or facilities they work in. Services enforce this on every request. See Security and Authentication.
Configurable workflows
Programmes, clinical workflows, forms, medication and lab-test catalogues and regional customisations are configured through the admin portal and the admin service, not hard-coded per deployment. The mobile app builds assessment forms from configuration.
Service-oriented
Each business capability is its own service with its own responsibility, communicating over REST (and a queue where work is asynchronous), with a shared library for common code.
Separation of transactional and reporting workloads
Reports are served from a separate reporting database populated by batch ETL, so analytical queries do not load the transactional systems.
Last updated