# thien-vnpt-cgo/umb_nhansu_database architecture

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

- Interactive diagram: https://gitdiagram.com/thien-vnpt-cgo/umb_nhansu_database
- Repository: https://github.com/thien-vnpt-cgo/umb_nhansu_database

## Overview

Ụm Bò Milk is an HR system with admin and employee web portals backed by a REST/Socket.IO server. The main workflow is employees and managers using the portals for attendance, scheduling, HR operations, and payroll; the backend applies domain services and persists master data in Google Sheets. The README documents GPS/photo attendance, role-based administration, and Zalo interview messaging. Some domain modules are listed in the source index but were not excerpted, so their internal calls are not expanded here.

Main entry points: [`apps/backend/src/app.ts`](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/app.ts) (REST API), [`apps/backend/src/repositories/single-writer-queue.ts`](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/single-writer-queue.ts) (Single Writer Queue), [`apps/backend/src/repositories/sheets.interface.ts`](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/sheets.interface.ts) (Repository Contract), [`apps/backend/src/server.ts`](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/server.ts) (API and Realtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["Web Portals"]
  node_admin["Admin Portal<br/>[App.tsx]"]
  node_employee["Employee Portal<br/>[App.tsx]"]
end

subgraph group_backend["Backend Services"]
  node_server["API and Realtime<br/>[server.ts]"]
  node_api["REST API<br/>[app.ts]"]
  node_auth["Accounts and Auth<br/>[auth.service.ts]"]
  node_employees["Employee and Hiring"]
  node_attendance["Attendance"]
  node_schedules["Schedules and Leave"]
  node_auto_schedule["Auto Scheduling"]
  node_weekly_off["Weekly Off"]
  node_payroll["Payroll<br/>[payroll.service.ts]"]
  node_notifications["Notifications"]
  node_reminders["Automated Reminders"]
  node_interview_dedupe["Interview Dedupe"]
  node_zalo_service["Zalo Messaging<br/>[zalo.service.ts]"]
end

subgraph group_data["Persistence"]
  node_writer["Single Writer Queue"]
  node_sheets_interface["Repository Contract"]
  node_sheets_adapter["Google Sheets Adapter"]
  node_photo_store[("Attendance Photos")]
end

subgraph group_shared["Shared Contracts"]
  node_shared_types["Shared Domain Types<br/>[attendance.ts]"]
  node_shared_grid["Attendance Grid<br/>[attendance-grid.ts]"]
end

subgraph group_integrations["External Integrations"]
  node_google_sheets[("Google Sheets")]
  node_zalo["Zalo"]
end

node_admin_actor(("Admin and HR"))
node_employee_actor(("Employee"))

node_admin_actor -->|"uses"| node_admin
node_employee_actor -->|"uses"| node_employee
node_admin -->|"calls API"| node_api
node_employee -->|"calls API"| node_api
node_server -->|"creates"| node_api
node_api -->|"uses"| node_auth
node_api -->|"uses"| node_employees
node_api -->|"uses"| node_attendance
node_api -->|"uses"| node_schedules
node_api -->|"uses"| node_auto_schedule
node_api -->|"uses"| node_weekly_off
node_api -->|"uses"| node_payroll
node_api -->|"calls"| node_interview_dedupe
node_api -->|"reads photos"| node_photo_store
node_server -->|"schedules ticks"| node_reminders
node_server -->|"sends notifications"| node_notifications
node_reminders -->|"sends"| node_notifications
node_reminders -->|"sends messages"| node_zalo_service
node_interview_dedupe -->|"notifies"| node_notifications
node_attendance -->|"queues writes"| node_writer
node_auto_schedule -->|"queues writes"| node_writer
node_schedules -->|"queues writes"| node_writer
node_payroll -->|"queues writes"| node_writer
node_writer -->|"uses contract"| node_sheets_interface
node_sheets_adapter -->|"implements"| node_sheets_interface
node_attendance -->|"reads and writes"| node_sheets_interface
node_employees -->|"reads and writes"| node_sheets_interface
node_payroll -->|"reads and writes"| node_sheets_interface
node_sheets_adapter -->|"reads and writes"| node_google_sheets
node_api -->|"uses domain data"| node_shared_types
node_employee -->|"uses domain data"| node_shared_types
node_shared_grid -.->|"uses types"| node_shared_types
node_zalo_service -->|"integrates"| node_zalo

click node_admin "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/admin-web/src/App.tsx"
click node_employee "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/employee-web/src/App.tsx"
click node_server "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/server.ts"
click node_api "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/app.ts"
click node_auth "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auth.service.ts"
click node_employees "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/employees.service.ts"
click node_attendance "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/attendance.service.ts"
click node_schedules "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/schedules.service.ts"
click node_auto_schedule "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auto-schedule.service.ts"
click node_weekly_off "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/weekly-off.service.ts"
click node_payroll "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/payroll.service.ts"
click node_notifications "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/notifications.service.ts"
click node_reminders "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auto-reminders.service.ts"
click node_interview_dedupe "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/interview-dedupe.service.ts"
click node_zalo_service "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/zalo.service.ts"
click node_writer "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/single-writer-queue.ts"
click node_sheets_interface "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/sheets.interface.ts"
click node_sheets_adapter "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/google-sheets.adapter.ts"
click node_photo_store "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/photo-disk.store.ts"
click node_shared_types "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/packages/shared/src/types/attendance.ts"
click node_shared_grid "https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/packages/shared/src/attendance-grid.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_admin,node_employee toneBlue
class node_server,node_api,node_auth,node_employees,node_attendance,node_schedules,node_auto_schedule,node_weekly_off,node_payroll,node_notifications,node_reminders,node_interview_dedupe,node_zalo_service toneAmber
class node_writer,node_sheets_interface,node_sheets_adapter,node_photo_store toneMint
class node_shared_types,node_shared_grid toneRose
class node_google_sheets,node_zalo,node_admin_actor,node_employee_actor toneIndigo
```

## Components

### Web Portals

- [Admin Portal](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/admin-web/src/App.tsx): `apps/admin-web/src/App.tsx`
- [Employee Portal](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/employee-web/src/App.tsx): `apps/employee-web/src/App.tsx`

### Backend Services

- [API and Realtime](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/server.ts): `apps/backend/src/server.ts`
- [REST API](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/app.ts): `apps/backend/src/app.ts`
- [Accounts and Auth](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auth.service.ts): `apps/backend/src/services/auth.service.ts`
- [Employee and Hiring](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/employees.service.ts): `apps/backend/src/services/employees.service.ts`
- [Attendance](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/attendance.service.ts): `apps/backend/src/services/attendance.service.ts`
- [Schedules and Leave](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/schedules.service.ts): `apps/backend/src/services/schedules.service.ts`
- [Auto Scheduling](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auto-schedule.service.ts): `apps/backend/src/services/auto-schedule.service.ts`
- [Weekly Off](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/weekly-off.service.ts): `apps/backend/src/services/weekly-off.service.ts`
- [Payroll](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/payroll.service.ts): `apps/backend/src/services/payroll.service.ts`
- [Notifications](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/notifications.service.ts): `apps/backend/src/services/notifications.service.ts`
- [Automated Reminders](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/auto-reminders.service.ts): `apps/backend/src/services/auto-reminders.service.ts`
- [Interview Dedupe](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/interview-dedupe.service.ts): `apps/backend/src/services/interview-dedupe.service.ts`
- [Zalo Messaging](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/zalo.service.ts): `apps/backend/src/services/zalo.service.ts`

### Persistence

- [Single Writer Queue](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/single-writer-queue.ts): `apps/backend/src/repositories/single-writer-queue.ts`
- [Repository Contract](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/sheets.interface.ts): `apps/backend/src/repositories/sheets.interface.ts`
- [Google Sheets Adapter](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/repositories/google-sheets.adapter.ts): `apps/backend/src/repositories/google-sheets.adapter.ts`
- [Attendance Photos](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/apps/backend/src/services/photo-disk.store.ts): `apps/backend/src/services/photo-disk.store.ts`

### Shared Contracts

- [Shared Domain Types](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/packages/shared/src/types/attendance.ts): `packages/shared/src/types/attendance.ts`
- [Attendance Grid](https://github.com/thien-vnpt-cgo/umb_nhansu_database/blob/main/packages/shared/src/attendance-grid.ts): `packages/shared/src/attendance-grid.ts`

### External Integrations

- **Google Sheets**
- **Zalo**

### Other components

- **Admin and HR**
- **Employee**

## Connections

- Admin and HR → Admin Portal: uses (evidence: `README.md`)
- Employee → Employee Portal: uses (evidence: `README.md`)
- Admin Portal → REST API: calls API (evidence: `apps/admin-web/src/App.tsx`)
- Employee Portal → REST API: calls API (evidence: `apps/employee-web/src/App.tsx`)
- API and Realtime → REST API: creates (evidence: `apps/backend/src/server.ts`)
- REST API → Accounts and Auth: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Employee and Hiring: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Attendance: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Schedules and Leave: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Auto Scheduling: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Weekly Off: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Payroll: uses (evidence: `apps/backend/src/app.ts`)
- REST API → Interview Dedupe: calls (evidence: `apps/backend/src/app.ts`)
- REST API → Attendance Photos: reads photos (evidence: `apps/backend/src/app.ts`)
- API and Realtime → Automated Reminders: schedules ticks (evidence: `apps/backend/src/server.ts`)
- API and Realtime → Notifications: sends notifications (evidence: `apps/backend/src/server.ts`)
- Automated Reminders → Notifications: sends (evidence: `apps/backend/src/services/auto-reminders.service.ts`)
- Automated Reminders → Zalo Messaging: sends messages (evidence: `apps/backend/src/services/auto-reminders.service.ts`)
- Interview Dedupe → Notifications: notifies (evidence: `apps/backend/src/services/interview-dedupe.service.ts`)
- Attendance → Single Writer Queue: queues writes (evidence: `apps/backend/src/services/attendance.service.ts`)
- Auto Scheduling → Single Writer Queue: queues writes (evidence: `apps/backend/src/services/auto-schedule.service.ts`)
- Schedules and Leave → Single Writer Queue: queues writes (evidence: `apps/backend/src/services/schedules.service.ts`)
- Payroll → Single Writer Queue: queues writes (evidence: `apps/backend/src/services/payroll.service.ts`)
- Single Writer Queue → Repository Contract: uses contract (evidence: `apps/backend/src/repositories/single-writer-queue.ts`)
- Google Sheets Adapter → Repository Contract: implements (evidence: `apps/backend/src/repositories/google-sheets.adapter.ts`)
- Attendance → Repository Contract: reads and writes (evidence: `apps/backend/src/services/attendance.service.ts`)
- Employee and Hiring → Repository Contract: reads and writes (evidence: `apps/backend/src/services/employees.service.ts`)
- Payroll → Repository Contract: reads and writes (evidence: `apps/backend/src/services/payroll.service.ts`)
- Google Sheets Adapter → Google Sheets: reads and writes (evidence: `README.md`)
- REST API → Shared Domain Types: uses domain data
- Employee Portal → Shared Domain Types: uses domain data (evidence: `apps/employee-web/src/App.tsx`)
- Attendance Grid → Shared Domain Types: uses types
- Zalo Messaging → Zalo: integrates (evidence: `README.md`)
