UI HRM
AI-Powered Multi-Tenant Human Resource Management SaaS
Role
Lead Full-Stack & AI Architect
Key Contribution
Multi-tenant SaaS architecture, 10+ HR modules, pgvector workflows & automated anomaly detection
Core Stack
ATTENDANCE ANOMALIES
LIVE · 98.4%AI EXPENSE & LEAVE ROUTING
Overview & Business Problem
Project Overview
UI HRM is a modern multi-tenant Human Resource Management SaaS designed to consolidate fragmented HR workflows into a single cohesive platform. Spanning 10+ integrated modules, it pairs type-safe full-stack architecture with embedded AI automation for expense classification, intelligent leave routing, and attendance anomaly detection.
Business Problem
Growing organizations often stitch together separate tools for attendance, leave approvals, and expense processing, creating manual review bottlenecks and inconsistent policy enforcement across departments.
My Role & Requirements
03 · My Role
- Architected the multi-tenant database schema and tenant-isolation layer using PostgreSQL and Drizzle ORM.
- Built 10+ integrated HR modules using Next.js 15 App Router and strict end-to-end TypeScript.
- Engineered AI workflow automation for expense categorization, intelligent leave routing, and attendance anomaly detection.
- Integrated pgvector inside PostgreSQL for semantic policy lookup and automated classification.
04 · Core Requirements
- Strict tenant isolation across organizations sharing a unified SaaS deployment.
- Modular architecture supporting 10+ cohesive HR workflows with shared permissions.
- Automated classification of employee expenses and anomaly flagging on attendance logs.
- Fast, low-latency dashboard UX with server-rendered data hydration.
Technical Challenges
Maintaining clean cross-module domain boundaries across 10+ HR workflows without duplicating business rules.
Keeping vector similarity lookups and transactional HR queries consistent inside a single PostgreSQL engine.
Designing deterministic fallback logic whenever AI expense categorization confidence falls below threshold.
Architecture Blueprint
Unified Next.js 15 full-stack architecture backed by PostgreSQL + pgvector via Drizzle ORM, isolating tenant context at the data-access layer and running AI classification and anomaly workflows asynchronously.
Technology Choices
Next.js 15 & TypeScript
Server Components and Server Actions minimize client bundle bloat while keeping full-stack types synchronized.
Drizzle ORM + PostgreSQL
Provides zero-overhead SQL control, explicit migrations, and native compatibility with pgvector.
pgvector
Eliminates the operational overhead of a separate vector store while enabling semantic matching alongside relational HR records.
Core Pattern Excerpt
Tenant-scoped Drizzle queries combined with pgvector similarity search classify expenses against organization-specific policy rules.
export async function categorizeExpense(
tenantId: string,
description: string,
embedding: number[]
) {
const matchedPolicies = await db
.select({
categoryId: expensePolicies.categoryId,
policyName: expensePolicies.name,
similarity: sql<number>`1 - (${expensePolicies.embedding} <=> ${JSON.stringify(embedding)}::vector)`,
})
.from(expensePolicies)
.where(eq(expensePolicies.tenantId, tenantId))
.orderBy(desc(sql`similarity`))
.limit(3);
const topMatch = matchedPolicies[0];
return {
categoryId: topMatch && topMatch.similarity > 0.82 ? topMatch.categoryId : null,
requiresManualReview: !topMatch || topMatch.similarity <= 0.82,
candidates: matchedPolicies,
};
}Outcomes & Lessons Learned
09 · Verified Outcomes
- Delivered a scalable multi-tenant SaaS architecture supporting end-to-end HR operations across 10+ integrated modules.
- Automated repetitive expense categorization, leave routing, and attendance anomaly detection.
10 · Lessons Learned
- Co-locating relational and vector data in PostgreSQL with pgvector dramatically simplifies multi-tenant consistency.
- Always pair AI automation with explicit confidence thresholds and human-in-the-loop review paths for financial workflows.