# mosip/resident-ui architecture

> Architecture diagram of the GitHub repository mosip/resident-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mosip/resident-ui
- Repository: https://github.com/mosip/resident-ui

## Overview

1. **Repository shape**
   - This repo is a **multi-part delivery** for the MOSIP Resident UI:
     - `resident-ui/` — the Angular single-page application.
     - `residenttest/` — a Java-based automated test rig for the UI flows.
     - `deploy/` and `helm/` — packaging and Kubernetes deployment assets.
   - The architecture is therefore split between **runtime UI**, **test automation**, and **cluster deployment**.

2. **Primary runtime: Angular SPA**
   - `resident-ui/` is the main product. It is a **client-side Angular app** built with Angular CLI, TypeScript, and npm.
   - It is packaged to run behind **Nginx** (`Dockerfile`, `nginx.conf`, `default.conf`, `download.conf`) rather than through a custom app server.

3. **Application shell and cross-cutting flow**
   - The app is organized around a central shell in `src/app/` with:
     - `app.module.ts`, `app-routing.module.ts`
     - global config and constants
     - HTTP interception and route protection
   - Core request flow goes through services like:
     - `httpinterceptor.ts` for API request/response handling
     - `authguard.service.ts`, `can-deactivate-guard.service.ts`
     - `authservice.service.ts`, `auto-logout.service.ts`, `logout.service.ts`
     - `config.service.ts` and `app-config.service.ts` for runtime configuration

4. **Feature boundary: resident self-service workflows**
   - The UI is divided into lazy-style feature areas under `src/app/feature/`, each representing a resident workflow:
     - `booking` — appointment/center selection, including map-based selection
     - `downloaduin` — download UIN
     - `getuin` — retrieve UIN
     - `verify` — verification flow
     - `document` — document-related interactions
     - `uinservices` — the main resident services hub
     - `dashboard` and `error`
   - Within `uinservices`, the functional sub-areas map directly to business capabilities:
     - update demographic data
     - lock/unlock authentication
     - revoke VID
     - share data with partner
     - track service requests
     - view history
     - personalised/physical card requests
     - grievance handling

5. **Shared UI and reusable components**
   - Common functionality is centralized in `src/app/shared/`:
     - `header`, `dialog`, `captcha`, `progress`, `pdf-viewer`
     - sanitization pipes and router helpers
     - a shared logger implementation
   - This indicates a **component-library-like boundary inside the app**, separating reusable UI behavior from workflow-specific screens.

6. **State and service model**
   - The app appears service-driven rather than heavily state-managed. Feature components mostly coordinate through Angular services and shared models:
     - `core/models` and `shared/models`
     - service classes in `core/services` and `feature/.../*.service.ts`
   - Data exchange is typed with request/response models, and feature screens are thin orchestration layers over backend APIs.

7. **Localization and runtime asset-driven behavior**
   - The UI is internationalized via `src/assets/i18n/*.json` with multiple languages.
   - Runtime behavior is also influenced by static assets such as:
     - `src/assets/config.json`
     - change-action scripts in `src/assets/changeActions/`
     - UI templates and icons/fonts
   - This suggests the app can be deployed with environment-specific configuration without rebuilding application logic.

8. **External dependencies implied by the UI**
   - The frontend is not self-contained; it is a client to external Resident/MOSIP platform APIs.
   - It also integrates with:
     - captcha handling
     - PDF rendering
     - authentication/session flows
     - map/center selection for bookings
   - The `assets/sharewithpartner.json` and identity spec files suggest document/schema-driven interactions with backend services.

9. **Container and Kubernetes packaging**
   - `resident-ui/Dockerfile` packages the compiled Angular app into an Nginx image.
   - `helm/resident-ui/` defines the Kubernetes deployment boundary with:
     - `deployment`, `service`, `ingress`, `gateway`, `virtualservice`, `hpa`, `configmap`, and service account templates
   - This points to deployment in a **service-mesh / ingress-based cluster environment**, not a standalone VM app.

10. **Operational deployment scripts**
   - `deploy/resident-ui/` contains install, delete, restart, and certificate-upload flow scripts.
   - `deploy/resident-uitestrig/` provides matching deployment scripts for the test rig.
   - These scripts are likely used for environment bootstrapping and operational refreshes alongside Helm.

