<aside> 🔁 Synced from GitHub #ac5b1a75b5d1. Edit in the paidhr-system-docs repository, not here: changes made in Notion are overwritten.

</aside>

System overview

PaidHR is five front doors talking to three backend services, which share one set of SQL Server databases and use their own MongoDB stores for the rest.

flowchart LR
  WEB[Web app] --> CORE
  MOB[Mobile app] --> CORE
  CP[Control panel] --> CORE
  BOT[Channel bot] --> CORE
  WEB --> EWA
  MOB --> EWA
  BOT --> EWA
  TERM[Clock-in terminal] --> EWA
  WEB --> WAL
  MOB --> WAL
  CORE[core-backend] |sessions, employees, loans| EWA[ewa-service]
  CORE -->|payout queue| WAL[wallet-service]
  CORE --> SQL[(SQL Server)]
  EWA --> SQL
  EWA --> MONGO[(MongoDB)]
  WAL --> MONGO
  WAL --> BANKS[Banking partners]
Box What it is
Web app React. HR admin, employee, manager and approval pages
Mobile app Flutter. Employees: requests, payslips, clock-in, EWA, wallet
Control panel PaidHR staff's admin tool
Channel bot USSD, WhatsApp and Telegram
Clock-in terminal Android kiosk on the wall
core-backend .NET. People, payroll, leave, approvals, identity, notifications
ewa-service NestJS. Earned wages, time & attendance, hiring, channels, integrations
wallet-service NestJS. Wallets, payouts, cards, bills, KYC
SQL Server Membership, one database per tenant, warehouse
MongoDB EWA, hiring and wallet records (plus SQS and Redis queues)
Banking partners Bmoni, VFD, Flutterwave, Paystack, Mono and others

The five rules that explain most behaviour

  1. core-backend owns identity. Every login, token and permission is issued by core-backend. ewa-service does not trust a token on its own: it calls core-backend's /account/checksession or /account/getusersession on each request. If core-backend is down, EWA and attendance stop working too. See sign-in & tenancy.
  2. Each customer's HR data lives in a tenant database. A login database (membership) says which tenant database an organisation lives in. Both core-backend and ewa-service open the right tenant per request. See databases.
  3. Most business rules live in stored procedures. core-backend's C# validates and orchestrates. The state changes (prepare payroll, review a request, accrue leave) happen in SQL stored procedures such as spPreparePayroll and spReviewEmployeeRequest. Each tenant database holds its own copy, deployed from the same migrations.
  4. Money moves through queues. core-backend never pays anyone directly. It puts payout instructions on an SQS queue; wallet-service takes them, pays through a banking partner, and reports back. See queues.
  5. Background jobs do a lot of the work. Accrual, exits that take effect on a date, EWA balances, payout retries and data syncs all run on schedules. A feature can look broken when its job has not run. See scheduled jobs.

A day in the life of a salary

sequenceDiagram
  participant HR as HR admin (web)
  participant Core as core-backend
  participant SQL as Tenant DB
  participant SQS as SQS
  participant Wal as wallet-service
  participant Bank as Banking partner
  participant Emp as Employee (mobile)
  HR->>Core: Prepare payroll
  Core->>SQL: spPreparePayroll (earnings, deductions, tax, pension, changes)
  HR->>Core: Submit for approval
  Core-->>HR: Approvers emailed (one-click links)
  HR->>Core: Approve (each step in the chain)
  Core->>SQL: spReviewPayroll → Approved
  HR->>Core: Process payment schedule
  Core->>SQS: payout messages (every 5 min worker)
  SQS->>Wal: INITIATE_PAYOUT
  Wal->>Bank: transfers
  Bank-->>Wal: webhook: success / failure
  Wal-->>Core: acknowledgement queue
  Core-->>Emp: payslip email + in-app

Each step is explained on its own page: payroll, payment schedules, wallet.