Case study · National government

Digital public services and AI integration

Alongside the e-money platform, I delivered a series of focused government systems covering health data, citizen services, embassy and consular services and passports. Most recently I added AI to an existing government service.

  • 22Mcitizens served
  • 71%of transactions online, up from 18%
  • 10 dayspassport processing, down from 6 weeks
  • 94%AI assistant accuracy on 1,500 questions

Challenge

  • Each agency ran its own legacy systems, paper steps and data silos, so citizens repeated the same information many times.
  • The data was some of the most sensitive a state holds (health, identity, travel), with strict privacy and residency rules.
  • Services had to work for citizens at home and abroad, often on low-end phones and slow connections.

What I built

  • Health data: interoperable record exchange between facilities using HL7 FHIR, with consent controls and role-based access.
  • Citizen services: a shared API layer and single sign-on so agencies could expose services online with less duplicated work.
  • Embassy and consular: appointment booking, case tracking and document workflows for citizens abroad.
  • Passports: application, payment, biometric capture integration and status tracking, linked to national identity records.
  • AI integration: a retrieval-augmented assistant over official policy and service documents, with source citations, guardrails, human review for sensitive cases, and evaluation before release.

Stack

Java/Spring Boot, Python, Node.js/TypeScript, PostgreSQL, MongoDB, Redis, Kafka, Keycloak, HL7 FHIR, Kubernetes, government cloud and on-premises, LLM APIs and open-weight models, pgvector, LlamaIndex, Terraform.

System design

All services share an identity and API platform, so each new service only has to build its own workflow.

All services share an identity and API platformOpenID Connect tokensKafkaCitizensKeycloaksingle sign-onCivil servantsNational identity registryShared gatewayauthentication, rate limits,request loggingHealth dataHAPI FHIR serverEmbassy and consularNode.js/TypeScript, RedisPassportsSpring Boot, MongoDB,PostgreSQLAI assistantLlamaIndex, pgvectorOpen-weight model hostedon premisesAPI model

Shared platform

  1. Identity: Keycloak provides single sign-on. Citizens sign in through one realm, with accounts verified against the national identity registry; civil servants use a separate realm with multi-factor authentication. Services receive OpenID Connect tokens and never handle passwords.
  2. API layer: a shared gateway handles authentication, rate limits and request logging for every agency's REST APIs. Kafka carries events between agencies, so for example a passport being issued updates the matching consular case without the two systems calling each other directly.
  3. Hosting: Kubernetes clusters run in government cloud, with health and identity data kept in on-premises data centres to meet residency rules. Terraform defines both environments.

Service designs

  1. Health data: a HAPI FHIR server (Java) stores standard resources such as Patient, Encounter and Observation. Adapters translate each facility's system into FHIR, and a master patient index matches the same person across facilities. Every read checks the patient's consent record and is written to an access log.
  2. Embassy and consular: a Node.js/TypeScript service handles booking, holding each appointment slot briefly in Redis so two people cannot take it. Cases move through set states, uploaded documents are virus-scanned before storage, and pages are kept light for slow connections abroad.
  3. Passports: a Spring Boot workflow runs application, payment, appointment, biometric capture, identity check, printing and collection. Application forms are stored in MongoDB because their fields vary by case, while workflow state lives in PostgreSQL. Enrolment stations capture photos and fingerprints to ICAO standards, and each applicant is checked against the national registry before printing.
  4. AI assistant:
    • Ingestion: a Python pipeline (LlamaIndex) splits official policy and service documents into sections, creates embeddings and stores them in pgvector with the document, section and effective date.
    • Answering: each question runs a combined vector and keyword search, the best passages are re-ranked, and the model answers only from those passages, with citations. With no supporting passage, it says so and offers a human contact.
    • Guardrails: personal data is removed before any model call. Questions involving personal cases go to an open-weight model hosted on premises, and public-information questions may use an API model. Sensitive topics route to staff.
    • Evaluation: the 1,500-question set runs on every change, and a release ships only if accuracy holds.

Results

  • Scope: 9 systems delivered across 6 agencies
  • Citizens served: 22M, with the online share of transactions up from 18% to 71%
  • Passports: processing time from 6 weeks down to 10 days
  • Consular requests: from 21 days down to 4 days
  • AI assistant: 78% of queries resolved without escalation, 94% accuracy on a 1,500-question evaluation set
Back to Work & Research