From 62bacdf104201fa34bdabeb11ff728927ac970f1 Mon Sep 17 00:00:00 2001 From: francy51 Date: Sat, 7 Mar 2026 16:52:35 -0500 Subject: [PATCH] Add research workspace and graphing flows --- app/analysis/page.tsx | 161 +-- .../[ticker]/[accessionNumber]/page.tsx | 27 +- app/api/[[...slugs]]/route.ts | 29 +- app/filings/page.tsx | 34 +- app/financials/page.tsx | 27 +- app/graphing/page.tsx | 664 ++++++++++ app/page.tsx | 5 + app/research/page.tsx | 831 ++++++++++++ app/watchlist/page.tsx | 8 + components/shell/app-shell.tsx | 61 +- drizzle/0008_research_workspace.sql | 91 ++ drizzle/meta/_journal.json | 7 + e2e/auth.spec.ts | 100 +- e2e/fixtures/sample-research.txt | 4 + e2e/graphing.spec.ts | 255 ++++ e2e/research-mvp.spec.ts | 110 +- hooks/use-link-prefetch.ts | 7 + lib/api.ts | 215 +++- lib/financial-metrics.ts | 147 +++ lib/graphing/catalog.test.ts | 51 + lib/graphing/catalog.ts | 238 ++++ lib/graphing/series.test.ts | 225 ++++ lib/graphing/series.ts | 189 +++ lib/query/keys.ts | 12 + lib/query/options.ts | 70 +- lib/server/api/app.ts | 456 +++++++ lib/server/db/index.test.ts | 5 + lib/server/db/index.ts | 299 +++++ lib/server/db/schema.ts | 83 +- .../financials/canonical-definitions.ts | 76 +- lib/server/financials/ratios.ts | 57 +- lib/server/financials/trend-series.ts | 2 +- lib/server/repos/research-journal.ts | 154 +-- lib/server/repos/research-library.ts | 1122 +++++++++++++++++ lib/types.ts | 100 ++ package.json | 2 +- scripts/e2e-prepare.ts | 4 +- 37 files changed, 5494 insertions(+), 434 deletions(-) create mode 100644 app/graphing/page.tsx create mode 100644 app/research/page.tsx create mode 100644 drizzle/0008_research_workspace.sql create mode 100644 e2e/fixtures/sample-research.txt create mode 100644 e2e/graphing.spec.ts create mode 100644 lib/financial-metrics.ts create mode 100644 lib/graphing/catalog.test.ts create mode 100644 lib/graphing/catalog.ts create mode 100644 lib/graphing/series.test.ts create mode 100644 lib/graphing/series.ts create mode 100644 lib/server/repos/research-library.ts diff --git a/app/analysis/page.tsx b/app/analysis/page.tsx index ac6f9b8..ae9a5cf 100644 --- a/app/analysis/page.tsx +++ b/app/analysis/page.tsx @@ -16,6 +16,7 @@ import { import { BrainCircuit, ChartNoAxesCombined, + NotebookTabs, NotebookPen, RefreshCcw, Search, @@ -29,6 +30,7 @@ import { Input } from '@/components/ui/input'; import { Panel } from '@/components/ui/panel'; import { useAuthGuard } from '@/hooks/use-auth-guard'; import { useLinkPrefetch } from '@/hooks/use-link-prefetch'; +import { buildGraphingHref } from '@/lib/graphing/catalog'; import { createResearchJournalEntry, deleteResearchJournalEntry, @@ -407,6 +409,14 @@ function AnalysisPageContent() { > Open filing stream + prefetchResearchTicker(analysis.company.ticker)} + onFocus={() => prefetchResearchTicker(analysis.company.ticker)} + className="text-sm text-[color:var(--accent)] hover:text-[color:var(--accent-strong)]" + > + Open graphing + ) : null} @@ -756,113 +766,70 @@ function AnalysisPageContent() { )} -
+
prefetchResearchTicker(activeTicker)} + onFocus={() => prefetchResearchTicker(activeTicker)} + className="inline-flex items-center gap-2 rounded-lg border border-[color:var(--line-weak)] px-3 py-2 text-xs uppercase tracking-[0.12em] text-[color:var(--accent)] transition hover:border-[color:var(--line-strong)] hover:text-[color:var(--accent-strong)]" + > + + Open research + + )} > -
-
- - setJournalForm((prev) => ({ ...prev, title: event.target.value }))} - placeholder="Investment thesis checkpoint, risk note, follow-up..." - /> +
+
+

Workspace focus

+

+ Use the research surface to manage the typed library, attach evidence to memo sections, upload diligence files, and assemble the packet view for investor review. +

-
- - setJournalForm((prev) => ({ ...prev, accessionNumber: event.target.value }))} - placeholder="0000000000-26-000001" - /> +
+
+

Stored research entries

+

{journalEntries.length}

+
+
+

Latest update

+

{journalEntries[0] ? formatDateTime(journalEntries[0].updated_at) : 'No research activity yet'}

+
-
- -