HR Portal · Technical Architecture

Architecture, Data Flow & the AI–PII Sandbox

How the system is built: a cost-aware sync off your existing HRIQ–to–Excel extraction, a Python-first stack, Singapore-resident hosting, and a hard wall between personal data and any AI model.

Batch sync, not paid API PDPA · SG residency AI sandboxed from PII Human-in-the-loop
01 / FOUNDATIONS

Five architectural decisions

Everything downstream follows from these. Two are shaped by your constraints — the HRIQ API cost and PDPA — and the rest enforce the human-accountability model from the requirements spec.

Sync, don't call

The Portal reads from its own database, kept current by scheduled batch extraction from HRIQ. The expensive live API is avoided except for rare, high-value writes.

Python-first

Backend in Python to reuse your existing extraction scripts and team familiarity. Your scripts become the ingestion backbone, not throwaway tooling.

AI is sandboxed

A model never sees raw personal data it doesn't need, and never performs statutory or financial math. A gateway scrubs every prompt that crosses the trust boundary.

Deterministic core

Payroll, levy, CPF, encashment and compensation run as tested Python code with traceable breakdowns — never an LLM.

SG-resident & sealed

Personal data is hosted in-region, the Portal is not publicly routable, and every action is written to an immutable audit log.

02 / DATA SOURCING

The HRIQ sync pattern

Your existing Python-to-Excel extraction is productionised into a scheduled pipeline. Extracted files land in a secure zone, are validated against a schema, then loaded into the Portal's operational store. The Portal queries that store — fast, and free of per-call API charges.

Figure 1 · Inbound data flow — scheduled batch ingestion
HRIQ
HRIS of record
scheduled
Python extract
→
Extractor
your scripts, productionised & scheduled
Excel / CSV→
Landing zone
encrypted, access-locked
validate +
transform
→
Portal DB
PostgreSQL — synced copy
query→
Portal app
dashboards, AI services

Cadence & freshness

Write-back (when a change must return to HRIQ)

⚠ PDPA consequenceBecause the Portal keeps a synced copy of personal data, that database is squarely in PDPA scope. It must carry the same retention, access-control and breach obligations as HRIQ itself — see §6.
03 / SYSTEM

Layered architecture

A conventional, boring-on-purpose layered design. Boring is correct for a compliance system — every layer is independently testable and the trust boundaries are explicit.

Figure 2 · Logical layers
Presentation — HR-only, behind SSO
Role dashboards web Approval & case UI Document review Knowledge assistant chat
Application / API — auth, RBAC, orchestration
API gateway FastAPI RBAC + session incl. coverage mode Workflow / approvals engine Notification service email/Teams Audit logger
Domain services
Compliance monitor Calculation engine deterministic Report builder Document generator
AI layer — via the sandbox gateway only (§5)
AI gateway scrub+log Drafting Retrieval / RAG Classification / triage
Data & integration
PostgreSQL operational Object store documents/scans Vector store regs/SOPs only Ingestion / extractor Audit log append-only
04 / STACK

Recommended technology

Chosen for PDPA fit, your Python capability, and longevity over novelty. All mainstream and hireable — important for the maintenance-ownership concern.

LayerRecommendationWhy
FrontendReact + TypeScript (Next.js)Mature, component-driven, accessible; easy to find developers.
BackendPython + FastAPIReuses your existing extraction scripts & team skills; fast, typed, well-documented.
DatabasePostgreSQLRelational integrity for payroll/audit; row-level security supports RBAC; strong encryption & backup tooling.
Background jobsCelery or APScheduler + RedisRuns scheduled extraction, monitoring scans, report generation.
Object storageEncrypted blob store (scanned passports, medical records, letters)Keeps large/sensitive files out of the relational DB; per-object access control.
Calculation enginePure Python module, 100% unit-testedDeterministic statutory/financial math, isolated from AI and from the web layer.
Auth / SSOOIDC / SAML (e.g. Microsoft Entra ID) + MFALikely already your corporate identity; restrict to the HR security group.
AI gatewayInternal service wrapping the model APISingle chokepoint for PII scrubbing, logging, purpose checks (§5).
LLMRegion-hosted, no-training endpoint (e.g. Azure OpenAI SG) or self-hosted open model for sensitive flowsKeeps inference in-region under a data-processing agreement; never a consumer endpoint.
✓ RecommendationIf you are a Microsoft/Office shop (Windows + likely M365), the path of least resistance is Entra ID for SSO and Azure (Singapore region) for hosting + Azure OpenAI — identity, residency and the AI endpoint all in one governed tenancy. AWS ap-southeast-1 or GCP asia-southeast1 are equally valid if you prefer.
05 / THE SANDBOX

