# lethimytram/erp-project-human-resources architecture

> Architecture diagram of the GitHub repository lethimytram/erp-project-human-resources, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lethimytram/erp-project-human-resources
- Repository: https://github.com/lethimytram/erp-project-human-resources

## Overview

##### Project Type and Purpose
- This is a full-stack, enterprise HRM (Human Resource Management) application built as a set of custom Odoo addons (modules) on top of the Odoo 18.3 Python framework, backed by PostgreSQL 13+.
- It automates end-to-end HR processes: recruitment, employee profile management, contracts, attendance, leave management and payroll (including tax/insurance calculations and external API integration).

##### File‐Structure Insights
- Top‐level artifacts
- “Business Process (BPMN)” folder – detailed process flows for core workflows (e.g., recruitment, payroll calculation).
- “Report and Demo Odoo” folder – Excel templates used to import or demo sample data for each HR sub-domain.
- README emphasizes Odoo modules, PostgreSQL schema (hr_employee, hr_contract, hr_recruitment, hr_attendance, hr_leave, hr_payslip) and the Python-based payroll rules engine.

##### Main Components
a. Presentation Layer
– Web Browser (HR staff, managers, employees)
– Odoo Web Client (QWeb + JavaScript)
b. Application / Business Logic Layer (Odoo Server)
– Core Odoo framework (ORM, Controllers, Views)
– Custom HRM addons:
- hr_recruitment
- hr_employee (profiles, departments)
- hr_contract
- hr_attendance
- hr_leave
- hr_payslip + Payroll Rule Engine
– API Modules (external system connectors: tax, insurance, SSO)
c. Data Layer
– PostgreSQL database (tables as above, linked via FKs)
d. Modeling & Demo Data Artifacts
– Excel import templates for demo/reporting

##### Relationships & Data Flows
- User → Web Client: HTTP/HTTPS requests to Odoo controllers
- Web Client → Business Logic: RPC calls (JSON) to Odoo server
- Business Logic → Database: ORM CRUD operations on core/hr tables
- Business Logic → External API: REST/SOAP calls for payroll integrations
- Data Import: Excel → Odoo import wizards → ORM
- Reporting: ORM queries → QWeb reports/PDF/dashboards

