How this site works
This site is a Docusaurus 3 project at the repository root. Guides are Markdown/MDX files in docs/. Interactive widgets are React components in src/components/pdr/. The original React/Vite Gateway guide in apps/pdr-gateway is kept unchanged and is the source this site was migrated from.
Repository layout
| Path | Purpose |
|---|---|
docs/ | Guides (Markdown/MDX). One file per page. |
sidebars.ts | Explicit navigation. Adding a guide is a file plus one line here. |
docusaurus.config.ts | Site config, strict link checking, search, docs served from /. |
src/data/pdr.ts | Single source of truth for URLs, synthetic examples, scenarios, certificates. |
src/components/pdr/ | Interactive components. |
src/theme/ | Docusaurus theme overrides (root provider, global MDX components, metadata bar). |
apps/pdr-gateway/ | Original app. Not imported by the site. |
How it was built
- Scaffold.
create-docusaurus(classic, TypeScript) was generated outside the repo and copied to the root without overwriting existing files. Demo content (blog, tutorial, homepage) was removed. - Configure. Docs are served from
/. The blog is disabled. Broken links, anchors and Markdown links fail the build. A local search plugin builds an index at build time with no external service. - Share data.
src/data/pdr.tswas copied from the original app so every component reads the same constants. - Share the environment.
src/theme/Root.tsxwraps the site in anEnvironmentProviderthat stores QA or Production (default QA, remembered inlocalStorageafter mount so server and client markup match). One selector drives every widget. - Port components. The original
App.tsxwas split into one component per file, using Docusaurus's ownCodeBlock(syntax highlighting and copy) and theme variables for styling. - Register globally.
src/theme/MDXComponents.tsxmakes every component available in any.mdxfile without an import. - Show metadata.
src/theme/DocItem/Content/index.tsxreadsowner,last_verified,service_versionandstatusfrom front matter and renders them above each guide. - Write content. Pages were written from the original app's content. Anything the source did not state is marked with a Documentation gap admonition rather than asserted.
Design decisions
Platform choices
| Decision | Why | Trade-off |
|---|---|---|
| Docusaurus over a custom engine | The ticket rules out building a documentation engine. Docusaurus provides navigation, search, versioned builds, Markdown/MDX and React, so existing widgets can be reused. | Pages are React under the hood, so a contributor who writes components needs some React. Plain guides need none. |
| MDX with global components | Authors write a component tag in a page with no import. That is what lets a contributor add a guide with no application-logic change. | Components are a hidden dependency of a page. Names must be unique, and renaming one means searching the docs. |
Explicit sidebars.ts | Navigation order is a deliberate editorial decision and shows up in review. | A new page needs one extra line. A page missing from the sidebar still builds, so review should check it. |
| One shared data module | URLs, examples and certificates live in src/data/pdr.ts, so a fact changes in one place and every page and widget agrees. | It is a copy of the original data.ts, so the two drift until the original is deprecated. |
| Strict link checking | Broken links, anchors and Markdown links fail the build, which satisfies the ticket's "broken internal links block publication" criterion. | Renaming a page forces you to fix every link to it. That is the point. |
| Local search plugin | Full-text search with no external account, service or key, and it works for a public static site. | The index is built at publish time and is only as good as the page content. It is not a hosted search service. |
Docusaurus CodeBlock and theme variables | Highlighting, copy buttons and dark mode come for free, and the 832-line original stylesheet is not carried over. | Visual changes go through the theme tokens in src/css/custom.css, not per-component CSS. |
| Metadata via a wrapper component | Owner, last-verified date and service version come from front matter, so they are enforced by habit and review, not by app logic. | The bar does not validate values. Whether an owner is real is a review question. |
Component choices
EnvironmentProvider, EnvironmentSelector, EnvLinks. QA and Production differ in hostnames, Okta issuers and onboarding material, and the ticket requires the two to be clearly distinguished. The choice lives in one React context, mounted in src/theme/Root.tsx, so it is shared by every widget on every page instead of each page keeping its own. It starts at QA and restores the saved choice after mount. Starting from a stored value would make the server-rendered HTML differ from the browser's first render. EnvLinks exists so a page can show the right Gateway, OpenAPI and Swagger URLs without hard-coding either environment.
WorkflowExplorer. The ticket requires the migrated guide to keep its workflow navigation. The original had a diagram, a step list, a per-step detail panel and a bottom stepper. They all changed the same piece of state, so they became a single component with one selected step. Each step's Request, Response and cURL tabs read from the shared fixtures. The Walkthrough tab links to the written guide instead of copying its text, so explanations have one home. The cost is that it no longer looks like the original diagram with arrows.
QueryBuilder. This delivers the "request-generation capability". It holds form state locally and only generates JSON and cURL with an <ACCESS_TOKEN> placeholder. It never sends a request, which keeps it inside the ticket's out-of-scope rule on executing requests or handling credentials. It reads the selected environment for the base URL.
QueryExamples, DocumentReferenceExplorer, Part2Labels. These render the synthetic response fixtures directly instead of using pasted JSON in a page, so the example you read is the same object the widgets use. DocumentReferenceExplorer handles a missing fixture explicitly instead of failing the page.
ScenarioExplorer and TestPatients. Both are driven entirely by data. Adding a QA scenario or a test patient is an edit to src/data/pdr.ts, with no component change, and each scenario carries its Validated status so the page never implies an unverified scenario is available.
AuthSnippets and CaBundle. These are per-environment: the token endpoint, issuer and connectivity test change with the selector. The certificate bundle sits in a collapsed section because it is long and rarely needed. The page text, not the component, carries the guidance not to pin the leaf certificate.
How a page renders
An .mdx page that contains <QueryBuilder /> is compiled by Docusaurus. The tag resolves to the component registered in MDXComponents.tsx. The component reads the selected environment from context and constants from src/data/pdr.ts, and renders generated JSON/cURL. No network calls are made. Execution of real requests stays in Swagger.
Walkthrough: add a static Markdown guide
Use this for explanatory content that needs no interactivity. The example adds a glossary page.
-
Create the file. Add
docs/gateway/glossary.mdwith front matter, then content:---title: Glossarydescription: Terms used in the PDR Gateway guides.owner: PDR Engineeringlast_verified: 2026-11-13service_version: "1.0"---# Glossary**QE.** A Qualified Entity in the exchange.See [Query](/gateway/query-retrieve). -
Add it to the navigation. In
sidebars.ts, add its id, which is the path underdocs/without the extension, to the right category:items: ['gateway/onboarding','gateway/authentication','gateway/query-retrieve','gateway/glossary',], -
Preview. Run
npm start. The page appears at/gateway/glossarywith the metadata bar and in search after a production build. -
Validate. Run
npm run build. A link to a page that does not exist, for example/gateway/does-not-exist, fails the build. This is the same check CI runs on every pull request, so fix it before opening one. -
Open a pull request. Follow the review requirements in Contributing.
Notes:
.mdfiles are parsed as MDX. In prose, write{and<inside backticks or code fences, or the build reports a syntax error.- Put images next to the page or under
static/img/and reference them by path. - Use
:::caution[Documentation gap]for anything you could not confirm.
Walkthrough: add a custom React component
Use this when a guide needs behavior, such as a selector, calculator or generator. The example adds a document-type picker that shows the format Retrieve returns.
-
Put shared facts in the data module. Append to
src/data/pdr.ts, so the numbers live in one place:export const documentFormats = [{type: 'CCD', format: 'XML / C-CDA'},{type: 'Lab', format: 'HL7 v2'},{type: 'Rad', format: 'HL7 v2'},{type: 'TRN', format: 'HL7 v2'},] as const; -
Write the component. Create
src/components/pdr/DocumentTypes.tsx. This minimal version is the one on the slides:import React, {useState} from 'react';import {documentFormats} from '@site/src/data/pdr';import styles from './pdr.module.css';export default function DocumentTypes() {const [type, setType] = useState('CCD');const current = documentFormats.find((d) => d.type === type);return (<div className={styles.panel}>{documentFormats.map((d) => (<button key={d.type} onClick={() => setType(d.type)}>{d.type}</button>))}<p>{current?.format}</p></div>);}Optional: a styled version with the portal's tabs and ARIA roles. It reuses the existing panel and tab styles from
pdr.module.css, so it matches the portal with no new CSS:import React, {useState} from 'react';import clsx from 'clsx';import {documentFormats} from '@site/src/data/pdr';import styles from './pdr.module.css';/** Pick a document type and see the format Retrieve returns for it. */export default function DocumentTypes() {const [selected, setSelected] = useState<string>(documentFormats[0].type);const current = documentFormats.find((d) => d.type === selected) ?? documentFormats[0];return (<div className={styles.panel}><div className={styles.tabs} role="tablist" aria-label="Document types">{documentFormats.map((d) => (<buttonkey={d.type}type="button"role="tab"aria-selected={d.type === selected}className={clsx(styles.tab, d.type === selected && styles.tabActive)}onClick={() => setSelected(d.type)}>{d.type}</button>))}</div><p>A <strong>{current.type}</strong> document is returned by Retrieve as{' '}<strong>{current.format}</strong>.</p></div>);} -
Register it for MDX. In
src/theme/MDXComponents.tsx, import it and add it to the exported object:import DocumentTypes from '@site/src/components/pdr/DocumentTypes';export default {...MDXComponents,// existing components...DocumentTypes,}; -
Use it in a page. In any
.mdxfile, write the tag with no import:## Document formats<DocumentTypes /> -
Check types and build. Run
npx tsc --noEmit, thennpm run build. The build renders every page on the server, so a component that crashes during server rendering fails here.
Rules for components:
- No browser APIs at render time. Pages are rendered on the server first. Do not touch
windoworlocalStoragewhile rendering. Read them inuseEffectafter mount, asEnvironmentContext.tsxdoes. - Need the QA/Production choice? Call
useEnvironment()fromEnvironmentContext.tsx, which gives youenvironmentandenv.baseUrl. - Show code? Use
CodeBlockfrom@theme/CodeBlock, not a rawpreelement, to get highlighting and copy. - Never call the API or handle credentials. The portal generates examples only. Real requests run in Swagger.
- Colors. Use the
--pdr-*tokens so light and dark mode work.
What we use from the original apps/pdr-gateway
Reused
| Original | Used as | Notes |
|---|---|---|
src/data.ts | src/data/pdr.ts (copied unchanged) | All exports retained: environments, onboarding values, query requests and responses, DocumentReference examples, test patients, scenarios, CA certificates, retrieve request, retrieved HL7 payload, workflow steps. |
WorkflowDiagram, StepDetail, the step list and bottom-stepper | WorkflowExplorer | The diagram nodes and step navigation became one stepper. Tabs: Walkthrough, Request, Response, cURL. |
QueryBuilder | QueryBuilder | Same fields, same JSON and cURL output. |
QueryContent examples | QueryExamples | Standard, Part 2 and No documents. |
DocumentsContent, Part2Content | DocumentReferenceExplorer, Part2Labels | Same synthetic resources. |
TechnicalOnboarding, QaPatientCatalog | ScenarioExplorer, TestPatients | Same scenarios and patient list. |
AuthContent | AuthSnippets and the Authentication page | Claims and token request per environment. |
ConnectionSetup | CaBundle, EnvLinks and the Onboarding page | CA chain, trust test and connectivity values. The prose became page text. |
| Environment picker, resource strip, Swagger links | EnvironmentSelector, EnvLinks, API reference page | |
| Footer disclaimer | Site footer |
Converted to prose
ResolveContent, CompleteContent, the Retrieve walkthrough and the onboarding requirements text became Markdown on the Matching & Part 2, Query & retrieve and Onboarding pages.
Not carried over
- Styling. The 832-line
styles.csswas not reused. Components use Docusaurus theme variables instead. - App shell.
main.tsx,index.html,vite.config.ts, the Vitetsconfigfiles,package.jsonand its lockfile are unused. The site has its own build. - Onboarding email button. The original prefilled a
mailto:with a request template. The new Onboarding page lists the required fields and links the address, but does not prefill the body. - Single-page layout. The original was one long page. Content is now split across pages.
Does the original app need to keep running?
No. Nothing in src/ or docs/ imports from apps/, so the site builds and runs without it. The only ongoing link is that src/data/pdr.ts is a copy, so changes to data.ts do not propagate. Once the original app is deprecated, src/data/pdr.ts is the only copy to maintain.
The legacy app stays in the repository, unchanged, until it is formally deprecated. The deploy and CI workflows now build the portal, not the legacy app.
Remaining work
- Live pull-request previews. Today each pull request attaches a downloadable build artifact. Rollback is a manual run of the deploy workflow from an earlier branch or tag.
- Old links: the original is a single page with fragments
#connection-setup,#qa-test-patientsand#technical-onboarding. Servers never see fragments, so a small browser script (src/clientModules/legacyHashRedirect.ts) sends them to the matching pages. Path-based redirects are not needed because the original had no other paths. - Record the framework decision.
- Confirm owners and verification dates with PDR engineering.