# sgxtract/pms architecture

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

- Interactive diagram: https://gitdiagram.com/sgxtract/pms
- Repository: https://github.com/sgxtract/pms

## Overview

This is an early Procurement Monitoring System web application scaffold: the layout describes tracking requests through completion, but the sampled runtime contains no procurement-request screens or workflow handlers. The visible product surface is the Next.js app shell, a design-system preview, and a database health endpoint; the migration tree signals user, lookup, request, history, and audit data. An operator can bootstrap the first admin account. Connections below are limited to relationships visible in excerpts or documented in the README; unsampled migration behavior is not inferred.

Main entry points: [`scripts/create-admin.ts`](https://github.com/sgxtract/pms/blob/main/scripts/create-admin.ts) (Create first admin), [`src/server/db.ts`](https://github.com/sgxtract/pms/blob/main/src/server/db.ts) (Database client), [`src/app/styleguide/page.tsx`](https://github.com/sgxtract/pms/blob/main/src/app/styleguide/page.tsx) (Design preview), [`src/components/ui/button.tsx`](https://github.com/sgxtract/pms/blob/main/src/components/ui/button.tsx) (Button)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Web application"]
  node_app_shell["Application shell<br/>[layout.tsx]"]
  node_home["Home page<br/>[page.tsx]"]
  node_styleguide["Design preview<br/>[page.tsx]"]
  node_health["Health endpoint<br/>[route.ts]"]
end

subgraph group_ui["Interface components"]
  node_theme_provider["Theme provider<br/>[theme-provider.tsx]"]
  node_button["Button<br/>[button.tsx]"]
  node_badge["Badge<br/>[badge.tsx]"]
  node_theme_toggle["Theme toggle<br/>[theme-toggle.tsx]"]
  node_class_utils["Class utilities<br/>[utils.ts]"]
end

subgraph group_server["Server and data"]
  node_database_client["Database client<br/>[db.ts]"]
  node_environment["Environment validation<br/>[env.ts]"]
  node_postgres[("PostgreSQL")]
  node_schema_migrations["Domain schema migrations"]
end

subgraph group_bootstrap["Admin bootstrap"]
  node_admin_setup["Create first admin<br/>[create-admin.ts]"]
  node_password_rules["Password validation<br/>[password.ts]"]
  node_password_hashing["Password hashing<br/>[password.ts]"]
end

node_visitor(("Web visitor"))
node_admin_operator(("Admin operator"))

node_visitor -->|"opens app"| node_home
node_app_shell -->|"wraps pages"| node_theme_provider
node_styleguide -->|"renders"| node_button
node_styleguide -->|"renders"| node_badge
node_styleguide -->|"renders"| node_theme_toggle
node_theme_toggle -->|"uses"| node_button
node_button -->|"merges classes"| node_class_utils
node_badge -->|"merges classes"| node_class_utils
node_health -->|"queries"| node_database_client
node_database_client -->|"reads settings"| node_environment
node_database_client -->|"connects"| node_postgres
node_admin_operator -->|"runs setup"| node_admin_setup
node_admin_setup -->|"validates password"| node_password_rules
node_admin_setup -->|"hashes password"| node_password_hashing
node_admin_setup -->|"creates account"| node_database_client
node_schema_migrations -.->|"defines schema"| node_postgres

click node_app_shell "https://github.com/sgxtract/pms/blob/main/src/app/layout.tsx"
click node_home "https://github.com/sgxtract/pms/blob/main/src/app/page.tsx"
click node_styleguide "https://github.com/sgxtract/pms/blob/main/src/app/styleguide/page.tsx"
click node_health "https://github.com/sgxtract/pms/blob/main/src/app/api/health/route.ts"
click node_theme_provider "https://github.com/sgxtract/pms/blob/main/src/components/providers/theme-provider.tsx"
click node_button "https://github.com/sgxtract/pms/blob/main/src/components/ui/button.tsx"
click node_badge "https://github.com/sgxtract/pms/blob/main/src/components/ui/badge.tsx"
click node_theme_toggle "https://github.com/sgxtract/pms/blob/main/src/components/ui/theme-toggle.tsx"
click node_class_utils "https://github.com/sgxtract/pms/blob/main/src/lib/utils.ts"
click node_database_client "https://github.com/sgxtract/pms/blob/main/src/server/db.ts"
click node_environment "https://github.com/sgxtract/pms/blob/main/src/server/env.ts"
click node_schema_migrations "https://github.com/sgxtract/pms/tree/main/db/migrations"
click node_admin_setup "https://github.com/sgxtract/pms/blob/main/scripts/create-admin.ts"
click node_password_rules "https://github.com/sgxtract/pms/blob/main/src/lib/validation/password.ts"
click node_password_hashing "https://github.com/sgxtract/pms/blob/main/src/server/auth/password.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_app_shell,node_home,node_styleguide,node_health toneBlue
class node_theme_provider,node_button,node_badge,node_theme_toggle,node_class_utils toneAmber
class node_database_client,node_environment,node_postgres,node_schema_migrations toneMint
class node_admin_setup,node_password_rules,node_password_hashing toneRose
class node_visitor,node_admin_operator toneIndigo
```

## Components

### Web application

- [Application shell](https://github.com/sgxtract/pms/blob/main/src/app/layout.tsx): `src/app/layout.tsx`
- [Home page](https://github.com/sgxtract/pms/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Design preview](https://github.com/sgxtract/pms/blob/main/src/app/styleguide/page.tsx): `src/app/styleguide/page.tsx`
- [Health endpoint](https://github.com/sgxtract/pms/blob/main/src/app/api/health/route.ts): `src/app/api/health/route.ts`

### Interface components

- [Theme provider](https://github.com/sgxtract/pms/blob/main/src/components/providers/theme-provider.tsx): `src/components/providers/theme-provider.tsx`
- [Button](https://github.com/sgxtract/pms/blob/main/src/components/ui/button.tsx): `src/components/ui/button.tsx`
- [Badge](https://github.com/sgxtract/pms/blob/main/src/components/ui/badge.tsx): `src/components/ui/badge.tsx`
- [Theme toggle](https://github.com/sgxtract/pms/blob/main/src/components/ui/theme-toggle.tsx): `src/components/ui/theme-toggle.tsx`
- [Class utilities](https://github.com/sgxtract/pms/blob/main/src/lib/utils.ts): `src/lib/utils.ts`

### Server and data

- [Database client](https://github.com/sgxtract/pms/blob/main/src/server/db.ts): `src/server/db.ts`
- [Environment validation](https://github.com/sgxtract/pms/blob/main/src/server/env.ts): `src/server/env.ts`
- **PostgreSQL**
- [Domain schema migrations](https://github.com/sgxtract/pms/tree/main/db/migrations): `db/migrations`

### Admin bootstrap

- [Create first admin](https://github.com/sgxtract/pms/blob/main/scripts/create-admin.ts): `scripts/create-admin.ts`
- [Password validation](https://github.com/sgxtract/pms/blob/main/src/lib/validation/password.ts): `src/lib/validation/password.ts`
- [Password hashing](https://github.com/sgxtract/pms/blob/main/src/server/auth/password.ts): `src/server/auth/password.ts`

### Other components

- **Web visitor**
- **Admin operator**

## Connections

- Web visitor → Home page: opens app (evidence: `README.md`)
- Application shell → Theme provider: wraps pages (evidence: `src/app/layout.tsx`)
- Design preview → Button: renders (evidence: `src/app/styleguide/page.tsx`)
- Design preview → Badge: renders (evidence: `src/app/styleguide/page.tsx`)
- Design preview → Theme toggle: renders (evidence: `src/app/styleguide/page.tsx`)
- Theme toggle → Button: uses (evidence: `src/components/ui/theme-toggle.tsx`)
- Button → Class utilities: merges classes (evidence: `src/components/ui/button.tsx`)
- Badge → Class utilities: merges classes (evidence: `src/components/ui/badge.tsx`)
- Health endpoint → Database client: queries (evidence: `src/app/api/health/route.ts`)
- Database client → Environment validation: reads settings (evidence: `src/server/db.ts`)
- Database client → PostgreSQL: connects (evidence: `src/server/db.ts`)
- Admin operator → Create first admin: runs setup (evidence: `README.md`)
- Create first admin → Password validation: validates password (evidence: `scripts/create-admin.ts`)
- Create first admin → Password hashing: hashes password (evidence: `scripts/create-admin.ts`)
- Create first admin → Database client: creates account (evidence: `scripts/create-admin.ts`)
- Domain schema migrations → PostgreSQL: defines schema