11. **CI/CD and release handling**
   - `.github/workflows/` includes chart lint/publish, release-change, tag, and push-trigger workflows.
   - The repo is set up for **automated chart validation and release management**, with signed key material stored under `.github/keys/`.

12. **Automated test rig: separate Java system**
   - `residenttest/` is a distinct Java/Maven project, not part of the UI runtime.
   - It contains:
     - TestNG-based test cases for each resident flow
     - REST and authentication utilities
     - reporting, screenshots, and email/SMTP support
   - It behaves like an **integration test harness** that drives the Resident UI scenarios and validates end-to-end behavior.

13. **Test rig external integrations**
   - The Java test rig includes utilities for:
     - REST client calls
     - Keycloak user management
     - kernel authentication
     - S3 access
     - SMTP monitoring
     - report generation
   - This means the test architecture spans the UI plus supporting platform services, and is designed for realistic environment validation rather than isolated unit tests.

14. **Overall architecture diagram boundary**
   - The cleanest diagram for this repo should show:
     - **Browser user** → **Angular SPA served by Nginx**
     - SPA → **external Resident/MOSIP backend services**
     - SPA cross-cutting concerns: auth, captcha, localization, PDF, logging
     - **Helm/Kubernetes** as the deployment layer
     - **Java Test Rig** as a separate verification pipeline exercising the same workflows against deployed environments

