WunderLedger is an AI-assisted invoice and receipt categorisation SaaS platform designed for SMEs, accountants, and finance teams. The MVP is a web-first, multi-tenant product with Dropbox-first ingestion, OCR-driven extraction, rules-first categorisation, AI fallback, manual review, monthly summaries, and Excel export.
This repository is structured as a modular monorepo so that connectors, OCR providers, export targets, country presets, and runtime services can evolve independently without breaking the core product.
WunderLedger aims to reduce the operational burden of invoice and receipt handling by providing:
- secure document ingestion from Dropbox and manual upload
- OCR and structured field extraction
- rules-first categorisation with controlled AI fallback
- human review queue for low-confidence or ambiguous items
- transaction and monthly summary generation
- accountant-friendly Excel export
- internal admin and operational visibility
- country-aware configuration, with Hong Kong as the first production preset
The repository and delivery plan are based on the following non-negotiable principles:
-
Web MVP first
- The first live release is a web application.
- Mobile capture is deferred to Phase 1.5.
-
Multi-tenant by design
- Tenant separation is enforced at the database layer with Postgres Row Level Security.
- Workspace membership and role checks are also enforced in the application layer.
-
Rules-first, AI-second
- Deterministic rules are used first for supplier, keyword, memory, and category assignment.
- AI fallback is only invoked when rules cannot produce an acceptable result.
- AI must be constrained to configured active categories and never invent unsupported categories.
-
Asynchronous processing
- OCR, sync, exports, retries, and recalculation are handled in background workers.
- User-facing API paths should remain responsive and not block on long-running jobs.
-
Configuration over hardcoding
- Country defaults, categories, parser hints, export rules, and tax labels are stored as data or configuration.
- Hong Kong is the first active country profile, but the platform must be extensible to other countries.
-
Replaceable providers
- Dropbox is the first ingestion connector.
- Google Document AI is the first OCR provider.
- Excel is the first export target.
- All of these are abstracted behind interfaces to support later replacement or expansion.
-
TDD and regression discipline
- Domain logic is built with test-driven development where practical.
- Every bug fix requires a regression test.
- RLS policies, integration boundaries, and exports must all be test-covered.
- Next.js App Router
- TypeScript
- Tailwind CSS
- shadcn/ui
- TanStack Query
- React Hook Form
- Zod
- Node.js LTS
- Fastify for API and worker services
- OpenAPI for service contract documentation
- Supabase Auth
- Supabase Postgres
- Row Level Security
- SQL-first migrations
- Google Document AI as the first OCR and invoice/receipt extraction provider
- Google Cloud Run
- Google Cloud Tasks
- Google Cloud Scheduler
- Google Secret Manager
- Google Cloud Logging and Monitoring
- ExcelJS or SheetJS for
.xlsxgeneration - Google Sheets export in Phase 1.5
- Vitest
- Playwright
- Supertest
- Testcontainers where needed for integration parity
- Google Cloud is the primary runtime platform.
- Supabase Postgres is the primary system-of-record database.
- GitHub is the source control system and code review platform.
- Replit is not the source of truth.
- Replit may be used only for isolated prototyping or demos if needed.
- Backups must rely on GitHub, managed database backups, and infrastructure-as-code, not Replit.
wunderledger/
├─ apps/
│ ├─ web/
│ ├─ mobile/
│ ├─ admin/
│ ├─ api/
│ └─ worker/
├─ packages/
│ ├─ ui/
│ ├─ config/
│ ├─ types/
│ ├─ database/
│ ├─ auth/
│ ├─ tenancy/
│ ├─ country-profiles/
│ ├─ categories/
│ ├─ connectors/
│ │ ├─ core/
│ │ └─ dropbox/
│ ├─ document-core/
│ ├─ ocr/
│ │ ├─ core/
│ │ └─ google-document-ai/
│ ├─ categorisation/
│ │ ├─ rules-engine/
│ │ ├─ memory-engine/
│ │ └─ ai-fallback/
│ ├─ review/
│ ├─ transactions/
│ ├─ summaries/
│ ├─ exports/
│ │ ├─ excel/
│ │ └─ google-sheets/
│ ├─ jobs/
│ ├─ observability/
│ └─ testing/
├─ infra/
│ ├─ terraform/
│ │ ├─ environments/
│ │ │ ├─ dev/
│ │ │ ├─ staging/
│ │ │ └─ prod/
│ │ └─ modules/
│ │ ├─ cloud-run/
│ │ ├─ cloud-tasks/
│ │ ├─ secret-manager/
│ │ ├─ monitoring/
│ │ └─ scheduler/
│ ├─ supabase/
│ │ ├─ migrations/
│ │ ├─ seeds/
│ │ ├─ policies/
│ │ └─ functions/
│ └─ github/
│ └─ workflows/
├─ docs/
│ ├─ architecture/
│ ├─ product/
│ ├─ engineering/
│ └─ api/
├─ .github/
│ ├─ ISSUE_TEMPLATE/
│ ├─ PULL_REQUEST_TEMPLATE.md
│ └─ workflows/
├─ scripts/
├─ package.json
├─ turbo.json
├─ pnpm-workspace.yaml
├─ .env.example
└─ .gitignore
- user authentication
- workspace creation
- role-based access
- internal admin impersonation
- workspace-safe service access
- country profile
- currency/date/tax labels
- financial year configuration
- language defaults
- plan limits and feature flags
- Dropbox connector first
- later Google Drive, OneDrive, SharePoint, accounting APIs
- source file discovery
- deduplication
- normalisation
- queueing
- retry lifecycle
- provider abstraction
- raw OCR capture
- canonical field mapping
- confidence scoring
- extracted line items
- parser diagnostics
- supplier rules
- keyword rules
- memory-based assignment
- constrained AI fallback
- confidence and reasoning output
- review queue
- preview
- field editing
- approve / recategorise / duplicate / archive / reprocess
- accounting-friendly transaction records
- monthly aggregation
- summary line generation
- reconciliation support
- Excel export in MVP
- Google Sheets export in Phase 1.5
- export jobs and audit trail
- workspace view
- job monitoring
- error centre
- audit logs
- usage metrics
- support tooling
Target: 2 weeks
Scope:
- monorepo bootstrap
- CI/CD
- local developer tooling
- environment scaffolding
- Google Cloud and Supabase setup
- base schema
- test harness
- architecture documentation
Deliverables:
- repo structure
- initial README
- CI pipeline
- migrations
- baseline environment setup
- first ADR set
Target: 8 to 10 weeks
Scope:
- auth and tenancy
- workspace settings
- Hong Kong country profile
- categories
- manual upload
- Dropbox OAuth and sync
- OCR extraction
- rules-first categorisation
- AI fallback
- review queue
- transactions
- monthly summaries
- Excel export
- admin ops basics
- audit logging
Deliverables:
- web MVP deployed to staging
- complete review-to-export workflow
- admin visibility into jobs and errors
- UAT-ready demo pack
Target: 4 to 6 weeks
Scope:
- Expo mobile app
- scan/capture flow
- upload and preview
- recent uploads
- Google Sheets export
- categorisation memory improvements
- duplicate handling improvements
Deliverables:
- mobile capture MVP
- Google Sheets export
- improved review ergonomics
Target: 6 to 10 weeks
Scope:
- more source connectors
- accounting platform integrations
- more country profiles
- billing enforcement
- expanded admin and support features
The project follows practical TDD, not ceremonial TDD.
Used for:
- rule evaluation
- supplier mapping
- memory lookups
- summary calculations
- date and tax format resolution
- export formatting helpers
Used for:
- repository behaviour
- RLS policy behaviour
- API contract checks
- worker job handlers
- Dropbox adapter contract tests
- OCR mapping tests
Used for:
- auth and workspace creation
- manual upload to review queue
- review approval to transaction generation
- Dropbox sync flow
- export generation
- admin visibility
- Every production bug requires a failing test before the fix is merged.
localdevstagingprod
- Supabase local or remote dev instance
- environment variables from
.env.local - seeded sample categories and country data
- mock Dropbox and OCR fixtures where practical
The MVP should include:
- secure OAuth token storage
- encrypted secrets management
- workspace-safe database access
- audit logging for key state changes
- role-based access control
- document metadata tracking
- low-privilege service accounts
- staged environments
- no hardcoded secrets in repo
This repo-ready package includes:
- root README
- codebase bootstrap script
.gitignore- initial SQL schema
- milestone backlog
- GitHub labels and issues seed files
- ADR documents
- placeholder docs for architecture and engineering conventions
- Run the bootstrap script in
~/WunderLedger/ - Copy the generated files into the local repository root if needed
- Review and adjust the README sections
- Create the first milestone and issues in GitHub
- Apply the Supabase migration
- Begin Phase 0 implementation
Not in MVP unless later approved:
- full accounting platform integrations
- complex tax engine beyond country-configured defaults
- advanced AI explanation UI
- production billing engine
- multi-cloud deployment
- offline-first mobile support
- custom OCR provider marketplace
mainfor production-ready codedevelopoptional if you prefer release train discipline- short-lived feature branches for implementation
Recommended:
feat:fix:docs:test:refactor:chore:
- linked issue
- acceptance criteria satisfied
- tests added or updated
- no secret leakage
- docs updated where relevant
Suggested initial ownership:
apps/web— frontend ownerapps/apiandapps/worker— backend ownerpackages/categorisation— domain ownerpackages/connectors/dropbox— integration ownerinfra/*— platform ownerdocs/*— shared ownership, tech lead approval
This repository package is a starting framework, not a finished implementation. It is intentionally structured to support staged delivery, strict tenancy, modularity, and testability from the beginning.