staffora
Home Features About Architecture Docs API Contact GitHub
Developer Resources

Documentation

Comprehensive guides and references for the Staffora HRIS platform. The codebase includes ~200 markdown documentation files covering architecture, security, compliance, and development.

In-Repository Documentation

The Staffora repository includes extensive documentation in the Docs/ directory.

Architecture Documentation

Architecture Decision Records (ADRs)

Records of key architectural decisions and their rationale.

Docs/architecture/

Database Guide

PostgreSQL schema design, RLS policies, migration strategy.

Docs/architecture/

Permissions System

RBAC design, field-level permissions, role hierarchy.

Docs/architecture/

Security & Compliance

Security Audit

Comprehensive security review findings.

Docs/audit/

UK Compliance Audit

Employment law compliance status.

Docs/audit/

Technical Debt Report

Known issues and remediation plans.

Docs/audit/

Developer Guides

Getting Started Guide

Local development setup.

Docs/guides/

Deployment Guide

Production deployment instructions.

Docs/guides/

Frontend Guide

React patterns, component library, state management.

Docs/guides/

Design Patterns

Security Patterns

Auth, CSRF, rate limiting, encryption patterns.

Docs/patterns/

State Machine Patterns

How state machines govern business workflows.

Docs/patterns/

Effective Dating Patterns

Temporal data management for HR records.

Docs/patterns/

Key Concepts

Core architectural principles that underpin the Staffora platform.

Multi-Tenancy

Staffora is built as a multi-tenant platform from the ground up. Every table uses PostgreSQL Row-Level Security (RLS) to enforce complete data isolation between tenants. The runtime database user (hris_app) has NOBYPASSRLS, making it impossible for application bugs to leak data across tenants.

Effective Dating

Employee records in Staffora are effective-dated, meaning every change is tracked with effective_from and effective_to dates. This preserves complete history -- personal information, contracts, positions, compensation, and manager assignments are never overwritten, only superseded by new records. This enables point-in-time queries (e.g., "who was this employee's manager on January 15th?") and provides a complete audit trail.

State Machines

Critical business processes are governed by explicit state machines defined in packages/shared/src/state-machines/. These enforce valid transitions (e.g., a leave request can only be approved from "pending" state) and prevent invalid operations at the type level. State machines exist for: employee lifecycle, leave requests, case management, workflows, performance reviews, recruitment pipeline, flexible working requests, and data breach handling.

Repository Pattern (No ORM)

Staffora deliberately avoids ORMs in favor of raw SQL using PostgreSQL's tagged template literals (via postgres.js). This gives full control over query performance, enables complex joins and CTEs, and makes it easy to leverage PostgreSQL-specific features like RLS, effective dating, and jsonb. Every module follows a consistent repository/service/routes layering.

Idempotency

Every mutating API endpoint accepts an Idempotency-Key header. This prevents duplicate operations on network retries -- if the same key is submitted twice, the second request returns the original response without re-executing the operation. Keys are scoped per tenant and stored in both Redis (fast check) and PostgreSQL (durable).

Technology Reference

Complete breakdown of the technologies powering Staffora.

Backend

Technology Purpose Version
BunRuntime & package manager1.1.38
Elysia.jsHTTP framework^1.1.26
TypeScriptLanguage^5.7.2
PostgreSQLDatabase16
RedisCache & queues7
postgres.jsSQL driver^3.4.5
Better AuthAuthentication^1.5.4
TypeBoxSchema validation^0.34.11
PinoStructured logging^9.14.0
pdf-libPDF generation^1.17.1
exceljsExcel export^4.4.0
nodemailerEmail^6.9.16
AWS S3 SDKFile storage^3.700.0
web-pushBrowser push^3.6.7
firebase-adminMobile push^13.0.2
OpenTelemetryTracing^1.9.0

Frontend

Technology Purpose Version
ReactUI framework^18.3.1
React Router v7Routing (SSR)^7.1.1
TanStack QueryData fetching^5.62.7
Tailwind CSSStyling^3.4.17
react-hook-formForm handling^7.54.2
zodValidation^3.24.1
rechartsCharts^3.8.0
@dnd-kitDrag and drop^6.3.1
lucide-reactIcons^0.469.0
StorybookComponent dev^8.5.0
VitestTesting^2.1.8

Infrastructure

Technology Purpose
Docker ComposeContainer orchestration
PgBouncerConnection pooling
NginxLoad balancer
PrometheusMetrics collection
GrafanaMetrics dashboards
Loki + PromtailLog aggregation
ClamAVVirus scanning
GitHub ActionsCI/CD (8 workflows)