How AI is walled off from personal data

This is the part that protects you. The rule: the model only ever receives the minimum it needs, de-identified, through one auditable gateway — and it is never trusted with a calculation or a final decision.

Figure 3 · The AI–PII trust boundary
🔒 Trust zone — holds PII (in-region)
Portal DB & object storeNames, FINs, passports, salaries, medical data.
Calculation engineAll payroll/levy/CPF math. Never calls the model.
Template mergeReal names/figures inserted into letters here, after AI returns.
AI Gateway
  • De-identify / tokenise PII
  • Minimise to needed fields
  • Purpose & role check
  • Log prompt + response
  • Route to approved model
⚠ Untrusted — the model
Receives only redacted texte.g. "Dear [EMPLOYEE_1], your bond of [AMOUNT_1]…" — placeholders, not real data.
Returns a draft / classificationReviewed by a human; re-hydrated with real values inside the trust zone.
No retention, no trainingContractual + region-locked endpoint.

The seven controls

⚠ Residual risk to acceptEven sandboxed, AI drafts can be wrong or subtly off. The human review gate (control 7) is the real backstop — it is a process control, not just a technical one, and must be enforced in the UI (nothing leaves the Portal without a named approval).
06 / SECURITY

Security & PDPA architecture

ControlImplementation
AccessSSO restricted to the HR security group; MFA enforced; Portal not publicly routable (corporate network / zero-trust access only).
AuthorisationApp-level RBAC for the six roles + PostgreSQL row-level security so a query cannot return out-of-scope rows even if app logic fails.
Coverage modeTemporary delegated access implementing the cross-training matrix (Payroll↔FW, FW→Staff, Staff→Payroll): Manager-approved, time-bounded, auto-expiring, and every action taken under delegation is flagged as such in the audit log.
NotificationsTime-critical alerts pushed to email/Teams; message content carries no sensitive personal data — it deep-links into the portal where RBAC applies. Unacknowledged critical alerts escalate up the reporting line.
EncryptionTLS 1.2+ in transit; AES-256 at rest for DB, object store and backups.
SecretsManaged secrets vault (DB creds, model keys, HRIQ creds); no secrets in code or config files.
AuditAppend-only, tamper-evident log of every data change, AI call and human approval — user, timestamp, before/after.
RetentionAutomated enforcement of the Employment Act retention clock with scheduled purge + pre-purge review.
BreachAnomaly alerts (unusual access/export) + a documented PDPC-aligned breach-response workflow.
ResidencyAll personal data stored and processed in Singapore region, including the AI endpoint.
AssuranceIndependent security review + penetration test before any phase that handles personal or financial data goes live.
6B / CV INTAKE

CV parsing — upload to structured record

CVs are the single input to recruitment; AI does the data entry. Whether a candidate uploads through the public application page or HR uploads an agency/walk-in CV, the file follows one pipeline: stored encrypted, parsed by AI into structured fields, written to the database, and scored for fit — no manual keying.