Main entry points: [`resident-ui/src/app/app.module.ts`](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/app.module.ts) (App shell), [`resident-ui/src/main.ts`](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/main.ts) (Resident UI), [`helm/resident-ui/Chart.yaml`](https://github.com/mosip/resident-ui/blob/master/helm/resident-ui/Chart.yaml) (Helm chart), [`residenttest/pom.xml`](https://github.com/mosip/resident-ui/blob/master/residenttest/pom.xml) (UI test rig)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Resident UI runtime"]
  node_browser(("Browser user<br/>actor"))
  node_spa["Resident UI<br/>angular spa<br/>[main.ts]"]
  node_shell["App shell<br/>angular shell<br/>[app.module.ts]"]
  node_config["Runtime config<br/>app config"]
  node_coreflow["Core flow<br/>guards/interceptor<br/>[httpinterceptor.ts]"]
  node_sharedui["Shared UI<br/>shared components<br/>[shared.module.ts]"]
  node_i18n["Localization<br/>i18n assets<br/>[default.json]"]
  node_booking["Booking flow<br/>resident feature<br/>[booking.module.ts]"]
  node_uinhub["UIN services<br/>resident feature hub"]
  node_verify["Verify flow<br/>resident feature<br/>[verify.module.ts]"]
  node_documentf["Document flow<br/>resident feature<br/>[document.module.ts]"]
  node_downloaduin["Download UIN<br/>resident feature"]
  node_getuin["Get UIN<br/>resident feature<br/>[getuin.module.ts]"]
  node_dashboard["Dashboard<br/>feature screen"]
  node_backend[("Resident APIs<br/>external backend")]
end

subgraph group_testing["Test automation"]
  node_testrig["UI test rig<br/>java maven harness<br/>[pom.xml]"]
  node_cases["Test cases<br/>test scenarios"]
  node_testutils["Test utilities<br/>test support<br/>[TestRunner.java]"]
end

subgraph group_delivery["Delivery and deploy"]
  node_nginx["Nginx package<br/>container image"]
  node_helm["Helm chart<br/>kubernetes packaging<br/>[Chart.yaml]"]
  node_scripts["Deploy scripts<br/>ops scripts<br/>[install.sh]"]
  node_ci["GitHub Actions<br/>release automation"]
end

node_browser -->|"uses"| node_spa
node_spa -->|"bootstraps"| node_shell
node_shell -->|"reads"| node_config
node_shell -->|"routes via"| node_coreflow
node_shell -->|"renders"| node_sharedui
node_shell -->|"localizes"| node_i18n
node_shell -->|"loads"| node_booking
node_shell -->|"loads"| node_uinhub
node_shell -->|"loads"| node_verify
node_shell -->|"loads"| node_documentf
node_shell -->|"loads"| node_downloaduin
node_shell -->|"loads"| node_getuin
node_shell -->|"loads"| node_dashboard
node_coreflow -->|"calls"| node_backend
node_booking -->|"calls"| node_backend
node_uinhub -->|"calls"| node_backend
node_verify -->|"calls"| node_backend
node_documentf -->|"calls"| node_backend
node_downloaduin -->|"calls"| node_backend
node_getuin -->|"calls"| node_backend
node_nginx -->|"packages"| node_spa
node_helm -->|"deploys"| node_nginx
node_scripts -->|"operates"| node_helm
node_ci -->|"publishes"| node_helm
node_testrig -->|"contains"| node_cases
node_testrig -->|"uses"| node_testutils
node_cases -->|"exercises"| node_spa
node_testutils -->|"integrates"| node_backend

click node_spa "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/main.ts"
click node_shell "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/app.module.ts"
click node_config "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/app-config.service.ts"
click node_coreflow "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/core/services/httpinterceptor.ts"
click node_sharedui "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/shared/shared.module.ts"
click node_i18n "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/assets/i18n/default.json"
click node_booking "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/booking/booking.module.ts"
click node_uinhub "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/uinservices/uinservices-routing.module.ts"
click node_verify "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/verify/verify.module.ts"
click node_documentf "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/document/document.module.ts"
click node_downloaduin "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/downloaduin/downloaduin.module.ts"
click node_getuin "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/getuin/getuin.module.ts"
click node_dashboard "https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/dashboard/dashboard.module.ts"
click node_nginx "https://github.com/mosip/resident-ui/tree/master/resident-ui/Dockerfile"
click node_helm "https://github.com/mosip/resident-ui/blob/master/helm/resident-ui/Chart.yaml"
click node_scripts "https://github.com/mosip/resident-ui/blob/master/deploy/resident-ui/install.sh"
click node_ci "https://github.com/mosip/resident-ui/blob/master/.github/workflows/chart-lint-publish.yml"
click node_testrig "https://github.com/mosip/resident-ui/blob/master/residenttest/pom.xml"
click node_cases "https://github.com/mosip/resident-ui/blob/master/residenttest/src/main/java/io/mosip/testrig/residentui/testcase/BookinganAppointment.java"
click node_testutils "https://github.com/mosip/resident-ui/blob/master/residenttest/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_spa,node_shell,node_config,node_coreflow,node_sharedui,node_i18n,node_booking,node_uinhub,node_verify,node_documentf,node_downloaduin,node_getuin,node_dashboard,node_backend toneBlue
class node_testrig,node_cases,node_testutils toneAmber
class node_nginx,node_helm,node_scripts,node_ci toneMint
```

## Components

### Resident UI runtime

Angular SPA and its cross-cutting application layers

- **Browser user**: actor · Resident accessing the UI
- [Resident UI](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/main.ts): angular spa · Client-side application served by Nginx · `resident-ui/src/main.ts`
- [App shell](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/app.module.ts): angular shell · Top-level module and routing boundary · `resident-ui/src/app/app.module.ts`
- [Runtime config](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/app-config.service.ts): app config · App configuration and environment bootstrap · `resident-ui/src/app/app-config.service.ts`
- [Core flow](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/core/services/httpinterceptor.ts): guards/interceptor · Authentication, routing, logout, and HTTP interception · `resident-ui/src/app/core/services/httpinterceptor.ts`
- [Shared UI](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/shared/shared.module.ts): shared components · Reusable header, dialogs, captcha, progress, and PDF viewer · `resident-ui/src/app/shared/shared.module.ts`
- [Localization](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/assets/i18n/default.json): i18n assets · Language bundles and runtime text resources · `resident-ui/src/assets/i18n/default.json`
- [Booking flow](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/booking/booking.module.ts): resident feature · Appointment and center selection workflow · `resident-ui/src/app/feature/booking/booking.module.ts`
- [UIN services](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/uinservices/uinservices-routing.module.ts): resident feature hub · Main resident self-service entry and capability hub · `resident-ui/src/app/feature/uinservices/uinservices-routing.module.ts`
- [Verify flow](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/verify/verify.module.ts): resident feature · Verification workflow for resident data · `resident-ui/src/app/feature/verify/verify.module.ts`
- [Document flow](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/document/document.module.ts): resident feature · Document-related interactions · `resident-ui/src/app/feature/document/document.module.ts`
- [Download UIN](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/downloaduin/downloaduin.module.ts): resident feature · UIN download workflow · `resident-ui/src/app/feature/downloaduin/downloaduin.module.ts`
- [Get UIN](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/getuin/getuin.module.ts): resident feature · UIN retrieval workflow · `resident-ui/src/app/feature/getuin/getuin.module.ts`
- [Dashboard](https://github.com/mosip/resident-ui/blob/master/resident-ui/src/app/feature/dashboard/dashboard.module.ts): feature screen · Landing and summary view · `resident-ui/src/app/feature/dashboard/dashboard.module.ts`
- **Resident APIs**: external backend · MOSIP resident and identity services consumed by the SPA

### Test automation

Separate Java harness that exercises resident workflows end to end

- [UI test rig](https://github.com/mosip/resident-ui/blob/master/residenttest/pom.xml): java maven harness · Separate Java project for resident UI end-to-end validation · `residenttest/pom.xml`
- [Test cases](https://github.com/mosip/resident-ui/blob/master/residenttest/src/main/java/io/mosip/testrig/residentui/testcase/BookinganAppointment.java): test scenarios · Resident workflow scenarios such as booking, login, update, and history · `residenttest/src/main/java/io/mosip/testrig/residentui/testcase/BookinganAppointment.java`
- [Test utilities](https://github.com/mosip/resident-ui/blob/master/residenttest/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java): test support · REST, auth, reporting, screenshots, SMTP, and environment helpers · `residenttest/src/main/java/io/mosip/testrig/residentui/utility/TestRunner.java`

### Delivery and deploy

Container, Helm, and operational deployment assets

- [Nginx package](https://github.com/mosip/resident-ui/tree/master/resident-ui/Dockerfile): container image · Static SPA hosting and reverse-proxy packaging · `resident-ui/Dockerfile`
- [Helm chart](https://github.com/mosip/resident-ui/blob/master/helm/resident-ui/Chart.yaml): kubernetes packaging · Deployment, service, ingress, gateway, and virtual service templates · `helm/resident-ui/Chart.yaml`
- [Deploy scripts](https://github.com/mosip/resident-ui/blob/master/deploy/resident-ui/install.sh): ops scripts · Install, delete, restart, and certificate upload flows · `deploy/resident-ui/install.sh`
- [GitHub Actions](https://github.com/mosip/resident-ui/blob/master/.github/workflows/chart-lint-publish.yml): release automation · Chart linting, tagging, and release workflows · `.github/workflows/chart-lint-publish.yml`

## Connections

- Browser user → Resident UI: uses · Residents interact with the SPA in the browser
- Resident UI → App shell: bootstraps · Angular entry point loads the application shell
- App shell → Runtime config: reads · Shell initializes runtime configuration
- App shell → Core flow: routes via · Routing, guards, auth, and HTTP interception shape every request
- App shell → Shared UI: renders · Shell and features reuse common UI building blocks
- App shell → Localization: localizes · UI text comes from language bundles
- App shell → Booking flow: loads · Booking is a lazy feature area
- App shell → UIN services: loads · Resident services hub is a central feature area
- App shell → Verify flow: loads · Verification is a feature boundary
- App shell → Document flow: loads · Document interactions are isolated as a feature
- App shell → Download UIN: loads · Download UIN is a dedicated flow
- App shell → Get UIN: loads · UIN retrieval is a dedicated flow
- App shell → Dashboard: loads · Dashboard provides an entry view
- Core flow → Resident APIs: calls · Services and interceptor exchange data with resident backend APIs
- Booking flow → Resident APIs: calls · Booking workflow fetches and submits appointments and center data
- UIN services → Resident APIs: calls · Resident self-service actions are API-driven
- Verify flow → Resident APIs: calls · Verification flow queries backend identity data
- Document flow → Resident APIs: calls · Document interactions rely on platform services
- Download UIN → Resident APIs: calls · Download flow retrieves identity artifacts from services
- Get UIN → Resident APIs: calls · Retrieval flow depends on backend lookup services
- Nginx package → Resident UI: packages · Compiled Angular app is served through Nginx
- Helm chart → Nginx package: deploys · Kubernetes chart deploys the containerized UI
- Deploy scripts → Helm chart: operates · Scripts install, restart, and manage release assets
- GitHub Actions → Helm chart: publishes · Automation validates and releases the chart
- UI test rig → Test cases: contains · Maven test project organizes resident scenarios
- UI test rig → Test utilities: uses · Shared utilities support execution, reporting, and environment setup
- Test cases → Resident UI: exercises · Scenarios drive the deployed Resident UI
- Test utilities → Resident APIs: integrates · Harness also reaches surrounding platform services and auth systems
