Document Generation Service
Generate DOCX/PDF from versioned templates and dynamic JSON data.
Convention-based template discovery — drop a file, it's live. No code changes.
- Zero-code document types — Drop
{type}_v{version}.docxintotemplates/and it's immediately available via the API - Legacy
.docsupport — Old Word templates auto-convert to.docxvia LibreOffice - PDF output — Seamless DOCX→PDF via LibreOffice (baked into the Docker image)
- Versioned templates — Multiple versions coexist; latest is used unless a specific version is requested
- RESTful API — Clean resource model (
documents,document-types) with OpenAPI docs - No database — Metadata is encoded in filenames; everything lives on disk (swap out for S3/Postgres when you're ready)
- Docker-native — Single
docker compose upwith LibreOffice included
git clone https://github.com/yoosuf/docket.git
cd docket
docker compose up --buildOpen http://127.0.0.1:8000/docs — interactive API docs are ready.
./scripts/try_document.sh # invoice, docx
./scripts/try_document.sh quote pdf # quote, pdf
./scripts/try_document.sh purchase_order pdf # purchase_order, pdfcurl -X POST http://127.0.0.1:8000/api/v1/documents \
-H "Content-Type: application/json" \
-d @docs/examples/invoice.json- Create a template (
docxtpl-compatible.docxwith Jinja2 placeholders) - Name it
{type}_v{version}.docxand drop it intotemplates/ - That's it — no code, no config, no restart
| Document | What's inside |
|---|---|
docs/architecture.md |
Module layout, component & sequence diagrams, extension points |
docs/design-decisions.md |
ADR-style rationale for key architectural choices |
docs/production-readiness.md |
Migration guide: local disk → S3, no DB → Postgres, sync → job queues |
docs/examples.md |
Ready-to-run samples for all 5 shipped document types |
pytest36 tests exercising template resolution, service orchestration, REST endpoints, and rendering — no mocks on the DOCX layer.
Modular monolith — one domain (documents) in one folder:
app/
├── main.py # Composition root (FastAPI app)
├── core/ # Config, errors, middleware
└── modules/
└── documents/ # Router, service, repository, models
Full architecture docs at docs/architecture.md.
| Type | Template | Version |
|---|---|---|
| Invoice | invoice_v1.docx |
1 |
| Quote | quote_v1.docx |
1 |
| Purchase Order | purchase_order_v1.docx |
1 |
| Contract | contract_v1.docx |
1 |
| Memo | memo_v1.doc (legacy) |
1 |
FastAPI · docxtpl (Jinja2-in-DOCX) · LibreOffice (PDF conversion) · Docker · Pydantic · Uvicorn
MIT © 2026 Yoosuf
Status: POC — no production dependencies (no DB, no S3, no auth, no queues). Ready to evolve into a full document service — see the production-readiness guide.