# skaslam1407/saas-hrms-frappe-hrms-sync architecture

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

- Interactive diagram: https://gitdiagram.com/skaslam1407/saas-hrms-frappe-hrms-sync
- Repository: https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync

## Overview

This is a SaaS HRMS-to-Frappe HRMS synchronization service. Users can request a sync through the API, while a daily scheduler provides an automatic trigger; both lead to the sync service, which reads SaaS records and upserts them into Frappe. The workflow covers company and organizational masters, employees, compensation, and optional payroll generation. Mapping functions shape records for Frappe, and the REST client handles target-system operations. Source excerpts show the orchestration and integrations; unsampled implementation details are not inferred beyond documented stages.

Main entry points: [`sync_service.py`](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py) (Sync Orchestrator), [`frappe_client.py`](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/frappe_client.py) (Frappe REST Client), [`main.py`](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/main.py) (FastAPI Endpoints), [`saas_source.py`](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/saas_source.py) (SaaS Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Triggers and API"]
  node_api["FastAPI Endpoints<br/>[main.py]"]
  node_scheduler["Daily Scheduler<br/>[scheduler.py]"]
end

subgraph group_source["Source and Mapping"]
  node_saas["SaaS Adapter<br/>[saas_source.py]"]
  node_records["HRMS Records<br/>[models.py]"]
  node_mappers["Frappe Mappers<br/>[mappers.py]"]
end

subgraph group_sync["Sync Workflows"]
  node_orchestrator["Sync Orchestrator<br/>[sync_service.py]"]
  node_masters["Organization Masters<br/>[sync_service.py]"]
  node_employees["Employee Sync<br/>[sync_service.py]"]
  node_compensation["Compensation Sync<br/>[sync_service.py]"]
  node_payroll["Payroll Generation<br/>[sync_service.py]"]
  node_results["Sync Results<br/>[models.py]"]
end

subgraph group_target["Target Integration"]
  node_frappe_client["Frappe REST Client<br/>[frappe_client.py]"]
  node_settings["Runtime Settings<br/>[config.py]"]
end

node_user(("SaaS User"))
node_saas_hrms["SaaS HRMS"]
node_frappe["Frappe HRMS"]

node_user -->|"requests sync"| node_api
node_api -->|"runs sync"| node_orchestrator
node_api -->|"starts scheduler"| node_scheduler
node_scheduler -->|"runs daily"| node_orchestrator
node_api -->|"checks health"| node_frappe_client
node_saas -->|"reads records"| node_saas_hrms
node_saas -->|"yields records"| node_records
node_orchestrator -->|"loads records"| node_saas
node_orchestrator -->|"syncs masters"| node_masters
node_orchestrator -->|"syncs employees"| node_employees
node_orchestrator -->|"syncs compensation"| node_compensation
node_orchestrator -->|"optionally runs"| node_payroll
node_masters -->|"maps payloads"| node_mappers
node_employees -->|"maps payloads"| node_mappers
node_compensation -->|"maps payloads"| node_mappers
node_masters -->|"upserts masters"| node_frappe_client
node_employees -->|"upserts employees"| node_frappe_client
node_compensation -->|"upserts compensation"| node_frappe_client
node_payroll -->|"creates payroll"| node_frappe_client
node_orchestrator -->|"returns report"| node_results
node_frappe_client -->|"REST operations"| node_frappe
node_frappe_client -->|"reads credentials"| node_settings
node_saas -->|"reads API settings"| node_settings

click node_api "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/main.py"
click node_scheduler "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/scheduler.py"
click node_orchestrator "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py"
click node_saas "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/saas_source.py"
click node_records "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/models.py"
click node_mappers "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/mappers.py"
click node_masters "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py"
click node_employees "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py"
click node_compensation "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py"
click node_payroll "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py"
click node_results "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/models.py"
click node_frappe_client "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/frappe_client.py"
click node_settings "https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/config.py"

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_api,node_scheduler,node_user toneBlue
class node_saas,node_records,node_mappers toneAmber
class node_orchestrator,node_masters,node_employees,node_compensation,node_payroll,node_results toneMint
class node_frappe_client,node_settings toneRose
class node_saas_hrms,node_frappe toneIndigo
```

## Components

### Triggers and API

- [FastAPI Endpoints](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/main.py): `main.py`
- [Daily Scheduler](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/scheduler.py): `scheduler.py`

### Source and Mapping

- [SaaS Adapter](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/saas_source.py): `saas_source.py`
- [HRMS Records](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/models.py): `models.py`
- [Frappe Mappers](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/mappers.py): `mappers.py`

### Sync Workflows

- [Sync Orchestrator](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py): `sync_service.py`
- [Organization Masters](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py): `sync_service.py`
- [Employee Sync](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py): `sync_service.py`
- [Compensation Sync](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py): `sync_service.py`
- [Payroll Generation](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/sync_service.py): `sync_service.py`
- [Sync Results](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/models.py): `models.py`

### Target Integration

- [Frappe REST Client](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/frappe_client.py): `frappe_client.py`
- [Runtime Settings](https://github.com/skaslam1407/saas-hrms-frappe-hrms-sync/blob/main/config.py): `config.py`

### Other components

- **SaaS User**
- **SaaS HRMS**
- **Frappe HRMS**

## Connections

- SaaS User → FastAPI Endpoints: requests sync (evidence: `main.py`)
- FastAPI Endpoints → Sync Orchestrator: runs sync (evidence: `main.py`)
- FastAPI Endpoints → Daily Scheduler: starts scheduler (evidence: `main.py`)
- Daily Scheduler → Sync Orchestrator: runs daily (evidence: `scheduler.py`)
- FastAPI Endpoints → Frappe REST Client: checks health (evidence: `main.py`)
- SaaS Adapter → SaaS HRMS: reads records (evidence: `saas_source.py`)
- SaaS Adapter → HRMS Records: yields records (evidence: `saas_source.py`)
- Sync Orchestrator → SaaS Adapter: loads records (evidence: `sync_service.py`)
- Sync Orchestrator → Organization Masters: syncs masters (evidence: `sync_service.py`)
- Sync Orchestrator → Employee Sync: syncs employees (evidence: `sync_service.py`)
- Sync Orchestrator → Compensation Sync: syncs compensation (evidence: `sync_service.py`)
- Sync Orchestrator → Payroll Generation: optionally runs (evidence: `sync_service.py`)
- Organization Masters → Frappe Mappers: maps payloads (evidence: `sync_service.py`)
- Employee Sync → Frappe Mappers: maps payloads (evidence: `sync_service.py`)
- Compensation Sync → Frappe Mappers: maps payloads (evidence: `sync_service.py`)
- Organization Masters → Frappe REST Client: upserts masters (evidence: `sync_service.py`)
- Employee Sync → Frappe REST Client: upserts employees (evidence: `sync_service.py`)
- Compensation Sync → Frappe REST Client: upserts compensation (evidence: `sync_service.py`)
- Payroll Generation → Frappe REST Client: creates payroll (evidence: `sync_service.py`)
- Sync Orchestrator → Sync Results: returns report (evidence: `sync_service.py`)
- Frappe REST Client → Frappe HRMS: REST operations (evidence: `frappe_client.py`)
- Frappe REST Client → Runtime Settings: reads credentials (evidence: `frappe_client.py`)
- SaaS Adapter → Runtime Settings: reads API settings (evidence: `saas_source.py`)