##### Architectural Patterns & Principles
- Layered Architecture (Presentation / Application / Data)
- Modular Addon Design (each HR domain in its own module)
- BPMN for process orchestration; UML for requirements traceability
- Single Source of Truth (PostgreSQL with referential integrity)
- Extensibility via Odoo’s plugin mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Browser (HR Staff, Managers, Employees)"]:::presentation
        WebClient["Odoo Web Client (QWeb + JavaScript)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Application / Business Logic Layer"
        subgraph "Core Odoo Framework"
            ORM["ORM"]:::backend
            Controllers["Controllers"]:::backend
            Views["Views"]:::backend
        end
        subgraph "Custom HRM Addons"
            Recruit["hr_recruitment"]:::backend
            EmployeeMod["hr_employee"]:::backend
            ContractMod["hr_contract"]:::backend
            Attendance["hr_attendance"]:::backend
            Leave["hr_leave"]:::backend
            Payroll["hr_payslip + Payroll Rule Engine"]:::backend
        end
        API["API Modules\n(tax, insurance, SSO)"]:::external
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["PostgreSQL Database\n(hr_employee, hr_contract, hr_recruitment,\nhr_attendance, hr_leave, hr_payslip)"]:::database
    end

    %% Modeling & Demo Data Artifacts
    subgraph "Modeling & Demo Data"
        subgraph "Design Artifacts"
            UC["Use-Case Diagrams"]:::document
            BPMN["BPMN Diagrams"]:::document
        end
        subgraph "Demo Data - Employee Domain"
            hr_contract_xls["Hợp đồng nhân viên\n(hr.contract).xlsx"]:::document
            hr_employee_xls["Nhân viên\n(hr.employee).xlsx"]:::document
            hr_department_xls["Phòng ban\n(hr.department).xlsx"]:::document
            import_seq["THỨ TỰ THỰC HIỆN.xlsx"]:::document
        end
        subgraph "Demo Data - Payroll Configuration"
            payroll_struct["Cấu trúc lương\n(hr.payroll.structure).xlsx"]:::document
            work_entry_type["HR Loại công\n(hr.work.entry.type).xlsx"]:::document
            resource_calendar["Nhân lực thời gian làm việc\n(resource.calendar).xlsx"]:::document
            salary_rule_group["Nhóm quy tắc Lương\n(hr.salary.rule.group).xlsx"]:::document
            salary_rule["Quy tắc lương\n(hr.salary.rule).xlsx"]:::document
            salary_rule_master["SalaryRule.xlsx"]:::document
        end
        subgraph "Demo Data - Payroll Timesheets & Payslips"
            timesheet["HR Công\n(hr.work.entry).xlsx"]:::document
            payslip_run["Lô Bảng lương\n(hr.payslip.run).xlsx"]:::document
            payslip["Phiếu lương\n(hr.payslip).xlsx"]:::document
            salary_structure_ref["SalaryStructure.xlsx"]:::document
        end
        FinalReport["Final Report Document"]:::document
        Markdown["README.md"]:::document
    end

    %% Relationships
    Browser -->|"HTTP/HTTPS"| WebClient
    WebClient -->|"JSON-RPC"| Controllers
    Controllers -->|"uses"| ORM
    Controllers -->|"renders"| Views
    Controllers -->|"invokes"| Recruit
    Controllers -->|"invokes"| EmployeeMod
    Controllers -->|"invokes"| ContractMod
    Controllers -->|"invokes"| Attendance
    Controllers -->|"invokes"| Leave
    Controllers -->|"invokes"| Payroll
    ORM -->|"CRUD Operations"| DB
    Payroll -->|"- - - REST/SOAP"| API
    hr_contract_xls -->|"Import Wizard"| Controllers
    hr_employee_xls -->|"Import Wizard"| Controllers
    hr_department_xls -->|"Import Wizard"| Controllers
    import_seq -->|"Guides Import"| Controllers
    payroll_struct -->|"Import Wizard"| Controllers
    work_entry_type -->|"Import Wizard"| Controllers
    resource_calendar -->|"Import Wizard"| Controllers
    salary_rule_group -->|"Import Wizard"| Controllers
    salary_rule -->|"Import Wizard"| Controllers
    salary_rule_master -->|"Reference Data"| Controllers
    timesheet -->|"Import Wizard"| Controllers
    payslip_run -->|"Import Wizard"| Controllers
    payslip -->|"Import Wizard"| Controllers
    salary_structure_ref -->|"Reference Data"| Controllers
    UC -.->|references| Recruit
    BPMN -.->|process for| Payroll

    %% Click Events
    click UC "https://github.com/lethimytram/erp-project-human-resources/blob/main/01 Usecase/UseCase.drawio"
    click BPMN "https://github.com/lethimytram/erp-project-human-resources/blob/main/02 Business Process (BPMN)/Business Process_BPMN.drawio"
    click hr_contract_xls "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/01 Nhân viên/Hợp đồng nhân viên (hr.contract).xlsx"
    click hr_employee_xls "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/01 Nhân viên/Nhân viên (hr.employee).xlsx"
    click hr_department_xls "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/01 Nhân viên/Phòng ban (hr.department).xlsx"
    click import_seq "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/01 Nhân viên/THỨ TỰ THỰC HIỆN.xlsx"
    click payroll_struct "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/Cấu trúc lương (hr.payroll.structur - 01.xlsx"
    click work_entry_type "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/HR Loại công (hr.work.entry.type).xlsx"
    click resource_calendar "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/Nhân lực thời gian làm việc (resource.calendar).xlsx"
    click salary_rule_group "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/Nhóm quy tắc Lương (hr.salary.rule.c.xlsx"
    click salary_rule "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/Quy tắc lương (hr.salary.rule).xlsx"
    click salary_rule_master "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/01 Cấu hình/SalaryRule.xlsx"
    click timesheet "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/02 Công/HR Công (hr.work.entry).xlsx"
    click payslip_run "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/03 Phiếu lương/Lô Bảng lương (hr.payslip.run).xlsx"
    click payslip "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/03 Phiếu lương/Phiếu lương (hr.payslip).xlsx"
    click salary_structure_ref "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/Demo Odoo Payroll/02 Bảng lương/03 Phiếu lương/SalaryStructure.xlsx"
    click FinalReport "https://github.com/lethimytram/erp-project-human-resources/blob/main/03 Report and Demo Odoo/FinalReport.docx"
    click Markdown "https://github.com/lethimytram/erp-project-human-resources/blob/main/README.md"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#2a7ae2,color:#002244
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724
    classDef database fill:#fff3cd,stroke:#ffc107,color:#856404
    classDef external fill:none,stroke:#6c757d,stroke-dasharray: 5 5,color:#6c757d
    classDef document fill:#e2e3e5,stroke:#6c757d,color:#343a40,shape:note
    classDef presentation,backend,database,external,document shape:rect,stroke-width:2px
```
