2026-07-17 13:17:21 -04:00
# SHOC Frontend (`shoc-frontend-new`)
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
[](https://github.com/Sea-Haven-Industries/shoc-frontend-new/actions/workflows/ci.yaml)
[](https://github.com/Sea-Haven-Industries/shoc-frontend-new/actions/workflows/deploy.yml)



2026-09-11 13:40:14 -04:00

2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
Vite + React SPA for Sea Haven facility management (SHOC): work orders, vendor
portal, uplifts, and related admin features. This is the selective rebuild of
the legacy SHOC frontend — new code follows the IrisLoan.Admin conventions
documented in [`docs/ARCHITECTURE_PLAN.md` ](docs/ARCHITECTURE_PLAN.md ).
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
- **GitHub:** `Sea-Haven-Industries/shoc-frontend-new`
- **Hosted at:** < https: // dev . seahaven . com > (dev environment; the only environment today)
- **Backend API:** `https://api.dev.seahaven.com/api` (called directly, cross-origin) — source: `Sea-Haven-Industries/shoc-backend`
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
## Architecture
2025-08-11 19:13:42 -05:00
2026-09-11 13:40:14 -04:00
Static SPA hosting on AWS, owned by HCP Terraform
([`terraform/README.md` ](terraform/README.md )). CloudFront serves the built
`dist/` from a private S3 bucket using a current/previous origin group;
the SPA calls the backend directly over HTTPS at `VITE_API_URL` (no `/api`
proxy at the CDN — the backend allows CORS).
2026-07-17 13:17:21 -04:00
```mermaid
graph LR
U[Browser] -->|HTTPS dev.seahaven.com| CF[CloudFront]
2026-09-11 13:40:14 -04:00
CF -->|origin group OAC| S3[S3 seahaven-shoc-frontend-dev]
2026-07-17 13:17:21 -04:00
CF -.->|viewer-request fn| FN[SPA rewrite → /index.html]
U -->|HTTPS api.dev.seahaven.com/api CORS| API[SHOC backend API]
2026-09-11 13:40:14 -04:00
GH[GitHub Actions] -->|OIDC upload releases/*| S3
TF[HCP Terraform shoc-frontend-new-dev] -->|pointer origin_path invalidation| CF
Feat/vite typescript migration (#16)
* chore: add eslint, prettier, husky and commitlint tooling
* ci: add GitHub Actions workflow for lint and build
* build: migrate from CRA to Vite with TypeScript config
* docs: add architecture plan and design system documentation
* fix: scope ESLint to new components and hooks directories
* feat: add HTTP client, query cache and shared utilities
* feat: add theme system and global application styles
* feat: add shared UI, layout and domain badge components
* feat: add auth domain, provider and login page
* feat: add app shell, file-based routing and bootstrap
* feat: add protected layout and dashboard module
* feat: add accounts CRUD module
* feat: add assets CRUD module
* feat: add contacts CRUD module
* feat: add employees CRUD module
* feat: add locations CRUD module
* feat: add calendar events module
* feat: add follow-ups CRUD module
* feat: add PM schedules CRUD module
* feat: add work orders module with dispatch modals
* feat: add vendors CRUD and portal token panel
* feat: add vendor purchase orders module
* feat: add uplifts queue module
* feat: add settings for dropdowns and task templates
* feat: add vendor portal routes and signature capture
* test: add Vitest setup and Playwright login e2e spec
* chore: remove legacy CRA pages, Redux store and JS hooks
* chore: update gitignore and env example for Vite
* docs: translate pt-BR docs and Cursor rules to English
* fix(ci): fix login e2e session mock and prettier formatting
* fix(build): use mjs router script for Node 20 CI compatibility
* chore: remove migration scripts and unused generouted router
* fix(auth): restore JWT and align CRUD with backend routes
* fix(api): add no-content helpers and align paths with backend
* fix(accounts): align detail and mutation payloads with backend
* fix(contacts): resolve detail via GetContacts and map address DTOs
* fix(work-orders): align routes, delete body, and create payload
* fix(vendors): delete vendors via REST route
* fix(pm-schedules): handle empty save and delete responses
* fix(employees): add fallbacks for detail and dropdown calls
* chore(calendar): disable routes until backend exists
* chore(env): switch tracked env vars to Vite prefixes
* fix(api): align frontend contracts with backend review findings
Correct Work Order getById query param, asset site options via Location API,
Employee JobTitleId payload, and remove stale API paths.
* fix(employees,pm-schedules): align forms with backend API contracts
Align PM Schedule form and save payload with PMSchedule_DTO fields.
Bind employee Job Title select to jobTitleId for create/update payloads.
Add regression tests for both flows.
* fix(pm-schedules): gate edit/delete for Dev API contract
Production Dev API exposes only GetList and Save.
Hide unsupported edit/delete UI and block the edit route.
Add regression tests for disabled actions.
* docs(env): document VITE_API_URL must include /api suffix
* refactor(api): extract shared API prefix URL resolution
* feat(build): fail build on misconfigured absolute VITE_API_URL
* test(api): cover API URL contract and prefix resolution
* feat(auth): disable login submit until email and password are valid
* test(auth): align login tests with disabled submit behavior
* Feat/ab/menu-and-header (#17)
* chore(deps): add lucide-react for layout icon migration
* feat(auth): add getPrimaryUserRole helper for header display
* style(theme): add sidebar active tokens and nav group typography
* refactor(menu): migrate nav icons to lucide and trim menu groups
* feat(layout): redesign sidebar, topbar, and admin shell viewport
* chore(menu): hide Reports and Documents from sidebar
---------
Co-authored-by: Arthur Bassi <arthur.winiarski.ranger@outlook.com>
* ci: add frontend PR quality baseline (#18)
* chore(deps): add lucide-react for layout icon migration
* feat(auth): add getPrimaryUserRole helper for header display
* style(theme): add sidebar active tokens and nav group typography
* refactor(menu): migrate nav icons to lucide and trim menu groups
* feat(layout): redesign sidebar, topbar, and admin shell viewport
* chore(menu): hide Reports and Documents from sidebar
* ci: add PR quality baseline checks
* ci: avoid self-matching standards guard
* ci: split frontend quality gates
---------
Co-authored-by: Arthur Bassi <arthur.winiarski.ranger@outlook.com>
---------
Co-authored-by: Arthur Bassi <arthur.winiarski.ranger@outlook.com>
Co-authored-by: Alexandre Brandizzi <alex_brandizzi@hotmail.com>
2026-06-18 14:41:17 -03:00
```
2025-08-11 19:13:42 -05:00
2026-09-11 13:40:14 -04:00
Dev hosting and content CD are owned by HCP Terraform (SH-300). Staging still
uses CloudFormation outputs and `scripts/deploy-web.sh` (SH-287).
2026-09-10 19:15:14 -04:00
2026-07-17 13:17:21 -04:00
Frontend stack: React 19, TypeScript, Vite, Tailwind CSS 4 + MUI, TanStack
Query, React Router (via `@generouted/react-router` ), React Hook Form + Zod,
Ky HTTP client. Source layout: `src/api/` , `src/domain/` , `src/app/` (see the
architecture plan for the keep/discard migration matrix).
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
## AWS Resources
2025-08-11 19:13:42 -05:00
2026-09-11 13:40:14 -04:00
HCP workspace ** `shoc-frontend-new-dev` ** — account `396287094661` , region
`us-east-1` . Defined in [`terraform/live/dev` ](terraform/live/dev ).
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
| Resource | Name | Purpose |
| ----------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| S3 bucket | `seahaven-shoc-frontend-dev` | Private origin (BLOCK_ALL, SSE, versioned; OAC-only reads) |
| CloudFront distribution | (stack output `DistributionId` ) | HTTPS static hosting on `dev.seahaven.com` , ACM `*.seahaven.com` |
| CloudFront Function | `SpaRewrite` | Viewer-request rewrite of extensionless paths to `/index.html` (deep links) |
| IAM role | `githubdeploy-shoc-frontend-new-dev` | GitHub Actions OIDC deploy role, trust scoped to `repo:Sea-Haven-Industries/shoc-frontend-new:ref:refs/heads/dev` |
| Route 53 records | A/AAAA apex alias in zone `dev.seahaven.com` (`Z07671212N75U4YLPWZR8` ) | Points the custom domain at CloudFront |
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
No Lambdas, queues, or databases — this stack is static hosting only.
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
## Configuration
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
### Secrets
2025-08-11 19:13:42 -05:00
2026-09-10 19:15:14 -04:00
No Secrets Manager or SSM parameters. AWS access is OIDC only; the deploy role
ARNs are deterministic and pinned in the workflows. The one **GitHub Actions
repo secret** is:
2026-07-17 13:17:21 -04:00
2026-09-10 19:15:14 -04:00
| Secret | Purpose |
| ------------------- | ------------------------------------------------------------------ |
| `SENTRY_AUTH_TOKEN` | Source-map upload by `scripts/upload-sourcemaps.sh` after a deploy |
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
### Environment variables (build-time, `VITE_*`)
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
| Variable | Description | Dev value |
| ----------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------- |
| `VITE_API_URL` | Ky API base prefix, **baked into the build** at `vite build` | `/api` (dev server) / `https://api.dev.seahaven.com/api` (production build) |
| `VITE_API_TARGET` | Dev-proxy target for `/api` (Vite dev server only) | `http://localhost:5141` |
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
`VITE_API_URL` supplies the full API prefix — route paths in `API_PATHS` do
**not** include `/api` . Absolute values **must end with `/api`** ;
`vite.config.ts` enforces this via `config/api-url-contract.ts` and fails the
build otherwise. See [`.env.example` ](.env.example ),
[`.env.development` ](.env.development ), and [`.env.production` ](.env.production ).
2025-08-11 19:13:42 -05:00
2026-09-11 13:40:14 -04:00
Pinned hosting constants (domain, certificate ARN, hosted zone) live in
[`terraform/live/dev/main.tf` ](terraform/live/dev/main.tf ).
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
## Local Development
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
Requirements: Node.js ≥ 22.22.1 (CI/CD run Node 24), npm 11.16.0 (pinned via
`packageManager` ).
2026-07-07 06:14:06 -03:00
2026-07-17 13:17:21 -04:00
```bash
npm ci
cp .env.example .env # then set VITE_API_URL=/api for local dev
npm run dev # Vite dev server on port 3000, proxies /api → VITE_API_TARGET
```
2026-07-07 06:14:06 -03:00
2026-07-17 13:17:21 -04:00
The dev proxy expects the `shoc-backend` API at `http://localhost:5141` ;
override with `VITE_API_TARGET` (e.g. `https://api.dev.seahaven.com` to use
the deployed dev API).
2026-09-11 13:40:14 -04:00
| Command | Description |
| ------------------------------------------ | ------------------------------------------------------------------ |
| `npm run dev` | Start Vite dev server on port 3000 |
| `npm run build` | Type-check (`tsc -b` ) and production build to `dist/` |
| `npm run preview` | Preview the production build locally |
| `npm test` / `npm run test:watch` | Vitest unit tests (once / watch) |
| `npm run test:e2e` / `npm run test:e2e:ui` | Playwright e2e tests (headless / UI mode) |
| `npm run lint` / `npm run lint:fix` | ESLint (check / auto-fix) |
| `npm run format` / `npm run format:check` | Prettier (write / check) |
| `npm run governance` | Governance checks (godfile, maintainability, Terraform, CD guards) |
| `npm run verify` | **All gates** : format + lint + build + test + governance |
2026-09-10 19:15:14 -04:00
`npm run governance` needs `terraform` and `python3` on `PATH` for the
2026-09-11 13:40:14 -04:00
Terraform and content-CD gates.
2026-07-17 13:17:21 -04:00
Husky + lint-staged run ESLint and Prettier on staged files at commit;
commitlint enforces conventional commit messages. Run `npx tsc --noEmit` (or
`npm run build` ) before pushing to catch type errors early.
## Contributing
- Branch from `dev` with a kebab-case description and a prefix matching the
work: `feature/` , `bug/` , `hotfix/` , `chore/` , `docs/` , or `refactor/`
(e.g. `feature/vendor-portal-filters` , `chore/sea-haven-branding` ).
- Commit messages follow
[Conventional Commits ](https://www.conventionalcommits.org ) — commitlint
rejects anything else at commit time.
- Open PRs against `dev` . Both `dev` and `main` are protected: every PR needs
a green CI run and an approving review from a code owner
(`@Sea-Haven-Industries/internal-dev` ); new pushes dismiss stale approvals.
Merged branches are deleted automatically.
2026-09-10 19:37:27 -04:00
- A PR that changes `terraform/**` may not also change application code (the
`terraform-isolation` CI job); ship Terraform in its own PR.
2026-09-11 13:40:14 -04:00
- Promotion flow: `feature/* → dev` (deployed to `dev.seahaven.com` through
Terraform content CD once `TERRAFORM_CONTENT_CD_ENABLED=true` )
2026-09-10 19:15:14 -04:00
`→ main` (production promotion — no prod environment exists yet).
2026-07-17 13:17:21 -04:00
## Deployment
2026-09-10 19:15:14 -04:00
No stored AWS keys — OIDC only. Infrastructure and content deploy separately:
2026-07-17 13:17:21 -04:00
- **CI** ([`.github/workflows/ci.yaml` ](.github/workflows/ci.yaml )) — on push
2026-09-10 19:15:14 -04:00
and PRs to `main` /`dev` /`staging` , calls
2026-07-17 13:17:21 -04:00
`Sea-Haven-Industries/.github` → `ci-typescript-frontend.yaml` (Node 24):
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
format check, lint, build, tests; **and** runs a repo-owned `governance` job
that calls `npm run verify` so every gate (including the maintainability
2026-09-10 19:15:14 -04:00
ratchets in [`scripts/governance-check.mjs` ](scripts/governance-check.mjs ),
2026-09-11 13:40:14 -04:00
the Terraform gates, and the content-CD guards) is guaranteed from this
2026-09-10 19:15:14 -04:00
repository. Conventions and gates are documented under
chore(governance): enforce frontend quality system (#53)
* chore(governance): make React/TS conventions mandatory via executable gates
Add AGENTS.md, QUALITY_GATES.md, ARCHITECTURE_AND_CODE_QUALITY.md, and
REVIEW_AND_PR_FRAMEWORK.md as the binding conventions and PR review
contract for humans and all coding/review agents.
Add a single 'npm run verify' command (format + lint + build + test +
governance) and 'npm run governance', which runs a dependency-free godfile
ratchet (whole-repo, baseline in scripts/governance-baseline.json) and a
changed-file maintainability gate (complexity<=20, function<=150, params<=4,
depth<=4) via ESLint. Legacy is handled by ratchets, not relaxation: 5
godfiles over 500 lines are grandfathered debt; maintainability thresholds
apply to changed TS/TSX (72 legacy violations across ~51 files otherwise).
Add a repo-owned 'governance' CI job that runs 'npm run verify' so every
gate is guaranteed from this repository, independent of the org reusable
workflow.
* fix(governance): make frontend ratchets fail closed
2026-07-24 16:47:34 -03:00
[`AGENTS.md` ](AGENTS.md ), [`QUALITY_GATES.md` ](QUALITY_GATES.md ),
[`ARCHITECTURE_AND_CODE_QUALITY.md` ](ARCHITECTURE_AND_CODE_QUALITY.md ), and
[`REVIEW_AND_PR_FRAMEWORK.md` ](REVIEW_AND_PR_FRAMEWORK.md ).
2026-09-10 20:45:49 -04:00
- **Terraform isolation**
([`.github/workflows/terraform-isolation.yaml` ](.github/workflows/terraform-isolation.yaml ))
— fails a PR that mixes `terraform/**` with application code, so a Terraform
merge never races a content release for the HCP workspace.
2026-09-10 19:15:14 -04:00
- **Dev content** ([`.github/workflows/deploy.yml` ](.github/workflows/deploy.yml ))
2026-09-11 13:40:14 -04:00
— `workflow_dispatch` on `dev` , and push-to-`dev` when
`vars.TERRAFORM_CONTENT_CD_ENABLED` is `true` (`paths-ignore: terraform/**` ).
GitHub uploads `releases/<sha>-<run>-<attempt>/` only. Terraform updates
`.release/current` , both origin paths, and the invalidation action. Verify
and rollback share `scripts/verify-cloudfront-release.sh` . Every run prints
a live-state summary.
2026-09-10 19:15:14 -04:00
- **Staging content**
([`.github/workflows/deploy-staging.yml` ](.github/workflows/deploy-staging.yml ))
— on push to `staging` , unchanged.
2026-09-11 13:40:14 -04:00
- **Infrastructure** — administrator-run HCP Terraform workspace
`shoc-frontend-new-dev` ([`terraform/README.md` ](terraform/README.md )).
Staging hosting stays on the existing CloudFormation stack until SH-287.
2026-09-10 19:15:14 -04:00
2026-09-11 13:40:14 -04:00
Do not run `scripts/deploy-web.sh` against dev. That script remains the staging
content publisher only.
2025-08-11 19:13:42 -05:00
2026-07-17 13:17:21 -04:00
## Operations
2026-09-10 19:15:14 -04:00
- **Verify:** open < https: // dev . seahaven . com > after a green **Deploy dev
content** run in the Actions tab; confirm a deep link (e.g. a work-orders
route) loads directly and API calls succeed.
2026-07-17 13:17:21 -04:00
- **Logs:** deploy logs live in GitHub Actions (CI + Deploy workflows). There
are no CloudWatch application logs — the stack is static hosting; runtime
errors surface in the browser and on the backend API's side.
- **Common failure modes:**
2026-09-11 13:40:14 -04:00
- _Stale content after deploy_ — CloudFront is still `InProgress` or an edge
still serves the previous `index.html` hash. Read the live-state summary
before assuming the site is down.
2026-09-10 19:15:14 -04:00
- _OIDC `AssumeRole` errors_ — the trust policy is scoped to the `dev` ref
on this repo; dispatching the workflow from another branch is rejected by
design.
2026-07-17 13:17:21 -04:00
- _Broken API requests after a build_ — `VITE_API_URL` missing the `/api`
suffix or carrying the wrong environment's host (it is baked in at build time).
- _CORS errors_ — the backend must allow the frontend origin; CloudFront does
not proxy `/api` .
2026-09-11 13:40:14 -04:00
- **Push-to-`dev` is gated.** Merging to `dev` publishes only when
`TERRAFORM_CONTENT_CD_ENABLED=true` . Merging a `terraform/**` change queues
an HCP Terraform run that a human confirms or discards before the next
content release (see the operational rules in `terraform/README.md` ).
2026-07-17 13:17:21 -04:00
## Documentation
2026-09-11 13:40:14 -04:00
- Dev Terraform runbook: [`terraform/README.md` ](terraform/README.md )
2026-07-17 13:17:21 -04:00
- Rebuild strategy and conventions: [`docs/ARCHITECTURE_PLAN.md` ](docs/ARCHITECTURE_PLAN.md );
design system and UI docs under [`docs/` ](docs/ )