# lee5345/sesim-client-portal architecture

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

- Interactive diagram: https://gitdiagram.com/lee5345/sesim-client-portal
- Repository: https://github.com/lee5345/sesim-client-portal

## Overview

Sesim is a secure, multi-tenant portal for Korean labor firms to collect company HR/payroll data, manage client and firm operations, and export datasets to Excel. The main workflow is client or firm staff authentication, company-scoped intake and record management, then server-side export; firm staff also manage companies, accounts, tasks, and activity. The graph reflects documented architecture and sampled references. Several feature modules are represented from the tree and README, but their internal calls were not sampled, so unsupported connections are omitted.

Main entry points: [`lib/db/db.ts`](https://github.com/lee5345/sesim-client-portal/blob/main/lib/db/db.ts) (PostgreSQL via Prisma), [`modules/daily-workers/actions.ts`](https://github.com/lee5345/sesim-client-portal/blob/main/modules/daily-workers/actions.ts) (Daily worker records), [`components/client/daily-worker-form-dialog.tsx`](https://github.com/lee5345/sesim-client-portal/blob/main/components/client/daily-worker-form-dialog.tsx) (Daily worker form), [`modules/auth/client-users.ts`](https://github.com/lee5345/sesim-client-portal/blob/main/modules/auth/client-users.ts) (Client accounts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_authui["Sign-in and requests<br/>[page.tsx]"]
  node_auth["Auth.js session<br/>[auth.ts]"]
  node_guards["Role and session guards<br/>[guards.ts]"]
  node_authority["Session authority"]
end

subgraph group_intake["Client data intake"]
  node_hire["Hire intake<br/>[actions.ts]"]
  node_termination["Termination records<br/>[actions.ts]"]
  node_compchanges["Compensation changes<br/>[actions.ts]"]
  node_daily["Daily worker records<br/>[actions.ts]"]
  node_dailyform["Daily worker form"]
  node_dailycalc["Daily work calculations<br/>[calculations.ts]"]
  node_compinfo["Compensation information"]
  node_businessincome["Business income<br/>[actions.ts]"]
  node_dependents["Dependents<br/>[actions.ts]"]
  node_leave["Leave records<br/>[actions.ts]"]
end

subgraph group_firm["Firm operations"]
  node_companies["Company and departments<br/>[companies.ts]"]
  node_accounts["Client accounts<br/>[client-users.ts]"]
  node_office["Office task management<br/>[actions.ts]"]
  node_activity["Audit activity<br/>[actions.ts]"]
  node_dashboard["Role dashboards<br/>[client.ts]"]
end

subgraph group_platform["Application services"]
  node_database[("PostgreSQL via Prisma<br/>[db.ts]")]
  node_realtime["Tenant change sync<br/>[sync.ts]"]
end

subgraph group_exports["Data exports"]
  node_exports["Excel export generation<br/>[daily-workers.ts]"]
end

node_client(("Client company user"))
node_firmuser(("Firm staff"))

node_client -->|"signs in"| node_authui
node_firmuser -->|"signs in"| node_authui
node_authui -->|"authenticates"| node_auth
node_auth -->|"uses"| node_database
node_guards -->|"checks session"| node_auth
node_guards -->|"checks authority"| node_authority
node_client -.->|"submits intake"| node_hire
node_client -.->|"submits records"| node_termination
node_client -.->|"submits changes"| node_compchanges
node_client -->|"enters records"| node_dailyform
node_dailyform -->|"calculates hours"| node_dailycalc
node_dailyform -->|"reveals RRN"| node_daily
node_firmuser -.->|"manages companies"| node_companies
node_firmuser -->|"manages accounts"| node_accounts
node_firmuser -.->|"manages tasks"| node_office
node_firmuser -.->|"reviews activity"| node_activity
node_client -->|"reviews data"| node_compinfo
node_client -.->|"submits income"| node_businessincome
node_client -.->|"submits dependents"| node_dependents
node_client -.->|"submits leave"| node_leave
node_accounts -->|"reads and writes"| node_database
node_accounts -->|"bumps sync cursors"| node_realtime
node_daily -.->|"persists records"| node_database
node_hire -.->|"persists records"| node_database
node_termination -.->|"persists records"| node_database
node_compchanges -.->|"persists records"| node_database
node_daily -.->|"exports dataset"| node_exports
node_exports -.->|"reads records"| node_database
node_firmuser -.->|"views dashboard"| node_dashboard
node_client -->|"views dashboard"| node_dashboard
node_dashboard -->|"queries activity"| node_database

click node_authui "https://github.com/lee5345/sesim-client-portal/blob/main/app/(auth)/login/page.tsx"
click node_auth "https://github.com/lee5345/sesim-client-portal/blob/main/auth.ts"
click node_guards "https://github.com/lee5345/sesim-client-portal/blob/main/lib/auth/guards.ts"
click node_authority "https://github.com/lee5345/sesim-client-portal/blob/main/lib/auth/session-authority.ts"
click node_hire "https://github.com/lee5345/sesim-client-portal/blob/main/modules/hire-intakes/actions.ts"
click node_termination "https://github.com/lee5345/sesim-client-portal/blob/main/modules/terminations/actions.ts"
click node_compchanges "https://github.com/lee5345/sesim-client-portal/blob/main/modules/compensation-changes/actions.ts"
click node_daily "https://github.com/lee5345/sesim-client-portal/blob/main/modules/daily-workers/actions.ts"
click node_dailyform "https://github.com/lee5345/sesim-client-portal/blob/main/components/client/daily-worker-form-dialog.tsx"
click node_dailycalc "https://github.com/lee5345/sesim-client-portal/blob/main/lib/daily-workers/calculations.ts"
click node_compinfo "https://github.com/lee5345/sesim-client-portal/blob/main/components/compensation-info/compensation-info-table.tsx"
click node_businessincome "https://github.com/lee5345/sesim-client-portal/blob/main/modules/business-income/actions.ts"
click node_dependents "https://github.com/lee5345/sesim-client-portal/blob/main/modules/dependents/actions.ts"
click node_leave "https://github.com/lee5345/sesim-client-portal/blob/main/modules/leave-records/actions.ts"
click node_companies "https://github.com/lee5345/sesim-client-portal/blob/main/modules/companies/companies.ts"
click node_accounts "https://github.com/lee5345/sesim-client-portal/blob/main/modules/auth/client-users.ts"
click node_office "https://github.com/lee5345/sesim-client-portal/blob/main/modules/office-tasks/actions.ts"
click node_activity "https://github.com/lee5345/sesim-client-portal/blob/main/modules/audit-logs/actions.ts"
click node_dashboard "https://github.com/lee5345/sesim-client-portal/blob/main/modules/dashboard/client.ts"
click node_database "https://github.com/lee5345/sesim-client-portal/blob/main/lib/db/db.ts"
click node_exports "https://github.com/lee5345/sesim-client-portal/blob/main/lib/export/daily-workers.ts"
click node_realtime "https://github.com/lee5345/sesim-client-portal/blob/main/modules/realtime/sync.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_authui,node_auth,node_guards,node_authority,node_client toneBlue
class node_hire,node_termination,node_compchanges,node_daily,node_dailyform,node_dailycalc,node_compinfo,node_businessincome,node_dependents,node_leave toneAmber
class node_companies,node_accounts,node_office,node_activity,node_dashboard toneMint
class node_database,node_realtime toneRose
class node_exports,node_firmuser toneIndigo
```

## Components

### Identity and access

- [Sign-in and requests](https://github.com/lee5345/sesim-client-portal/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`
- [Auth.js session](https://github.com/lee5345/sesim-client-portal/blob/main/auth.ts): `auth.ts`
- [Role and session guards](https://github.com/lee5345/sesim-client-portal/blob/main/lib/auth/guards.ts): `lib/auth/guards.ts`
- [Session authority](https://github.com/lee5345/sesim-client-portal/blob/main/lib/auth/session-authority.ts): `lib/auth/session-authority.ts`

### Client data intake

- [Hire intake](https://github.com/lee5345/sesim-client-portal/blob/main/modules/hire-intakes/actions.ts): `modules/hire-intakes/actions.ts`
- [Termination records](https://github.com/lee5345/sesim-client-portal/blob/main/modules/terminations/actions.ts): `modules/terminations/actions.ts`
- [Compensation changes](https://github.com/lee5345/sesim-client-portal/blob/main/modules/compensation-changes/actions.ts): `modules/compensation-changes/actions.ts`
- [Daily worker records](https://github.com/lee5345/sesim-client-portal/blob/main/modules/daily-workers/actions.ts): `modules/daily-workers/actions.ts`
- [Daily worker form](https://github.com/lee5345/sesim-client-portal/blob/main/components/client/daily-worker-form-dialog.tsx): `components/client/daily-worker-form-dialog.tsx`
- [Daily work calculations](https://github.com/lee5345/sesim-client-portal/blob/main/lib/daily-workers/calculations.ts): `lib/daily-workers/calculations.ts`
- [Compensation information](https://github.com/lee5345/sesim-client-portal/blob/main/components/compensation-info/compensation-info-table.tsx): `components/compensation-info/compensation-info-table.tsx`
- [Business income](https://github.com/lee5345/sesim-client-portal/blob/main/modules/business-income/actions.ts): `modules/business-income/actions.ts`
- [Dependents](https://github.com/lee5345/sesim-client-portal/blob/main/modules/dependents/actions.ts): `modules/dependents/actions.ts`
- [Leave records](https://github.com/lee5345/sesim-client-portal/blob/main/modules/leave-records/actions.ts): `modules/leave-records/actions.ts`

### Firm operations

- [Company and departments](https://github.com/lee5345/sesim-client-portal/blob/main/modules/companies/companies.ts): `modules/companies/companies.ts`
- [Client accounts](https://github.com/lee5345/sesim-client-portal/blob/main/modules/auth/client-users.ts): `modules/auth/client-users.ts`
- [Office task management](https://github.com/lee5345/sesim-client-portal/blob/main/modules/office-tasks/actions.ts): `modules/office-tasks/actions.ts`
- [Audit activity](https://github.com/lee5345/sesim-client-portal/blob/main/modules/audit-logs/actions.ts): `modules/audit-logs/actions.ts`
- [Role dashboards](https://github.com/lee5345/sesim-client-portal/blob/main/modules/dashboard/client.ts): `modules/dashboard/client.ts`

### Application services

- [PostgreSQL via Prisma](https://github.com/lee5345/sesim-client-portal/blob/main/lib/db/db.ts): `lib/db/db.ts`
- [Tenant change sync](https://github.com/lee5345/sesim-client-portal/blob/main/modules/realtime/sync.ts): `modules/realtime/sync.ts`

### Data exports

- [Excel export generation](https://github.com/lee5345/sesim-client-portal/blob/main/lib/export/daily-workers.ts): `lib/export/daily-workers.ts`

### Other components

- **Client company user**
- **Firm staff**

## Connections

- Client company user → Sign-in and requests: signs in
- Firm staff → Sign-in and requests: signs in
- Sign-in and requests → Auth.js session: authenticates (evidence: `app/(auth)/login/page.tsx`)
- Auth.js session → PostgreSQL via Prisma: uses (evidence: `auth.ts`)
- Role and session guards → Auth.js session: checks session (evidence: `lib/auth/guards.ts`)
- Role and session guards → Session authority: checks authority (evidence: `lib/auth/guards.ts`)
- Client company user → Hire intake: submits intake
- Client company user → Termination records: submits records
- Client company user → Compensation changes: submits changes
- Client company user → Daily worker form: enters records (evidence: `components/client/daily-worker-form-dialog.tsx`)
- Daily worker form → Daily work calculations: calculates hours (evidence: `components/client/daily-worker-form-dialog.tsx`)
- Daily worker form → Daily worker records: reveals RRN (evidence: `components/client/daily-worker-form-dialog.tsx`)
- Firm staff → Company and departments: manages companies
- Firm staff → Client accounts: manages accounts
- Firm staff → Office task management: manages tasks
- Firm staff → Audit activity: reviews activity
- Client company user → Compensation information: reviews data
- Client company user → Business income: submits income
- Client company user → Dependents: submits dependents
- Client company user → Leave records: submits leave
- Client accounts → PostgreSQL via Prisma: reads and writes (evidence: `modules/auth/client-users.ts`)
- Client accounts → Tenant change sync: bumps sync cursors (evidence: `modules/auth/client-users.ts`)
- Daily worker records → PostgreSQL via Prisma: persists records
- Hire intake → PostgreSQL via Prisma: persists records
- Termination records → PostgreSQL via Prisma: persists records
- Compensation changes → PostgreSQL via Prisma: persists records
- Daily worker records → Excel export generation: exports dataset
- Excel export generation → PostgreSQL via Prisma: reads records
- Firm staff → Role dashboards: views dashboard
- Client company user → Role dashboards: views dashboard
- Role dashboards → PostgreSQL via Prisma: queries activity (evidence: `modules/dashboard/client.ts`)
