# pgswork8686-stack/builder-web-app-pgs-agency- architecture

> Architecture diagram of the GitHub repository pgswork8686-stack/builder-web-app-pgs-agency-, 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/pgswork8686-stack/builder-web-app-pgs-agency-
- Repository: https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-

## Overview

PGS Hub is an agency operations platform with role-based internal dashboards and a client portal. Users authenticate, enter role-appropriate workspaces, and use web screens that communicate with a NestJS REST/realtime API backed by Supabase. The domain spans workforce administration, project delivery, finance, and collaboration/automation. The README documents the major capabilities and stack; sampled controller excerpts and the SOURCE INDEX confirm selected service calls. Many subsystem implementations were not sampled, so their internal links are omitted rather than inferred.

Main entry points: [`apps/web/lib/api/client.ts`](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/web/lib/api/client.ts) (Web API adapters), [`apps/api/src/supabase/supabase.service.ts`](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/supabase/supabase.service.ts) (Supabase services), [`apps/api/src/attendance/attendance.service.ts`](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/attendance/attendance.service.ts) (Attendance), [`apps/api/src/chat/chat.service.ts`](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/chat/chat.service.ts) (Chat and realtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["Role dashboards<br/>[page.tsx]"]
  node_webapi["Web API adapters<br/>[client.ts]"]
end

subgraph group_workforce["Workforce operations"]
  node_people["People and organization<br/>[people.service.ts]"]
  node_attendance["Attendance"]
  node_leave["Leave management<br/>[leave.service.ts]"]
  node_payroll["Payroll<br/>[payroll.service.ts]"]
  node_workcalendar["Work calendar"]
end

subgraph group_delivery["Project delivery"]
  node_projects["Projects and memberships"]
  node_tasks["Tasks<br/>[tasks.service.ts]"]
  node_workflows["Workflow templates and runtime"]
  node_workspace["Project workspace and files"]
  node_services["Service catalog"]
end

subgraph group_business["Finance and clients"]
  node_finance["Finance<br/>[finance.service.ts]"]
  node_expenses["Expenses"]
  node_clients["Client management<br/>[clients.service.ts]"]
  node_documents["Documents"]
  node_support["Client support<br/>[support.service.ts]"]
end

subgraph group_platform["API and collaboration"]
  node_auth["Authentication and access<br/>[auth.guard.ts]"]
  node_supabase[("Supabase services")]
  node_notifications["Notifications"]
  node_chat["Chat and realtime<br/>[chat.service.ts]"]
  node_automation["Automation"]
end

node_users(("Staff and clients"))

node_users -->|"use"| node_web
node_web -->|"request data"| node_webapi
node_webapi -->|"call REST API"| node_auth
node_auth -->|"verify token and profile"| node_supabase
node_webapi -.->|"request people data"| node_people
node_webapi -.->|"request project data"| node_projects
node_webapi -.->|"request finance data"| node_finance
node_webapi -.->|"request attendance data"| node_attendance
node_webapi -.->|"request workflow data"| node_workflows
node_webapi -.->|"request chat data"| node_chat
node_webapi -.->|"request notifications"| node_notifications
node_people -.->|"persist records"| node_supabase
node_attendance -->|"read and write"| node_supabase
node_attendance -->|"notify"| node_notifications
node_attendance -->|"invoke automation"| node_automation
node_projects -.->|"persist records"| node_supabase
node_workflows -.->|"persist templates"| node_supabase
node_finance -.->|"read and write"| node_supabase
node_payroll -.->|"use attendance records"| node_attendance
node_chat -->|"read and write"| node_supabase
node_chat -->|"notify"| node_notifications
node_chat -->|"invoke automation"| node_automation
node_automation -->|"read and write"| node_supabase
node_automation -->|"notify"| node_notifications

click node_web "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/web/app/app/page.tsx"
click node_webapi "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/web/lib/api/client.ts"
click node_auth "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/auth/auth.guard.ts"
click node_supabase "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/supabase/supabase.service.ts"
click node_people "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/people/people.service.ts"
click node_attendance "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/attendance/attendance.service.ts"
click node_leave "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/leave/leave.service.ts"
click node_payroll "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/payroll/payroll.service.ts"
click node_workcalendar "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/work-calendar/work-calendar.service.ts"
click node_projects "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/projects/projects.service.ts"
click node_tasks "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/tasks/tasks.service.ts"
click node_workflows "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/workflows/workflow.service.ts"
click node_workspace "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/workspace/workspace.service.ts"
click node_services "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/services/services.service.ts"
click node_finance "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/finance/finance.service.ts"
click node_expenses "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/expenses/expenses.service.ts"
click node_clients "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/clients/clients.service.ts"
click node_documents "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/documents/documents.service.ts"
click node_notifications "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/notifications/notifications.service.ts"
click node_chat "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/chat/chat.service.ts"
click node_automation "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/automation/automation.service.ts"
click node_support "https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/support/support.service.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_web,node_webapi,node_users toneBlue
class node_people,node_attendance,node_leave,node_payroll,node_workcalendar toneAmber
class node_projects,node_tasks,node_workflows,node_workspace,node_services toneMint
class node_finance,node_expenses,node_clients,node_documents,node_support toneRose
class node_auth,node_supabase,node_notifications,node_chat,node_automation toneIndigo
```

## Components

### Web experience

- [Role dashboards](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/web/app/app/page.tsx): `apps/web/app/app/page.tsx`
- [Web API adapters](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/web/lib/api/client.ts): `apps/web/lib/api/client.ts`

### Workforce operations

- [People and organization](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/people/people.service.ts): `apps/api/src/people/people.service.ts`
- [Attendance](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/attendance/attendance.service.ts): `apps/api/src/attendance/attendance.service.ts`
- [Leave management](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/leave/leave.service.ts): `apps/api/src/leave/leave.service.ts`
- [Payroll](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/payroll/payroll.service.ts): `apps/api/src/payroll/payroll.service.ts`
- [Work calendar](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/work-calendar/work-calendar.service.ts): `apps/api/src/work-calendar/work-calendar.service.ts`

### Project delivery

- [Projects and memberships](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/projects/projects.service.ts): `apps/api/src/projects/projects.service.ts`
- [Tasks](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/tasks/tasks.service.ts): `apps/api/src/tasks/tasks.service.ts`
- [Workflow templates and runtime](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/workflows/workflow.service.ts): `apps/api/src/workflows/workflow.service.ts`
- [Project workspace and files](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/workspace/workspace.service.ts): `apps/api/src/workspace/workspace.service.ts`
- [Service catalog](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/services/services.service.ts): `apps/api/src/services/services.service.ts`

### Finance and clients

- [Finance](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/finance/finance.service.ts): `apps/api/src/finance/finance.service.ts`
- [Expenses](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/expenses/expenses.service.ts): `apps/api/src/expenses/expenses.service.ts`
- [Client management](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/clients/clients.service.ts): `apps/api/src/clients/clients.service.ts`
- [Documents](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/documents/documents.service.ts): `apps/api/src/documents/documents.service.ts`
- [Client support](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/support/support.service.ts): `apps/api/src/support/support.service.ts`

### API and collaboration

- [Authentication and access](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/auth/auth.guard.ts): `apps/api/src/auth/auth.guard.ts`
- [Supabase services](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/supabase/supabase.service.ts): `apps/api/src/supabase/supabase.service.ts`
- [Notifications](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/notifications/notifications.service.ts): `apps/api/src/notifications/notifications.service.ts`
- [Chat and realtime](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/chat/chat.service.ts): `apps/api/src/chat/chat.service.ts`
- [Automation](https://github.com/pgswork8686-stack/builder-web-app-pgs-agency-/blob/main/apps/api/src/automation/automation.service.ts): `apps/api/src/automation/automation.service.ts`

### Other components

- **Staff and clients**

## Connections

- Staff and clients → Role dashboards: use (evidence: `README.md`)
- Role dashboards → Web API adapters: request data (evidence: `README.md`)
- Web API adapters → Authentication and access: call REST API (evidence: `README.md`)
- Authentication and access → Supabase services: verify token and profile (evidence: `apps/api/src/auth/auth.guard.ts`)
- Web API adapters → People and organization: request people data
- Web API adapters → Projects and memberships: request project data
- Web API adapters → Finance: request finance data
- Web API adapters → Attendance: request attendance data
- Web API adapters → Workflow templates and runtime: request workflow data
- Web API adapters → Chat and realtime: request chat data
- Web API adapters → Notifications: request notifications
- People and organization → Supabase services: persist records
- Attendance → Supabase services: read and write (evidence: `apps/api/src/attendance/attendance.service.ts`)
- Attendance → Notifications: notify (evidence: `apps/api/src/attendance/attendance.service.ts`)
- Attendance → Automation: invoke automation (evidence: `apps/api/src/attendance/attendance.service.ts`)
- Projects and memberships → Supabase services: persist records
- Workflow templates and runtime → Supabase services: persist templates
- Finance → Supabase services: read and write
- Payroll → Attendance: use attendance records
- Chat and realtime → Supabase services: read and write (evidence: `apps/api/src/chat/chat.service.ts`)
- Chat and realtime → Notifications: notify (evidence: `apps/api/src/chat/chat.service.ts`)
- Chat and realtime → Automation: invoke automation (evidence: `apps/api/src/chat/chat.service.ts`)
- Automation → Supabase services: read and write (evidence: `apps/api/src/automation/automation.service.ts`)
- Automation → Notifications: notify (evidence: `apps/api/src/automation/automation.service.ts`)
