Adam BlansettSenior Full-Stack & AI Engineer
Software Architecture
11 min read
Adam Blansett

Decoupling AI Recruiting and HR Operations: Signed HMAC Webhooks, pgvector Policy RAG, and PII Scrubbing

Architectural case study on decoupling AI Recruiter and AI HR Platform across candidate-to-employee onboarding via signed HMAC-SHA256 webhooks, pre-LLM PII scrubbing, Celery Beat leave accruals, and active JWT revocation.

MicroservicesHMAC-SHA256HR TechPolicy RAGPII RedactionCelerypgvector

HR and talent acquisition share a single pivotal handoff—the moment a candidate signs an offer—yet everything before and after that event belongs to fundamentally different security zones. Combining high-volume candidate scraping and outbound recruiting email pipelines into the same database as active employee leave accruals, compensation metadata, and performance reviews creates unnecessary coupling and elevates breach blast radius.

That is why AI Recruiter and AI HR Operations Platform were engineered as independent services connected strictly across a verified, idempotent event boundary.

The Signed Offer-Accepted Webhook Boundary#

When an opportunity progresses through AI Recruiter's 18-stage recruiting pipeline (including its database-enforced human approval gate for Gmail outreach) and triggers `candidate.offer_accepted`, it dispatches an event to AI HR Platform signed with HMAC-SHA256 and a delivery timestamp:

verify_handoff_webhook.py
def verify_signed_handoff(raw_body: bytes, signature_header: str, secret: bytes) -> bool:
    expected = hmac.new(secret, raw_body, hashlib.sha256).hexdigest()
    provided = signature_header.removeprefix("sha256=").strip()
    return hmac.compare_digest(expected, provided)

On receipt, the HR microservice validates the signature with `hmac.compare_digest`, verifies event uniqueness so network retries cannot double-create staff accounts (a pattern teams can test locally with tools like Webhook Reliability Kit), and provisions onboarding tasks automatically.

Policy Enforcement Q&A with pgvector RAG and Pre-LLM PII Scrubbing#

Employees routinely paste sensitive personal details into chat boxes when asking about parental leave, expense reimbursements, or compliance SOPs. Routing those raw prompts to external SaaS chatbots creates avoidable compliance exposure. In the HR microservice, employee handbooks and SOPs are chunked and indexed into PostgreSQL 16 `pgvector`, while a pre-inference PII scrubber strips SSNs, personal contact details, and employee IDs prior to generation.

By defaulting to self-hosted Ollama inference (`Llama 3.1 8B`, `Qwen 2.5 7B`, and `nomic-embed-text`), policy answers cite specific handbook sections without transmitting employee questions off-premises.

Asynchronous Leave Accruals and Anti-Bias OKR Synthesis#

Operational reliability in HR depends heavily on background scheduling and clear auditability:

  • Celery Beat Accrual Scheduler: Periodically recalculates PTO, sick, parental, and bereavement leave balances with rollover caps, paired with live team calendar conflict checks during manager approval.
  • 360-Degree Reviews with Anti-Bias Guardrails: Gathers self, peer, manager, and direct-report feedback alongside OKR completion telemetry while prompting reviewers toward observable behavioral evidence.
  • Multi-Tenant RBAC & Active JWT Revocation: Separates `SUPER_ADMIN`, `HR_ADMIN`, `PEOPLE_MANAGER`, and `EMPLOYEE` scopes, backed by active token revocation on logout so compromised sessions invalidate immediately.
Production Security Check: Both Python/FastAPI and React/Vite workspaces run GitHub Actions CI against live PostgreSQL pgvector and Redis 7 containers, keeping dependencies audited at zero high/critical frontend CVEs in v2.0.1.

Designing cleanly bounded internal microservices or connecting legacy systems with signed event contracts? Review my Software Architecture and AI Engineering practices, or book a consultation.

Applied Architecture

Production Case Studies & Capabilities

Explore how these engineering patterns are deployed in production systems and available through client engagements.

Case Study

AI HR Operations Platform

A production-ready Python (FastAPI) and React HR operations microservice with pgvector policy RAG, multi-tier leave accrual scheduling, 360-degree OKR reviews, pre-LLM PII scrubbing, and signed HMAC-SHA256 webhook handoff from AI Recruiter.

Read Case Study
Case Study

AI Recruiter

A production-grade Python (FastAPI) and React platform providing provider-neutral LLM opportunity evaluation, DNS-verified recruiter discovery, and database-enforced human-in-the-loop outreach.

Read Case Study
Related Engineering Service

Software Architecture & System Design

Fast-moving teams frequently accrue hidden architectural liabilities: tangled domain logic, unmaintainable monoliths, or over-engineered microservices that paralyze development.

Related Engineering Service

AI Engineering & LLM Integration

Many AI initiatives fail in production due to prompt fragility, high token latency, hallucination risks, and lack of structured evaluation. I bridge the gap between experimental LLM prompts and deterministic software engineering.

Frequently Asked Questions

Why keep AI Recruiter and AI HR Platform as separate services instead of one monolith?
Recruiting tools serve external job candidates, outreach pipelines, and Gmail/job-board integrations with high webhook churn, while internal HR platforms hold payroll-adjacent employee records, leave balances, policy RAG indexes, and performance reviews with strict RBAC. Decoupling them via signed event contracts limits blast radius and lets each scale and deploy independently.
How do HMAC-SHA256 webhooks ensure safe offer-to-onboarding handoff?
When a candidate accepts an offer in AI Recruiter, the emitter signs the serialized payload and timestamp with a shared secret using HMAC-SHA256. The receiving HR endpoint validates the signature in constant time, rejects stale timestamps to block replay attacks, and uses idempotency keys so retried deliveries never provision duplicate employee records.
How is employee PII protected when answering policy questions with an LLM?
Before any query leaves the service layer, a deterministic PII scrubber masks SSNs, personal phone numbers, home addresses, and private email tokens. By default, embeddings and synthesis run locally on Ollama models (Llama 3.1, Qwen 2.5, nomic-embed-text) over cited PostgreSQL pgvector handbook chunks.
Share this technical guide

Need Help Solving This in Your Application?

I partner with founders, executives, and engineering leaders to design architectures, resolve production bottlenecks, and deliver resilient software.

Related Technical Articles