DEV Community

Cover image for How I Built a Contract Automation Platform with ASP.NET, Angular, and Dynamic .docx Templates
Bogdan Pil
Bogdan Pil

Posted on

How I Built a Contract Automation Platform with ASP.NET, Angular, and Dynamic .docx Templates

When I started building Contractize.app, my goal was simple: let people create clean, accurate contracts in seconds β€” without legal friction.

But making that work under the hood? That was the fun part.

In this post, I’ll share how I built the backend with ASP.NET, the frontend with Angular, and integrated external document rendering through .docx templates and Formize API to generate final PDFs β€” all with automation in mind.


πŸ› οΈ Tech Stack Overview

  • Frontend: Angular
  • Backend: ASP.NET Core
  • Document Templates: Microsoft Word .docx files
  • API Integration: Formize.com (for template filling & PDF generation)
  • Output: Publicly accessible PDF contracts

πŸ“„ Why .docx?

Instead of hardcoding templates or using plain-text, I chose .docx because:

  • It's familiar to end users (Word format = comfort).
  • It supports rich formatting (tables, styles, variables).
  • It's editable by non-tech staff (lawyers, ops, etc.).

Templates were uploaded to a central storage on Formize.com, where variable placeholders like {{clientName}} or {{startDate}} were pre-defined.


πŸ”Œ API Flow: Dynamic Contract Generation

Here's the high-level flow of how dynamic contract creation works:

  1. User fills a form on the frontend (Angular).
  2. Data is sent to ASP.NET backend.
  3. Backend compiles a JSON object with the correct variables.
  4. A POST request is made to Formize API:

    {
      "templateId": "nda-template.docx",
      "data": {
        "clientName": "Acme Corp",
        "startDate": "2025-05-27",
        ...
      }
    }
    
  5. Formize fills the .docx template and returns a PDF download link.

  6. The backend saves that link, sends it to the frontend, and optionally emails it to the client.

⚑ The result? A professional, filled, legally structured contract in under 5 seconds.


πŸš€ Lessons Learned

  • Using .docx was a game-changer: Legal teams can update templates without touching code.
  • ASP.NET + Angular combo was seamless, especially for form validation and API integration.
  • Formize API saved weeks of work by abstracting template parsing and PDF generation.
  • Caching document links (or PDFs themselves) is key for performance if users generate many contracts in a session.

πŸ“š Next Steps

We're now expanding to:

  • Dynamic clause toggles (e.g. include/exclude arbitration).
  • Multi-language templates.
  • eSignatures (integrating DocuSign or HelloSign).

If you're building anything document-related, or want to automate contracts for your team or startup β€” feel free to ping me or check out Contractize.app. Happy to share more behind-the-scenes!


πŸ’¬ Have you ever built a doc-generation flow? Used .docx in production? Would love to hear your setup.

Top comments (4)

Collapse
 
loykozak profile image
Zakhar Shelkovnikov

Great read, Bogdan!
Your work is a significant contribution to the field of document automation, and I look forward to seeing how Contractize.app evolves. Wishing you continued success in your endeavors!

Collapse
 
yelnur_seitzhanov_f2de0a2 profile image
Yelnur Seitzhanov

Sounds very interesting

Collapse
 
mikeev profile image
Ruslan Mikeev

Unusual approach.

Collapse
 
rogach profile image
Maksym

Great solution