# ytkaaaaaaaaa/iw3 architecture

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

- Interactive diagram: https://gitdiagram.com/ytkaaaaaaaaa/iw3
- Repository: https://github.com/ytkaaaaaaaaa/iw3

## Overview

This is a workforce-dispatch application for managing companies, workers, vacancies, schedules, attendance reports, travel, and external data synchronization. The principal workflow is dispatcher login, loading scoped workforce data into workspace views, editing vacancy staffing schedules, and persisting those changes through authenticated APIs. The graph includes the key domain stages and sync/travel capabilities documented by the source index and tree. Most route and view implementations were not sampled, so their connections are included only where source-index references or excerpts support them.

Main entry points: [`app`](https://github.com/ytkaaaaaaaaa/iw3/tree/master/app) (Workspace pages), [`app/api/sync/route.ts`](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/sync/route.ts) (Sync API), [`app/api/vacancies/[slug]/schedule/route.ts`](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/vacancies/%5Bslug%5D/schedule/route.ts) (Schedule API), [`lib/auth/guard.ts`](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/auth/guard.ts) (Session guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Dispatcher workspace"]
  node_login["Login UI<br/>[login-form.tsx]"]
  node_shell["App shell<br/>[app-shell.tsx]"]
  node_pages["Workspace pages"]
end

subgraph group_domain["Workforce operations"]
  node_companies["Company management<br/>[companies-view.tsx]"]
  node_people["People management<br/>[people-view.tsx]"]
  node_vacancies["Vacancy management<br/>[vacancies-view.tsx]"]
  node_schedule_ui["Schedule workspace"]
  node_schedule_api["Schedule API<br/>[route.ts]"]
  node_hours["Hours and reports<br/>[hours-view.tsx]"]
  node_map["Map workspace<br/>[map-view.tsx]"]
  node_search["People search<br/>[search-dialog.tsx]"]
  node_sync_ui["Sync controls<br/>[sync-view.tsx]"]
  node_reports_api["Report endpoints<br/>[route.ts]"]
end

subgraph group_services["Application services"]
  node_auth["Session guard<br/>[guard.ts]"]
  node_data_context["Workforce context"]
  node_page_data["Page data loader<br/>[page-data.ts]"]
  node_workforce_db["Workforce queries<br/>[workforce.ts]"]
  node_database[("PostgreSQL<br/>[index.ts]")]
  node_schedule_persist["Schedule persistence"]
  node_derive["Staffing calculations<br/>[derive.ts]"]
end

subgraph group_integrations["Data integrations"]
  node_sync_api["Sync API<br/>[route.ts]"]
  node_warehouse["Warehouse sync"]
  node_flexpedia["Flexpedia sync<br/>[flexpedia-sync.ts]"]
  node_travel["Travel distances<br/>[services.ts]"]
  node_geocode["Geocoding API<br/>[route.ts]"]
end

node_dispatcher(("Dispatcher"))

node_dispatcher -->|"signs in"| node_login
node_login -->|"starts session"| node_auth
node_dispatcher -->|"uses workspace"| node_pages
node_pages -->|"checks session"| node_auth
node_pages -->|"loads data"| node_page_data
node_page_data -->|"loads workforce"| node_workforce_db
node_workforce_db -.->|"queries"| node_database
node_pages -->|"provides data"| node_data_context
node_pages -->|"renders shell"| node_shell
node_pages -->|"renders view"| node_companies
node_pages -->|"renders view"| node_people
node_pages -->|"renders view"| node_vacancies
node_pages -.->|"renders schedule"| node_schedule_ui
node_schedule_ui -.->|"saves schedule"| node_schedule_api
node_schedule_api -->|"checks session"| node_auth
node_schedule_api -->|"parses snapshot"| node_schedule_persist
node_schedule_api -->|"reads and writes"| node_database
node_schedule_ui -->|"calculates staffing"| node_derive
node_pages -->|"renders view"| node_hours
node_pages -->|"renders workspace"| node_map
node_shell -->|"opens search"| node_search
node_pages -->|"renders view"| node_sync_ui
node_sync_ui -.->|"requests sync"| node_sync_api
node_sync_api -->|"checks session"| node_auth
node_sync_api -->|"runs warehouse sync"| node_warehouse
node_sync_api -->|"runs employee sync"| node_flexpedia
node_sync_api -->|"refreshes distances"| node_travel
node_map -.->|"looks up addresses"| node_geocode
node_hours -.->|"submits reports"| node_reports_api

click node_login "https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/login/login-form.tsx"
click node_auth "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/auth/guard.ts"
click node_shell "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/app-shell.tsx"
click node_pages "https://github.com/ytkaaaaaaaaa/iw3/tree/master/app"
click node_data_context "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/workforce-data-context.tsx"
click node_page_data "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/page-data.ts"
click node_workforce_db "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/workforce.ts"
click node_database "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/index.ts"
click node_companies "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/companies-view.tsx"
click node_people "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/people/people-view.tsx"
click node_vacancies "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/vacancies/vacancies-view.tsx"
click node_schedule_ui "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/vacancy-schedule.tsx"
click node_schedule_api "https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/vacancies/%5Bslug%5D/schedule/route.ts"
click node_schedule_persist "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/schedule-persistence.ts"
click node_derive "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/derive.ts"
click node_hours "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/hours/hours-view.tsx"
click node_map "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/map-view.tsx"
click node_search "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/search-dialog.tsx"
click node_sync_ui "https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/sync-view.tsx"
click node_sync_api "https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/sync/route.ts"
click node_warehouse "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/sync/supabase-warehouse.ts"
click node_flexpedia "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/sync/flexpedia-sync.ts"
click node_travel "https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/travel/services.ts"
click node_geocode "https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/geocode/route.ts"
click node_reports_api "https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/vacancies/%5Bslug%5D/reports/route.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_login,node_shell,node_pages toneBlue
class node_companies,node_people,node_vacancies,node_schedule_ui,node_schedule_api,node_hours,node_map,node_search,node_sync_ui,node_reports_api toneAmber
class node_auth,node_data_context,node_page_data,node_workforce_db,node_database,node_schedule_persist,node_derive toneMint
class node_sync_api,node_warehouse,node_flexpedia,node_travel,node_geocode toneRose
class node_dispatcher toneIndigo
```

## Components

### Dispatcher workspace

- [Login UI](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/login/login-form.tsx): `app/login/login-form.tsx`
- [App shell](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/app-shell.tsx): `components/app-shell.tsx`
- [Workspace pages](https://github.com/ytkaaaaaaaaa/iw3/tree/master/app): `app`

### Workforce operations

- [Company management](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/companies-view.tsx): `components/companies-view.tsx`
- [People management](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/people/people-view.tsx): `components/people/people-view.tsx`
- [Vacancy management](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/vacancies/vacancies-view.tsx): `components/vacancies/vacancies-view.tsx`
- [Schedule workspace](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/vacancy-schedule.tsx): `components/vacancy-schedule.tsx`
- [Schedule API](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/vacancies/%5Bslug%5D/schedule/route.ts): `app/api/vacancies/[slug]/schedule/route.ts`
- [Hours and reports](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/hours/hours-view.tsx): `components/hours/hours-view.tsx`
- [Map workspace](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/map-view.tsx): `components/map-view.tsx`
- [People search](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/search-dialog.tsx): `components/search-dialog.tsx`
- [Sync controls](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/sync-view.tsx): `components/sync-view.tsx`
- [Report endpoints](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/vacancies/%5Bslug%5D/reports/route.ts): `app/api/vacancies/[slug]/reports/route.ts`

### Application services

- [Session guard](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/auth/guard.ts): `lib/auth/guard.ts`
- [Workforce context](https://github.com/ytkaaaaaaaaa/iw3/blob/master/components/workforce-data-context.tsx): `components/workforce-data-context.tsx`
- [Page data loader](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/page-data.ts): `lib/db/page-data.ts`
- [Workforce queries](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/workforce.ts): `lib/db/workforce.ts`
- [PostgreSQL](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/db/index.ts): `lib/db/index.ts`
- [Schedule persistence](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/schedule-persistence.ts): `lib/schedule-persistence.ts`
- [Staffing calculations](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/derive.ts): `lib/derive.ts`

### Data integrations

- [Sync API](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/sync/route.ts): `app/api/sync/route.ts`
- [Warehouse sync](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/sync/supabase-warehouse.ts): `lib/sync/supabase-warehouse.ts`
- [Flexpedia sync](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/sync/flexpedia-sync.ts): `lib/sync/flexpedia-sync.ts`
- [Travel distances](https://github.com/ytkaaaaaaaaa/iw3/blob/master/lib/travel/services.ts): `lib/travel/services.ts`
- [Geocoding API](https://github.com/ytkaaaaaaaaa/iw3/blob/master/app/api/geocode/route.ts): `app/api/geocode/route.ts`

### Other components

- **Dispatcher**

## Connections

- Dispatcher → Login UI: signs in
- Login UI → Session guard: starts session (evidence: `app/login/login-form.tsx`)
- Dispatcher → Workspace pages: uses workspace (evidence: `app/companies/page.tsx`)
- Workspace pages → Session guard: checks session (evidence: `app/companies/page.tsx`)
- Workspace pages → Page data loader: loads data (evidence: `app/companies/page.tsx`)
- Page data loader → Workforce queries: loads workforce (evidence: `lib/db/page-data.ts`)
- Workforce queries → PostgreSQL: queries
- Workspace pages → Workforce context: provides data (evidence: `app/companies/page.tsx`)
- Workspace pages → App shell: renders shell
- Workspace pages → Company management: renders view (evidence: `app/companies/page.tsx`)
- Workspace pages → People management: renders view (evidence: `app/people/page.tsx`)
- Workspace pages → Vacancy management: renders view (evidence: `app/vacancies/page.tsx`)
- Workspace pages → Schedule workspace: renders schedule
- Schedule workspace → Schedule API: saves schedule
- Schedule API → Session guard: checks session (evidence: `app/api/vacancies/[slug]/schedule/route.ts`)
- Schedule API → Schedule persistence: parses snapshot (evidence: `app/api/vacancies/[slug]/schedule/route.ts`)
- Schedule API → PostgreSQL: reads and writes (evidence: `app/api/vacancies/[slug]/schedule/route.ts`)
- Schedule workspace → Staffing calculations: calculates staffing
- Workspace pages → Hours and reports: renders view (evidence: `app/hours/page.tsx`)
- Workspace pages → Map workspace: renders workspace
- App shell → People search: opens search (evidence: `components/app-shell.tsx`)
- Workspace pages → Sync controls: renders view (evidence: `app/sync/page.tsx`)
- Sync controls → Sync API: requests sync
- Sync API → Session guard: checks session (evidence: `app/api/sync/route.ts`)
- Sync API → Warehouse sync: runs warehouse sync (evidence: `app/api/sync/route.ts`)
- Sync API → Flexpedia sync: runs employee sync (evidence: `app/api/sync/route.ts`)
- Sync API → Travel distances: refreshes distances (evidence: `app/api/sync/route.ts`)
- Map workspace → Geocoding API: looks up addresses
- Hours and reports → Report endpoints: submits reports