Figure 4 · CV intake & parsing pipeline
CV upload
application page or HR upload
file +
consent
→
Object store
encrypted · virus-scanned
document text→
AI parser
OCR + entity extraction, via gateway
structured
fields
→
Candidate record
PostgreSQL (structured)
skills →
fit score
→
Screening pipeline
ranked shortlist
1
A CV is uploaded — by a candidate on the public application page (consent captured at source) or by HR for an agency / walk-in / referral CV (consent + source recorded).
2
File lands in the encrypted object store and is virus-scanned. The raw CV is personal data — it carries the retention clock from day one.
3
AI parser extracts name, contact, experience, role and skills (OCR for scans + entity extraction). Only the minimal document text needed crosses the AI gateway; the structured result returns to the trust zone.
4
Fields are written as a structured candidate record in PostgreSQL, linked to the stored file. Low-confidence fields are flagged.
5
Fit score is computed deterministically — extracted skills/experience matched against the role profile — and the candidate enters the screening pipeline, ranked.
6
Human reviews the extracted fields and the ranking before routing to a hirer. Extraction is assisted, not autonomous.
⚠ Two design constraintsAccuracy: CV layouts are messy; parsing is never 100%. The review-and-correct step stays, and low-confidence fields are flagged rather than trusted. Explainable ranking: the fit score is deterministic skill/experience matching — not an opaque LLM judgement — so a shortlisting decision can always be explained and defended (relevant to FCF / anti-discrimination record-keeping).
6C / EXTERNAL ACTORS

Non-HR actors & how they touch the system

The portal is HR-only, but the job scopes involve several non-HR actors. None of them get portal accounts — each gets a purpose-built channel. The secure one-time link pattern (single-purpose, expiring, no login, minimal data) serves every "respond to one question" case.

ActorInteractionChannel
Hiring managersReview shortlisted CV, register interestOne-time link (outbound email → response recorded in Recruitment)
Site supervisorsConfirm missing/abnormal OT entries; leave-coverage coordinationOne-time link or email digest from the Assistant's chase queue
CandidatesApply, upload CV, receive invites & offersPublic application page (§6B) + outbound email
EHS departmentIncident reports in (trigger claim cases); weekly OT exception report out (fatigue monitoring)Structured intake (form/file drop) inbound; scheduled report delivery outbound
FinanceWage-subsidy/grant reconciliation; grading flagsFile exchange / shared reports (INT-04)
OperationsSite-deployment data for tender cross-checks & headcount reconciliationBatch file exchange (INT-04)
Head of HR / DirectorApprovals above Manager DOA tier; HR Assurance SummaryHead of HR is a portal user; Director receives escalations via the Head of HR
07 / WALKTHROUGHS

Two end-to-end flows

A · Generating a bond letter (AI-assisted)

1
Executive (Staff) selects an employee and "draft bond letter" in their workspace.
2
App fetches needed fields from the Portal DB (trust zone) — bond terms, dates.
3
AI Gateway de-identifies: real name/amount become [EMPLOYEE_1], [AMOUNT_1]; only the skeleton crosses to the model.
4
Model returns drafted letter prose with placeholders intact; gateway logs the exchange.
5
Template merge inside the trust zone re-inserts real values. Draft labelled "AI-generated".
6
Human review gate: Executive (and approver per DOA) reviews and releases. Issued version archived; action audited.

B · DRC / permit-expiry alert (AI-led monitoring)

1
Nightly extraction refreshes worker/permit data into the Portal DB.
2
Compliance monitor (deterministic) recomputes DRC headroom and scans permit/passport expiry windows.
3
Threshold breaches and upcoming expiries become prioritised alerts with owner + due date.
4
FW Executive sees them on the compliance board at login; the monthly DRC report is auto-compiled for the HR Manager.
5
Human acts: the Executive initiates renewal/correction; the Manager approves corrective action. No money or filing moves without a person.

Note flow B touches no LLM at all — the highest-value monitoring is pure deterministic code. AI is the assistant, not the engine.

08 / OPS & OPEN ITEMS

Environments & decisions still open

Environments & operations

Decisions that need your input

DecisionOptions / note
Cloud vs on-premCloud SG-region (recommended, faster/cheaper) vs on-prem if company policy forbids cloud for HR data.
Identity providerConfirm Entra ID / Google Workspace / other — drives SSO & possibly hosting.
Self-hosted vs API modelAPI model (simpler, region-locked) vs self-hosted open model (max data control, more ops). Can mix per sensitivity.
Extraction cadenceHow fresh must each dataset be? Drives schedule and intra-day delta design.
Existing scriptsShare current Python extraction scripts so they can be assessed and folded into the ingestion layer.