Handwritten Document Engine is a production-oriented monorepo scaffold for a document-generation and handwriting-data platform. The product still supports handwritten document generation, but the architecture now also reserves clear boundaries for style libraries, user style profiles, dataset studio workflows, online ink ingestion, parser runs, page-graph normalization, dataset snapshots, config-driven product rules, and future Android sync.
This repository intentionally stays incremental: it provides service boundaries, local infrastructure, developer workflows, and typed contracts without pretending that unbuilt subsystems such as model training or device synchronization are already implemented.
.
|-- apps
| |-- api
| `-- web
|-- deploy
| `-- systemd
|-- docs
| |-- ARCHITECTURE.md
| |-- BILLING_AND_USAGE.md
| |-- DEPLOYMENT.md
| |-- SETUP_UBUNTU_VM.md
| |-- SYSADMIN_RUNBOOK.md
| `-- LOCALIZATION.md
|-- workers
| `-- processor
|-- docker-compose.yml
`-- Makefile
apps/web: React + TypeScript + Vite + Tailwind frontend scaffoldapps/api: Go API with typed config, auth, uploads, Redis-backed async job orchestration, subscription enforcement, credit accounting, billing endpoints, and product-domain contracts for styles, datasets, parser runs, page graphs, training placeholders, sync, and config-driven rulesworkers/processor: Python worker scaffold with Redis intake, a staged processing pipeline, parser MVP support for PDF/PNG-JPG/DOCX/TXT, semantic transformation modes, deterministic layout planning, handwritten render scene generation, multi-format export packaging for PNG/JPG/PDF, restricted machine-export contract parsing, parser-adapter contracts, page-graph placeholders, dataset snapshot placeholders, and API-based status reportingdocker-compose.yml: PostgreSQL, Redis, and MinIO for local development, plus automatic MinIO bucket bootstrap
Multilingual support is a core architecture decision, not a later enhancement. The project supports English and Russian from the start through shared translation keys, locale-aware formatting, and localization-safe API contracts.
- durable contributor rules:
AGENTS.md - developer guide:
docs/LOCALIZATION.md
- Node.js 20+
- npm 10+
- Go 1.24+
- Python 3.12+
- Docker Desktop or compatible Docker engine
- GNU Make or compatible
make
- Copy environment examples where needed.
- Start local infrastructure.
- Install per-service dependencies.
- Run each service in a separate terminal.
make init-env
make up
make install-api
make install-web
make install-worker
make migrate
make dev-web
make dev-api
make dev-worker- Root shared infrastructure variables:
.env.example - Web app:
apps/web/.env.example - API:
apps/api/.env.example - Worker:
workers/processor/.env.example
Each service reads its own environment variables. Shared infrastructure defaults are aligned across examples to keep local development consistent. The example files now contain explicit placeholders for secrets; replace them before starting the stack.
- Web app:
http://localhost:5173 - API health:
http://localhost:8080/healthz - PostgreSQL:
localhost:5432 - Redis:
localhost:6379 - MinIO API:
http://localhost:9000 - MinIO console:
http://localhost:9001
make init-env # copy example env files into local working files
make up # start postgres, redis, minio, and bucket bootstrap
make down # stop local infrastructure
make install-web # install frontend dependencies
make install-api # download Go modules
make install-worker # install Python worker dependencies
make migrate # run database migrations
make seed # seed development data
make dev-web # run Vite dev server on 0.0.0.0
make dev-api # run Go API
make dev-worker # run Python worker
make build-api # compile the Go API binary to ./bin
make build-web # build the frontend production bundle
make preview-web # preview the built frontend on 0.0.0.0
make test # run web, API, and worker tests
make lint # run web, API, and worker linters where configured
make fmt # run formatters where configured- The scaffold avoids business logic and persistence code until requirements are clearer.
- The API and worker both use explicit config loaders with validation because configuration drift is a common early source of failures.
- Docker Compose only provisions shared local infrastructure. App runtimes remain host-managed so they can be started directly from source or wrapped with systemd without rebuilding container images first.
- Localization is built into the frontend architecture and backend contracts from the start rather than being deferred to a later phase.
- The processor reports job lifecycle updates through the API's internal worker contract instead of writing directly to PostgreSQL so job transition rules stay centralized.
- The processor parser MVP normalizes supported file types into a stable parsed-document contract so downstream stages can evolve independently from source-specific extraction code.
- The processor render and export MVPs keep layout, scene construction, rasterization, packaging, and storage registration separate so PNG/JPG/PDF delivery can ship now without blocking later SVG, stroke-based, or machine-oriented exporters.
- Product rules remain config-driven. Billing, plan limits, dataset access, style capabilities, parser-adapter availability, and future training or sync gates should be loaded as data rather than buried in handlers or UI branches.
- Runtime config is stored in PostgreSQL with versioned current entries plus append-only audit logs, so admins can update validated product rules without redeploying the stack.
- Subscription enforcement is centralized in the API so file-size limits, page limits, export-format access, summary-mode access, styled-generation access, style-training access, and credit overage decisions all come from the same policy engine.
- Dataset collections, dataset snapshots, parser runs, page graphs, and training jobs are modeled as adjacent domains rather than being hidden inside generation-job records.
- Restricted machine-writing export is permission-gated in the API and currently limited to internal contracts plus safe extension points for future
svg_path,gcode, andhpglemitters. - Systemd examples and deployment guidance now live under
deploy/systemd/anddocs/so Ubuntu operators can start, supervise, and troubleshoot the stack without reading the codebase in full.
- Extend the queued job flow with object-storage-backed artifact persistence, richer worker observability, and additional export adapters once parsing and rendering subsystems are ready.
- Implement worker-side stroke/path generation and artifact registration for restricted machine export after hardware requirements are concrete.
- Connect the web app's new generation workspace to real upload, job-creation, and status APIs.
- Add real credit top-ups and payment-provider integration only after billing operations, ledgers, and support workflows are stable.
- See
docs/SETUP_UBUNTU_VM.md,docs/DEPLOYMENT.md, anddocs/SYSADMIN_RUNBOOK.mdfor operator-facing startup and maintenance procedures. - See
docs/CONFIG_RULES.mdfor runtime config namespaces, validation, audit history, and effective-resolution behavior. - See
docs/BILLING_AND_USAGE.mdfor plan capabilities, ledger tables, enforcement behavior, and billing endpoints.