You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decision OS is a client-side web application built with Next.js 16 (App Router), React 19, and TypeScript (strict mode). It uses a local-first architecture — all data lives in the browser's localStorage by default, with optional Supabase-powered cloud sync for cross-device access. The app implements multiple MCDA (Multi-Criteria Decision Analysis) algorithms, Monte Carlo simulation, cognitive bias detection, and data enrichment — all running entirely in the browser.
Touch-optimized 0–10 range slider with ≥44px target and color coding
WeightSlider.tsx
Range slider + number input for criterion weights with ARIA attributes
WeightDistributionBar.tsx
Stacked horizontal bar showing normalized weight percentages
MobileScoreCards.tsx
Accordion card layout for mobile scoring with sliders and confidence dots
SortableItem.tsx
@dnd-kit/sortable drag-and-drop wrapper with accessible grip handle
ScoringPrompt.tsx
Contextual scoring guidance — anchor prompts (1/5/10) and calibration
CriterionTooltip.tsx
Accessible hover/focus/touch tooltip for criterion descriptions
ReasoningPopover.tsx
Per-score reasoning notes popover with filled-icon indicator
CompletionRing.tsx
SVG circular progress indicator for score-matrix completeness
QualityBar.tsx
Overall quality score bar with expandable per-check indicators
Results & Analysis
File
Responsibility
ResultsView.tsx
Rankings, breakdowns, top drivers, export, chart, share
ScoreChart.tsx
Recharts bar + stacked breakdown chart (React.memo, lazy-loaded)
SensitivityView.tsx
Weight-swing analysis with interactive slider
CompareView.tsx
Side-by-side decision comparison with divergence analysis
MonteCarloView.tsx
Monte Carlo simulation config, results, histograms, CIs
ParetoChart.tsx
Recharts scatter plot with Pareto frontier line and axis selectors
WhatIfPanel.tsx
Sandboxed what-if overlay with real-time rank comparison
Multi-Algorithm & Confidence
File
Responsibility
FrameworkComparison.tsx
WSM/TOPSIS/Minimax Regret side-by-side with Kendall's W consensus
HybridResults.tsx
Consensus ranking table with color-coded agreement indicators
AHPWizard.tsx
Step-by-step pairwise comparison wizard for AHP weight derivation
ConfidenceDot.tsx
Clickable green/amber/red dot cycling through confidence levels
ConfidenceIndicator.tsx
Enriched-score reliability badge (Tier 1/2/3) with tooltip
CompositeConfidenceIndicator.tsx
Traffic-light composite confidence badge with expandable breakdown
ConfidenceStrategySelector.tsx
Radio selector: display-only / penalize / widen-MC confidence modes
ScoreProvenanceIndicator.tsx
Manual/enriched/overridden badge with restore-enriched action
Bias & Patterns
File
Responsibility
BiasWarnings.tsx
Cognitive bias warnings as dismissible, severity-styled cards
PatternInsights.tsx
Cross-decision pattern cards with confidence indicators and evidence
Lifecycle & Retrospective
File
Responsibility
OutcomeTracker.tsx
Records outcomes (chosen option, rating, notes) with prediction comparison
RetrospectiveView.tsx
Decision lifecycle timeline with journal, milestones, and markdown export
Data Enrichment
File
Responsibility
EnrichmentSuggest.tsx
Suggests auto-fill data queries; users accept, dismiss, or override
Import & Share
File
Responsibility
ImportModal.tsx
File import dialog with CSV preview, drag-and-drop support
TemplatePicker.tsx
Modal template picker with focus trap and card grid
ShareView.tsx
Read-only presentation view for shared decisions
Auth & Sync
File
Responsibility
AuthButton.tsx
Sign in/out dropdown with GitHub and Google OAuth providers
SyncStatus.tsx
Cloud sync status indicator with manual retry
MigrationBanner.tsx
One-time localStorage → cloud migration prompt
Collaboration (Real-Time)
File
Responsibility
CollaborationProvider.tsx
Context provider wrapping useRealtime hook for the component tree
CollaborationBadge.tsx
Connection status indicator (green/yellow dot) with live count
PresenceAvatars.tsx
Stacked avatar circles for connected collaborators with overflow
UX & Onboarding
File
Responsibility
CoachmarkOverlay.tsx
3-step onboarding tour with positioned tooltips and focus trap
KeyboardShortcutsModal.tsx
Modal displaying global keyboard shortcuts with focus trap
MobileOverflowMenu.tsx
Kebab-triggered dropdown for header actions on narrow viewports
LanguageSwitcher.tsx
Locale-switching dropdown (en/es/fr) persisted to localStorage
/src/hooks/ — Custom React Hooks (7 files)
File
Responsibility
useValidation.ts
Memoized real-time validation — errors, warnings, infos for inline UI
useAuth.ts
Supabase auth state — user, session, sign in/out, loading
useSync.ts
Cloud sync status — auto-sync on mount/focus, manual trigger
useRealtime.ts
Realtime collaboration — channel lifecycle, broadcast, presence state
useBiasDetection.ts
Debounced (500ms) bias detection with per-type dismissal management
useMonteCarloWorker.ts
Runs Monte Carlo in a Web Worker with progress, cancellation, fallback
useOnboarding.ts
Onboarding state machine (idle → step1–3), auto-triggers on first visit
/src/workers/ — Web Workers (1 file)
File
Responsibility
monte-carlo.worker.ts
Off-main-thread Monte Carlo simulation via typed message protocol
/src/app/ — Next.js App Router
File
Responsibility
layout.tsx
Root layout with metadata, fonts, FOUC-prevention script
page.tsx
Main page with tab navigation, keyboard shortcuts, conditional tab rendering
not-found.tsx
Custom 404 page
share/page.tsx
Read-only share route — decodes and displays shared decisions
manifest.ts
PWA web app manifest (name, icons, theme)
sitemap.ts
Dynamic sitemap generation for SEO
globals.css
Tailwind imports and CSS variables
/src/lib/i18n/ — Localization Data
File
Responsibility
en.json
English translations
es.json
Spanish translations
fr.json
French translations
Design Decisions
Local-first with optional cloud: All state in localStorage by default. When Supabase env vars are set, auth + cloud sync activate. Saves always go to localStorage first (instant), then to cloud (async, best-effort). See ADR-002.
Pure scoring engine: All scoring functions are pure (no side effects). This makes them easy to test and reason about. The WSM scoreOption() uses a single-pass loop to eliminate redundant iterations.
Focused Contexts over monolithic Context: State is split into 4 focused contexts (DecisionDataCtx, ResultsCtx, ActionsCtx, DecisionDispatchContext) to prevent unnecessary re-renders. A backward-compatible DecisionContext combines all for legacy consumers. Components import only the context they need via useDecisionData(), useResultsContext(), useActions(), or useDecisionDispatch().
useReducer + pure reducer: Decision state mutations flow through decision-reducer.ts — a pure reducer with typed action discriminated unions. Undo/redo coalescing middleware wraps the core reducer. 50-entry history stack via useRef.
Recharts for visualization: Score charts and Pareto plots use Recharts. Lazy-loaded via React.lazy + Suspense to keep initial bundle small.
Conditional tab rendering: Only the active tab's component mounts (DecisionBuilder is always-mounted). Inactive tabs render a skeleton <output> placeholder. This eliminates thousands of unnecessary DOM nodes.
Single-page app: All functionality on one page with 7 tabs (Builder, Results, Sensitivity, Compare, Monte Carlo, Pareto, Quality). Keyboard shortcuts 1–7 switch tabs.
Dark mode: System-preference-aware with localStorage persistence. FOUC prevented via inline <script> in layout.
Inline validation: useValidation hook provides memoized real-time feedback. Builder shows inline borders/messages; Results tab shows a guard for critical errors.
Templates: Pre-built decision templates defined statically in src/lib/templates.ts. instantiateTemplate() generates fresh IDs and zero scores.
Web Worker for Monte Carlo: Heavy simulation runs off-main-thread via monte-carlo.worker.ts. The useMonteCarloWorker hook manages the lifecycle with progress tracking and cancellation. Falls back to main thread when Workers are unavailable.
Multi-algorithm consensus: Beyond WSM, the app runs TOPSIS and Minimax Regret in parallel, then unifies rankings via Borda count. Kendall's W measures concordance across algorithms.
3-tier data enrichment: The enrichment engine tries live providers first, falls back to bundled datasets, then to estimation via income-group/regional proxies. All enriched scores carry provenance and confidence metadata.
i18n: React context-based i18n with useTranslation() hook. Locale files in src/lib/i18n/ (en, es, fr). Persisted to localStorage via LanguageSwitcher.
Real-time collaboration: Supabase Realtime Broadcast + Presence enables live multi-user editing. The realtime.ts engine manages channel lifecycle, action broadcast, and presence tracking. Periodic snapshot reconciliation (every 10s) ensures late joiners and missed messages are handled. fullSync() is skipped when a Realtime channel is active to avoid conflicts. Zero additional bundle cost since Supabase Realtime is included in the existing SDK.