JTI Docusaurus Template – Project Health Report
Last updated: 2026-03-04
1) Project Summary
This repository is a Docusaurus v3 template customized for JTI with:
- React + TypeScript based site customization.
- Optional Azure AD authentication and group-based authorization through MSAL.
- Optional Azure Static Web Apps (SWA) route-level protection.
- Optional Azure Application Insights integration.
- Local search indexing via
@easyops-cn/docusaurus-search-local.
2) Architecture Overview
Core runtime flow
src/theme/Root.tsxis the integration entry point for:- Content Security Policy header injection.
- MSAL bootstrap and provider wiring.
- AuthN/AuthZ gating and conditional rendering.
- App Insights initialization and user context setup.
Authentication modules
src/authentication/authConfig.ts- Defines shared MSAL runtime configuration and logger behavior.
src/authentication/auth.ts- Creates the MSAL public client app.
- Handles login redirect lifecycle.
- Resolves user identity from MSAL and/or SWA
/.auth/me. - Implements group authorization checks.
- Exposes
acquireAccessToken()for future API integrations.
Observability
src/services/appInsights.ts- Lazy-loads
ApplicationInsightssingleton. - Applies authenticated user context once available.
- Lazy-loads
3) Configuration Surface
Build/runtime config
docusaurus.config.ts- Controls Docusaurus settings, i18n, navbar/footer, search plugin, and auth feature flags.
- Uses environment values via
dotenvincustomFields.
Azure SWA security
staticwebapp.config.json- Restricts all routes to
authenticatedrole. - Redirects unauthorized requests to Azure AD login.
- Restricts all routes to
NPM scripts (operational)
npm run start– local development (runs lint + dev server)npm run lint– ESLint auto-fix acrosssrcnpm run build– production build (includes prebuild lint)npm run serve– serves built output for validation/search testing
4) React Doctor Analysis
Command used
npx -y react-doctor@latest . --verbose --diff
Result snapshot
- Score: 94/100 (
Great) - Findings: 1 error, 16 warnings, across 9/14 scanned files
- Scan context: full scan (no diff/feature branch context detected)
High-priority finding (Error)
- Missing image alt attribute
- File:
src/components/HomepageFeatures/index.tsx - Impact: accessibility violation and lint failure risk
- Recommendation: add
alttext (oralt=""if decorative)
- File:
Notable warnings
-
Array index used as React key
- File:
src/components/HomepageFeatures/index.tsx - Recommendation: use stable key based on item identity (e.g., title/slug/id).
- File:
-
Large component size
- File:
src/pages/token-test.tsx(~363 lines) - Recommendation: split into focused presentational subcomponents (
TokenHeader,TokenResult,TroubleshootingPanel, etc.).
- File:
-
useEffect complexity and state updates
- File:
src/theme/Root.tsx - Recommendation: reduce effect branching and consider a reducer/state-machine style for auth init transitions.
- File:
-
Unused-file warnings likely influenced by framework conventions
- Reported files include:
src/theme/Root.tsxsrc/components/Loading/index.tsxsrc/services/appInsights.ts
- Note: In Docusaurus, theme override files can be resolved by convention and may appear “unused” to generic static analyzers.
- Reported files include:
5) Risk & Quality Notes
- Accessibility: one concrete gap (
imgalt attribute) should be fixed immediately. - Maintainability: auth orchestration in
Root.tsxis functional but dense; medium-term simplification would lower regression risk. - Performance/readability: token test page is currently a useful diagnostics tool but would benefit from decomposition.
- Tooling interpretation: treat “unused” findings carefully where framework-level auto-discovery applies.
6) Prioritized Remediation Plan
-
Immediate (today)
- Add missing
altattribute inHomepageFeatures. - Replace index-based list key with stable key.
- Add missing
-
Short term (this sprint)
- Refactor
token-test.tsxinto smaller components without changing behavior. - Simplify
Root.tsxauth initialization path; reduce side-effect branching.
- Refactor
-
Medium term (next sprint)
- Add a lightweight architectural note for auth flow transitions.
- Add targeted tests around auth-init and authorization-gate rendering behavior.
7) Operational Guidance
- Re-run quality scan after each significant React/auth change:
npx -y react-doctor@latest . --verbose --diff
- For build confidence before release:
npm run lint
npm run build
npm run serve
8) Conclusion
The template is in a strong state overall (94/100) with one clear accessibility defect and a small set of maintainability opportunities. The authentication foundation is robust and supports multiple deployment/auth strategies; the next quality gains come from targeted cleanup in UI accessibility and auth/page component structure.