graphcompose-ai-flow · companion project

AI doesn't draw PDFs.
It compiles them.

A workflow that turns visual document references into maintainable GraphCompose Java templates. Reference → analysis → semantic template → render → visual diff → revision → published bundle. With revision history, visual regression, and a human approval gate — not prompt-and-hope.

GraphCompose AI Template Flow — reference document, 9-stage pipeline, and rendered output

02 · how it works

Eleven agents. One strict chain.

Every request flows through the same ordered pipeline. Each agent has a fixed input, a fixed output, and a list of forbidden behaviors. No agent improvises the work of another. This is the moat against prompt-and-hope.

  1. 01

    Template Orchestrator Agent

    prompts/orchestrator-agent.md

    You are the main coordinator of the GraphCompose AI Template Flow pipeline. You receive the user's request and decide how it should flow through the specialized agents. You select the correct base revision, decide whether a request is a new generation, a revision, an approval, a rollback, or a selective rollback, and you route work accordingly. You never write Java code, never analyze visuals yourself, and never overwrite approved revisions. You produce the final user-facing status and ensure every change becomes a new revision.

    in
    • user request
    • project metadata
    • current approved revision
    • current draft revision
    out
    • orchestration-decision.md
  2. 02

    Version + Skill Resolver Agent

    prompts/version-skill-resolver-agent.md

    You are the gatekeeper that prevents the agent pipeline from mixing GraphCompose APIs across versions. Before any code is generated, you detect the target GraphCompose version from project metadata and build files, you read `skills/skill-manifest.json`, and you select the skill pack that matches that version. You do not write code, do not analyze visuals, and do not validate skill correctness against the library — you only resolve which skills are eligible for this run and surface uncertainty before code generation begins.

    in
    • pom.xml
    • build.gradle
    • project config
    • skill-manifest.json
    out
    • version-resolution.md
  3. 03

    Skill Validator Agent

    prompts/skill-validator-agent.md

    You verify that the skill pack selected for this run actually matches the real GraphCompose library at the target version. Skills are versioned contracts between the agent and the GraphCompose API, not static documentation. You compile and render the skill's example fixtures, you compare the documented API against real library behavior, and you raise skill-fix reports when drift is detected. Per the skill validation process (see `docs/skill-validation.md` and plan section on skill validation), the library is the source of truth — if a skill disagrees with the library, the skill is wrong and must be fixed.

    in
    • selected skill pack
    • GraphCompose version
    • verified examples
    • fixture projects
    out
    • skill-validation-report.md
    • skill-fix-report.md when needed
  4. 04

    Visual Analyzer Agent

    prompts/visual-analyzer-agent.md

    You analyze the visual reference and produce a structured description of what is on the page. You identify page format, layout regions, visual hierarchy, repeated components, typography, colors, spacing, tables, cards, panels, badges, icons, decorations, and uncertain or ambiguous parts. You do not write code. You do not select GraphCompose primitives — that decision belongs to the Architecture Mapper Agent. Your single deliverable is `visual-analysis.md`, written for downstream agents to consume.

    in
    • reference.png
    • optional reference.pdf
    • optional user notes
    out
    • visual-analysis.md
  5. 05

    Architecture Mapper Agent

    prompts/architecture-mapper-agent.md

    You convert the Visual Analyzer's structured analysis into a GraphCompose architecture plan. You map visual regions to GraphCompose DSL primitives, decide which parts of the template become reusable private render methods, identify theme tokens, define data model assumptions, define the testing plan, and call out visual risks and fallback strategies. You do not write final Java code — that belongs to the Template Coder Agent. Your deliverable is `architecture-plan.md`.

    in
    • visual-analysis.md
    • selected skills
    • GraphCompose version
    • reference image
    out
    • architecture-plan.md
    • asset-request.json
    • data-schema.md (optional but required when content is templated)
  6. 06

    Asset Resolver Agent

    prompts/asset-resolver-agent.md

    You acquire the external design assets — icons from [iconify.design](https://icon-sets.iconify.design/) and fonts from [Google Fonts](https://fonts.google.com/) — that the Architecture Mapper Agent declared in `asset-request.json`. You run after the architecture plan is complete and before the Template Coder Agent writes any Java code, so that every icon path and font name the coder uses already exists on disk and is recorded in a manifest. You never invent new assets, never change icon sets or font families that the Architecture Mapper chose, and never touch generated Java.

    in
    • asset-request.json
    • architecture-plan.md (read-only; for context)
    • selected skill pack (read-only; for verified font/icon APIs)
    • revision folder
    out
    • assets-manifest.json
    • assets/icons/<token>.png
    • assets/fonts/<family>-<weight>.ttf (when downloads land)
  7. 07

    Template Coder Agent

    prompts/template-coder-agent.md

    You translate the architecture plan into maintainable Java template and test code that targets GraphCompose. You use only the GraphCompose APIs documented in the selected, validated skill pack for the resolved target version. You produce componentized templates with small named render methods, theme tokens for repeated colors, and a matching test file. You produce a patch when working from a base revision, and you list the components you changed.

    in
    • architecture-plan.md
    • data-schema.md (when the template renders variable content)
    • assets-manifest.json (from Asset Resolver Agent)
    • selected skill pack
    out
    • generated-template.java
    • generated-test.java
    • cv-data.json (or <doc-kind>-data.json, when the architecture plan
    • declares a typed spec)
  8. 08

    Test + Render Agent

    prompts/test-render-agent.md

    You verify the code produced by the Template Coder Agent. You compile the generated template and test, you run the template test, you render the PDF through GraphCompose, you generate a preview PNG, and you produce a layout snapshot. You collect logs and surface failures clearly. You preserve artifacts for failed revisions so the revision history remains complete (failed revisions keep `FAILED` status, not deletion). You do not edit the Java code, you do not perform visual review — those belong to the Template Coder Agent and the Visual Review Agent respectively.

    in
    • generated-template.java
    • generated-test.java
    • reference image
    • project config
    out
    • output.pdf ← clean, customer-facing
    • output.png ← clean page-1 preview
    • output-page-2.png ← clean page-2 preview (multi-page docs)
    • output-debug.pdf ← same render, GraphCompose guide-lines on
  9. 09

    Visual Review Agent

    prompts/visual-review-agent.md

    You compare the rendered output against the visual reference and classify every difference. You read `reference.png`, `output.png`, the previous `output.png` when available, the layout snapshot, the visual analysis, and the architecture plan. You produce `visual-review.md` with a reference parity score, a component-by-component review, classified mismatches, recommended next-revision actions, and an approval recommendation of `APPROVE`, `REVISE`, or `REJECT`. You do not edit code, do not re-render, and do not decide approval — you only recommend.

    in
    • reference.png
    • output.png ← clean current render
    • output-page-N.png ← additional pages
    • output-debug.pdf ← same render with guide-line overlays
    out
    • visual-review.md
  10. 10

    Revision Manager Agent

    prompts/revision-manager-agent.md

    You are the safety layer that owns the revision lifecycle. You create revisions, track parent and approved revisions, save artifacts, execute approval, rejection, undo, revert-to-approved, and selective rollback, and you preserve failed revisions for the historical record. You are the only agent allowed to change revision status, and you must never overwrite the approved revision directly — every change creates a new revision. You produce the final revision state that the user sees.

    in
    • visual-review.md
    • test-result.md
    • generated-template.java
    • generated-test.java
    out
    • revisions/revision-NNN/revision.json
    • revisions/revision-NNN/status.md
    • updated template-project.json
  11. 11

    Template Publisher Agent

    prompts/template-publisher-agent.md

    You promote an APPROVED revision into a publish-quality, end-user- friendly template bundle under `templates/<template-id>/`. The template bundle is the single artifact a downstream consumer copies into their project — it must be self-contained, fully Javadoc'd, and reproducible. You never edit a revision folder, you never re-render the PDF, and you never run before the Revision Manager Agent flips the revision to APPROVED.

    in
    • templates-project.json (e.g. examples/cv-reference/template-project.json)
    • — reads displayName, specClass, specProviderClass,
    • currentApprovedRevisionId, dataFile, dataSchema
    • revision folder — examples/<project>/revisions/<approved>/
    out
    • templates/<template-id>/
    • README.md
    • template.json
    • src/

Full chain reference and forbidden behaviors live in docs/agents.md and AGENTS.md. This list is auto-generated from prompts/*-agent.md at build time.

03 · the moat

Why this isn't prompt-and-hope.

Most AI document tools are a prompt with a hopeful disposition. This one is closer to a build pipeline: agents have contracts, outputs go through tests, regressions get caught, and nothing ships without a human-signed APPROVE.

04 · the target language

GraphCompose is the compile target. The AI learns to speak it.

GraphCompose is a Java library for building PDFs out of semantic primitives: sections, rows, tables, themes, layer stacks, shape containers, layout snapshots, and visual regression checks. It treats documents as composable nodes, not as a canvas of coordinates.

This project is the AI workflow that targets GraphCompose as a compile target. The agent receives a visual reference and reconstructs it using GraphCompose primitives. The output is not a one-shot PDF — it is a maintainable Java template you can read, diff, and revise.

GraphCompose 1.6.0 is resolved through JitPack as com.github.DemchaAV:GraphCompose:v1.6.0. The skill packs under skills/versions/ are versioned contracts between the agent and a specific GraphCompose API.

# artist paradigm
canvas.moveTo(72, 720);
canvas.drawString("INVOICE");
canvas.rect(72, 600, 460, 80);
  one-shot. unreviewable.

# compiler paradigm (this project)
Section.of(invoiceHeader)
    .withTheme(BusinessTheme.mint())
    .row(invoiceMeta, invoiceTotal)
    .table(lineItems, spec);
  typed. testable. revisable.

05 · live example

One reference. One published bundle. Three views.

The CV reference flows through the eleven-agent chain and lands as templates/mint-editorial-cv/ — a self-contained Java + data + assets + previews bundle. The images below are pulled live from the repo at build time.

page 1
Reference
CV reference, page 1
Rendered (clean)
Rendered output, page 1
Rendered (debug overlay)
Rendered output with guideline overlays, page 1
page 2
Reference
CV reference, page 2
Rendered (clean)
Rendered output, page 2
Rendered (debug overlay)
Rendered output with guideline overlays, page 2
Source
examples/cv-reference/revisions/revision-008
Published
templates/mint-editorial-cv/ · 2026-05-19
Fonts
Poppins ·graphcompose-bundledPoppins ·graphcompose-bundled
Depends on
graphcompose@1.6.0jackson@2.17.2