# aryankarmani/omnihr-backend architecture

> Architecture diagram of the GitHub repository aryankarmani/omnihr-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryankarmani/omnihr-backend
- Repository: https://github.com/aryankarmani/omnihr-backend

## Overview

OmniHR is a multi-tenant HR SaaS backend. A company user reaches HR functions through the Express API, where routes apply authentication and dispatch to domain controllers; those controllers manage tenant data and, where shown, trigger notifications, audit records, or email. Public landing-page requests support demo leads and paid company onboarding, while a separate super-admin API manages platform companies, plans, subscriptions, and payments. The tree also documents attendance, leave, payroll, reporting, and employee-management capabilities. Several route/controller implementations are unsampled, so those links are not inferred.

Main entry points: [`src/app.ts`](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/app.ts) (Express app), [`src/controllers/employee.controller.ts`](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/employee.controller.ts) (Employee management), [`src/controllers/attendance.controller.ts`](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/attendance.controller.ts) (Attendance management), [`src/utils/mail.ts`](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/mail.ts) (Email delivery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_app["Express app<br/>[app.ts]"]
  node_employee_routes["Employee routes<br/>[employee.routes.ts]"]
  node_attendance_routes["Attendance routes"]
  node_masters_routes["Master-data routes<br/>[masters.routes.ts]"]
  node_reports_routes["Report routes<br/>[report.routes.ts]"]
  node_public_routes["Public routes<br/>[public.routes.ts]"]
  node_superadmin_routes["Super-admin routes"]
end

subgraph group_hr["HR operations"]
  node_employee["Employee management"]
  node_attendance["Attendance management"]
  node_masters["HR master data"]
  node_leave["Leave management"]
  node_payroll["Payroll"]
  node_reports["Reporting"]
  node_teams["Team management<br/>[team.controller.ts]"]
end

subgraph group_platform["Platform SaaS"]
  node_onboarding["Paid onboarding"]
  node_demo["Demo requests"]
  node_platform_admin["Platform administration"]
  node_subscription_notice["Subscription notices"]
end

subgraph group_shared["Shared services"]
  node_db[("Application database")]
  node_auth["Tenant authentication<br/>[auth.ts]"]
  node_superadmin_auth["Super-admin auth<br/>[superadmin.auth.ts]"]
  node_notify["In-app notifications<br/>[notification.ts]"]
  node_audit["Audit logging<br/>[auditLog.ts]"]
  node_mail["Email delivery<br/>[mail.ts]"]
  node_team_scope["Team scope<br/>[teamScope.ts]"]
  node_push["Push delivery"]
end

node_visitor(("API client"))

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts API"| node_employee_routes
node_app -->|"mounts API"| node_attendance_routes
node_app -->|"mounts API"| node_masters_routes
node_app -->|"mounts API"| node_reports_routes
node_app -->|"mounts API"| node_public_routes
node_app -->|"mounts API"| node_superadmin_routes
node_app -->|"mounts routes"| node_leave
node_app -->|"mounts routes"| node_payroll
node_app -->|"mounts routes"| node_teams
node_employee_routes -->|"dispatches"| node_employee
node_employee_routes -->|"authenticates"| node_auth
node_attendance_routes -->|"dispatches"| node_attendance
node_attendance_routes -->|"authenticates"| node_auth
node_masters_routes -->|"dispatches"| node_masters
node_masters_routes -->|"authenticates"| node_auth
node_reports_routes -->|"dispatches"| node_reports
node_public_routes -->|"dispatches"| node_onboarding
node_public_routes -->|"dispatches"| node_demo
node_superadmin_routes -->|"routes requests"| node_platform_admin
node_superadmin_routes -->|"authenticates"| node_superadmin_auth
node_employee -->|"reads and writes"| node_db
node_attendance -->|"reads and writes"| node_db
node_masters -->|"reads and writes"| node_db
node_attendance -->|"checks team scope"| node_team_scope
node_employee -->|"checks team scope"| node_team_scope
node_attendance -->|"creates notifications"| node_notify
node_employee -->|"creates notifications"| node_notify
node_attendance -->|"records actions"| node_audit
node_employee -->|"records actions"| node_audit
node_attendance -->|"sends push"| node_push
node_employee -->|"sends welcome email"| node_mail
node_onboarding -->|"sends email"| node_mail
node_demo -->|"sends email"| node_mail
node_app -->|"starts checker"| node_subscription_notice
node_subscription_notice -->|"updates subscription"| node_db
node_subscription_notice -->|"sends notices"| node_mail

click node_app "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/app.ts"
click node_employee_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/employee.routes.ts"
click node_attendance_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/attendance.routes.ts"
click node_masters_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/masters.routes.ts"
click node_reports_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/report.routes.ts"
click node_public_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/public.routes.ts"
click node_superadmin_routes "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/superadmin.routes.ts"
click node_employee "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/employee.controller.ts"
click node_attendance "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/attendance.controller.ts"
click node_masters "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/masters.controller.ts"
click node_leave "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/leave.controller.ts"
click node_payroll "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/payroll.controller.ts"
click node_reports "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/report.controller.ts"
click node_teams "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/team.controller.ts"
click node_onboarding "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/public.onboarding.controller.ts"
click node_demo "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/demoRequest.controller.ts"
click node_platform_admin "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/superadmin.routes.ts"
click node_subscription_notice "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/services/subscriptionNotification.service.ts"
click node_auth "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/middleware/auth.ts"
click node_superadmin_auth "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/middleware/superadmin.auth.ts"
click node_notify "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/notification.ts"
click node_audit "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/auditLog.ts"
click node_mail "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/mail.ts"
click node_team_scope "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/teamScope.ts"
click node_push "https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/pushNotification.controller.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_employee_routes,node_attendance_routes,node_masters_routes,node_reports_routes,node_public_routes,node_superadmin_routes,node_visitor toneBlue
class node_employee,node_attendance,node_masters,node_leave,node_payroll,node_reports,node_teams toneAmber
class node_onboarding,node_demo,node_platform_admin,node_subscription_notice toneMint
class node_db,node_auth,node_superadmin_auth,node_notify,node_audit,node_mail,node_team_scope,node_push toneRose
```

## Components

### API entry

- [Express app](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/app.ts): `src/app.ts`
- [Employee routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/employee.routes.ts): `src/routes/employee.routes.ts`
- [Attendance routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/attendance.routes.ts): `src/routes/attendance.routes.ts`
- [Master-data routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/masters.routes.ts): `src/routes/masters.routes.ts`
- [Report routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/report.routes.ts): `src/routes/report.routes.ts`
- [Public routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/public.routes.ts): `src/routes/public.routes.ts`
- [Super-admin routes](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/superadmin.routes.ts): `src/routes/superadmin.routes.ts`

### HR operations

- [Employee management](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/employee.controller.ts): `src/controllers/employee.controller.ts`
- [Attendance management](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/attendance.controller.ts): `src/controllers/attendance.controller.ts`
- [HR master data](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/masters.controller.ts): `src/controllers/masters.controller.ts`
- [Leave management](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/leave.controller.ts): `src/controllers/leave.controller.ts`
- [Payroll](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/payroll.controller.ts): `src/controllers/payroll.controller.ts`
- [Reporting](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/report.controller.ts): `src/controllers/report.controller.ts`
- [Team management](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/team.controller.ts): `src/controllers/team.controller.ts`

### Platform SaaS

- [Paid onboarding](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/public.onboarding.controller.ts): `src/controllers/public.onboarding.controller.ts`
- [Demo requests](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/demoRequest.controller.ts): `src/controllers/demoRequest.controller.ts`
- [Platform administration](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/routes/superadmin.routes.ts): `src/routes/superadmin.routes.ts`
- [Subscription notices](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/services/subscriptionNotification.service.ts): `src/services/subscriptionNotification.service.ts`

### Shared services

- **Application database**
- [Tenant authentication](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/middleware/auth.ts): `src/middleware/auth.ts`
- [Super-admin auth](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/middleware/superadmin.auth.ts): `src/middleware/superadmin.auth.ts`
- [In-app notifications](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/notification.ts): `src/utils/notification.ts`
- [Audit logging](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/auditLog.ts): `src/utils/auditLog.ts`
- [Email delivery](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/mail.ts): `src/utils/mail.ts`
- [Team scope](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/utils/teamScope.ts): `src/utils/teamScope.ts`
- [Push delivery](https://github.com/aryankarmani/omnihr-backend/blob/feat/aryan/be/src/controllers/pushNotification.controller.ts): `src/controllers/pushNotification.controller.ts`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Express app → Employee routes: mounts API (evidence: `src/app.ts`)
- Express app → Attendance routes: mounts API (evidence: `src/app.ts`)
- Express app → Master-data routes: mounts API (evidence: `src/app.ts`)
- Express app → Report routes: mounts API (evidence: `src/app.ts`)
- Express app → Public routes: mounts API (evidence: `src/app.ts`)
- Express app → Super-admin routes: mounts API (evidence: `src/app.ts`)
- Express app → Leave management: mounts routes (evidence: `src/app.ts`)
- Express app → Payroll: mounts routes (evidence: `src/app.ts`)
- Express app → Team management: mounts routes (evidence: `src/app.ts`)
- Employee routes → Employee management: dispatches (evidence: `src/routes/employee.routes.ts`)
- Employee routes → Tenant authentication: authenticates (evidence: `src/routes/employee.routes.ts`)
- Attendance routes → Attendance management: dispatches (evidence: `src/routes/attendance.routes.ts`)
- Attendance routes → Tenant authentication: authenticates (evidence: `src/routes/attendance.routes.ts`)
- Master-data routes → HR master data: dispatches (evidence: `src/routes/masters.routes.ts`)
- Master-data routes → Tenant authentication: authenticates (evidence: `src/routes/masters.routes.ts`)
- Report routes → Reporting: dispatches (evidence: `src/routes/report.routes.ts`)
- Public routes → Paid onboarding: dispatches (evidence: `src/routes/public.routes.ts`)
- Public routes → Demo requests: dispatches (evidence: `src/routes/public.routes.ts`)
- Super-admin routes → Platform administration: routes requests (evidence: `src/routes/superadmin.routes.ts`)
- Super-admin routes → Super-admin auth: authenticates (evidence: `src/routes/superadmin.routes.ts`)
- Employee management → Application database: reads and writes (evidence: `src/controllers/employee.controller.ts`)
- Attendance management → Application database: reads and writes (evidence: `src/controllers/attendance.controller.ts`)
- HR master data → Application database: reads and writes (evidence: `src/controllers/masters.controller.ts`)
- Attendance management → Team scope: checks team scope (evidence: `src/controllers/attendance.controller.ts`)
- Employee management → Team scope: checks team scope (evidence: `src/controllers/employee.controller.ts`)
- Attendance management → In-app notifications: creates notifications (evidence: `src/controllers/attendance.controller.ts`)
- Employee management → In-app notifications: creates notifications (evidence: `src/controllers/employee.controller.ts`)
- Attendance management → Audit logging: records actions (evidence: `src/controllers/attendance.controller.ts`)
- Employee management → Audit logging: records actions (evidence: `src/controllers/employee.controller.ts`)
- Attendance management → Push delivery: sends push (evidence: `src/controllers/attendance.controller.ts`)
- Employee management → Email delivery: sends welcome email (evidence: `src/controllers/employee.controller.ts`)
- Paid onboarding → Email delivery: sends email (evidence: `src/controllers/public.onboarding.controller.ts`)
- Demo requests → Email delivery: sends email (evidence: `src/controllers/demoRequest.controller.ts`)
- Express app → Subscription notices: starts checker (evidence: `src/app.ts`)
- Subscription notices → Application database: updates subscription (evidence: `src/services/subscriptionNotification.service.ts`)
- Subscription notices → Email delivery: sends notices (evidence: `src/services/subscriptionNotification.service.ts`)
