aditya0103's picture
Tasks 5-7: eval harness, FastAPI backend, Paper & Ink UI- src/eval/ β€” precision/recall/F1 harness with type-aware comparators,micro/macro F1, CSV + markdown reports, --model benchmark flag- src/api/ β€” FastAPI backend with /extract, /schemas, /health,request-ID middleware, typed error envelope, injectable extractor- ui/ β€” Vite + React + TS + Tailwind + Motion + React Three FiberPaper & Ink editorial UI with 3D paper hero, dark/light mode,confidence inkwell, wax-stamp metrics, kinetic typography- 95 passing tests (up from 54); UI is a separate npm workspace
557ab38
|
Raw
History Blame Contribute Delete
3.38 kB

Ledger UI

The Paper & Ink frontend for the structured-data-extraction API.

Stack

  • Vite + React + TypeScript β€” fast dev loop, small bundle.
  • Tailwind β€” utility layout only. All colors, typography, and design tokens live as CSS variables in src/styles/theme.css, so dark/light mode is a single attribute flip on <html data-theme="...">.
  • Motion (motion/react) β€” component-level animation.
  • React Three Fiber + drei + three β€” the 3D paper sheet in the hero.
  • Google Fonts β€” Instrument Serif (display), Geist (UI), JetBrains Mono (code). All free.

Run locally

# 1. Install
cd ui
npm install

# 2. Point at the API (in another terminal, from the repo root):
uvicorn src.api.main:app --reload

# 3. Start the dev server
npm run dev

# open http://localhost:5173

Vite proxies /api/* to http://localhost:8000, so no CORS needed in dev.

Configuration

  • VITE_API_BASE (optional) β€” override the API origin for prod builds. Defaults to /api.

Design tokens

Everything visual is in src/styles/theme.css:

  • --bg, --surface, --surface-2, --rule β€” surfaces + dividers
  • --ink, --ink-strong, --ink-soft, --ink-mute β€” text weights
  • --accent, --accent-hover, --accent-soft β€” coral
  • --sage, --mustard β€” confidence tiers + warnings

To try a color, edit the variable β€” both modes update simultaneously.

Project shape

ui/
β”œβ”€β”€ index.html                  # font preload + theme priming (no-flash)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.tsx                # ReactDOM render
β”‚   β”œβ”€β”€ App.tsx                 # page composition
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”œβ”€β”€ theme.css           # design tokens (light + dark)
β”‚   β”‚   └── globals.css         # base + grain overlay + focus/cursor
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ TopNav.tsx          # logo + theme toggle
β”‚   β”‚   β”œβ”€β”€ ThemeToggle.tsx     # hand-drawn sun/moon
β”‚   β”‚   β”œβ”€β”€ CustomCursor.tsx    # spring-lag ink dot
β”‚   β”‚   β”œβ”€β”€ Hero.tsx            # kinetic headline + stats + 3D scene
β”‚   β”‚   β”œβ”€β”€ PaperScene.tsx      # R3F: floating paper w/ mouse parallax
β”‚   β”‚   β”œβ”€β”€ ExtractSection.tsx  # workbench (dropzone + results)
β”‚   β”‚   β”œβ”€β”€ Dropzone.tsx        # drop + browse + doc-type + samples
β”‚   β”‚   β”œβ”€β”€ ResultsPanel.tsx    # composes the below
β”‚   β”‚   β”œβ”€β”€ ConfidenceInkwell.tsx # confidence as an ink vessel
β”‚   β”‚   β”œβ”€β”€ MetricsStrip.tsx    # cost/latency/tokens/model
β”‚   β”‚   β”œβ”€β”€ JsonView.tsx        # syntax-highlighted JSON
β”‚   β”‚   β”œβ”€β”€ WarningsList.tsx    # model-flagged concerns
β”‚   β”‚   β”œβ”€β”€ HowItWorks.tsx      # three chapters
β”‚   β”‚   β”œβ”€β”€ Numbers.tsx         # magazine-style data page
β”‚   β”‚   └── Footer.tsx          # signature line
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ useTheme.ts         # dark/light + localStorage
β”‚   β”‚   └── useExtract.ts       # upload lifecycle
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ api.ts              # thin fetch client + typed error envelope
β”‚   β”‚   └── samples.ts          # committed sample docs
β”‚   └── types.ts                # mirrors src/schemas server-side
└── public/samples/             # sample_receipt.png, sample_invoice.pdf