Hugo — Fund-Side Letter Platform
Single-worker worker architecture for fund setup, investor work, document workflows, exports, and AI-assisted clause operations.Hugo is one Cloudflare Worker that serves:
- browser pages for fund operations and administration
- JSON APIs for internal clients and the Word add-in
- asynchronous parse jobs via Queues
- hourly scheduled maintenance in the same worker process
Current route surface
Top-level registrars (
src/routes/register-routes.tsx)/api/feedbackand/addin/word-feedback— feedback draft + template feedback endpoints/api/events— review analytics ingestion/addin/word-api/*— allowlisted Word API bridge and related add-in callbacks/api/users— identity and session switch helpers/admin— admin-only utility endpoints/api— fund/investor/clause/chat/search endpoints/api/chat— tool-aware chat surface/auth/addin-complete— Word taskpane session handoffpage-routes— all HTML pages below
Page route groups (
src/routes/page-routes.tsx)core: fund, sponsor, and closing pagesinvestor: global investor directory and fund-scoped investor/commitment viewsintelligence: recommender and network graphlibrary: clause library, grouping, MFN exclusions, pro-forma builderconfiguration: setup/closings/settings, template settings, clause text variablestask: fund tasks, LP tasks, comments, activitymfn: MFN and ISL screensupload: side letter upload, parse status, review/mergeexport: export orchestration and preview/download routes
Runtime and middleware shape
Worker entrypoint
src/index.tsx exports one app with three entry handlers:
- fetch (HTTP)
- queue (parse queue consumer)
- scheduled (hourly maintenance sweep)
There is no separate API worker or queue worker process in this repo.
Auth and request setup
- Auth: fail-closed CF Access gate when
REQUIRE_CF_ACCESSis true, with app-level identity fallback for dev/review modes. - Fund context: resolves
:fundSlugtoc.var.fundId/c.var.fundStatus. - Closed-fund policy: applied to
/funds/:fundSlugand/api/funds/:fundSlugroutes. - Review gate: optional password gate via
review.hugo.nordiclawfirm.com.
Runtime bindings
| Binding | Role |
|---|---|
DB (D1) | Application state and workflow tables |
FEEDBACK_DB (D1) | feedback draft store + rate limits |
DOCUMENTS (R2) | raw uploads and generated export artifacts |
PARSE_QUEUE (Queue) | async doc parse jobs + DLQ |
AI_GATEWAY_ID / AI env vars | Cloudflare AI Gateway + Heimdall provider calls |
| CHAT_* env vars | optional clause-chat endpoint controls |
Background execution
- Queue: async document parsing and classification runs off request path.
- DLQ: permanent parse failures are recorded through a dead-letter consumer.
- Scheduled sweep: repairs stuck parse jobs, cleans orphaned managed R2 objects, and retires old exports/preview artifacts.
- Database handling: request handlers use retry-wrapped D1 proxies on
c.var.dbandc.var.feedbackDb.
Primary product surfaces
For implementation follow
docs/developer-map.md; for live bindings, use docs/architecture-log.md and README.md together.