AKP-Hub | Digital Marketing

Building a Deterministic Document Automation System with Python

Most productivity problems are not complex.

They are repetitive.

For me, that problem was document formatting.

Every day, I spent nearly 30 minutes formatting structured notes into professional documents:

  • Adjusting font sizes

  • Changing heading colors

  • Fixing spacing

  • Aligning bullet lists

  • Styling tables

  • Applying borders and margins

For a 10-page document, that adds up quickly.

Instead of optimizing the template, I decided to rethink the system.

Deterministic

Formatting is not creative work.

It is mechanical repetition.

And most people solve it using one of three approaches:

  1. Manual formatting in Word

  2. Templates

  3. AI-based formatting tools

Each has trade-offs.

Templates reduce work but still require correction.
AI APIs introduce cost, unpredictability, and external dependency.
Local LLMs require significant hardware resources.

I wanted something else:

  • Predictable

  • Fast

  • Offline

  • Fully customizable

  • Architecturally clean

That’s how NotesForge began.

Why I Didn’t Use AI

As someone familiar with transformers, RAG systems, and generative AI workflows, building an AI-powered formatter seemed natural.

But after testing multiple approaches, I rejected AI for this use case.

1. API-Based AI Limitations

  • Paid usage

  • Rate limits

  • Dependency on external services

  • Non-deterministic outputs

Formatting needs consistency. Not creativity.

2. Local LLM Constraints

  • High GPU requirements

  • Slow inference on consumer hardware

  • Significant power consumption

  • Overkill for structured formatting

Using probabilistic models to apply font sizes is unnecessary.

This is a deterministic problem. So I built a deterministic solution.

Introducing NotesForge

NotesForge is a modular document automation system built using:

  • Python

  • Streamlit

  • python-docx

  • JSON-based configuration

It transforms structured plain text into professionally formatted Word and PDF documents in seconds.

  • No AI APIs.
  • No heavy models.
  • No unpredictability.
Deterministic document automation architecture showing modular MVC design with Streamlit frontend, configuration layer, and python-docx document builder

The Role of Claude and GPT in Building NotesForge

Although NotesForge is intentionally deterministic and does not rely on AI APIs at runtime, generative AI played a strategic role during development.

This distinction is important.

AI was not used as a feature.
It was used as a development accelerator.

Why Claude?

Claude (Sonnet 4.5) was primarily used for:

  • Logic refinement

  • Structural improvements

  • Reviewing classification flows

  • Stress-testing edge cases

Its strength lies in reasoning-heavy outputs and architectural thinking.
It helped refine regex ordering, detection hierarchy, and modular breakdown.

But the final implementation logic was reviewed, rewritten, and structured manually.

Claude assisted.
It did not replace engineering decisions.

Why GPT?

GPT was used differently.

Primarily for:

  • Research on Streamlit architecture

  • Understanding python-docx XML styling patterns

  • Exploring modular design strategies

  • Comparing deterministic vs probabilistic workflows

It acted more as a research partner than a code generator.

Why Not Use AI in the Final Product?

This is the critical architectural insight.

AI helped build the system.

But AI was deliberately excluded from the runtime system.

Reasons:

  • Formatting is deterministic.

  • Predictability is more valuable than creativity.

  • API costs are unnecessary for structured logic.

  • Local LLM overhead is unjustified for rule-based tasks.

In other words:

AI accelerated development.
Deterministic logic powers execution.

A Practical Hybrid Philosophy

This project represents a modern development pattern:

Use AI to think faster.
Use engineering to design.
Use logic to execute.

That distinction matters.

NotesForge is not anti-AI.
It is anti-misuse-of-AI.

Architecture: Modular MVC Design

NotesForge follows a modular MVC-inspired architecture.

System Flow

User → Frontend → Configuration Layer → Business Logic → DOCX/PDF Output

Frontend Layer (Streamlit):

Handles:

  • Text input

  • Live preview

  • Theme switching

  • Settings customization

  • Download generation

Configuration Layer:

  • ConfigManager (JSON-based settings)

  • ThemeManager (preset and custom themes)

  • 150+ configurable styling parameters

Business Logic Layer (Core Engine):

Contains:

  1. TextAnalyzer

  2. DocumentBuilder

  3. PDFBuilder

Each module has a single responsibility.

How the Intelligent Classification Engine Works

The core of deterministic document automation lies in structured pattern detection.

For every line of text, the system:

  1. Cleans markdown artifacts

  2. Applies ordered regex classification

  3. Assigns semantic type

Priority hierarchy ensures predictable results.

The engine detects:

  • Day headings

  • Topic headings

  • Section headings

  • Bullets and numbered lists

  • Shell commands

  • Code blocks

  • File paths

  • Tables (pipes, spaces, tabs)

  • Labels (Example:, Note:, Steps:)

  • Quotes

  • Mathematical formulas

This structured detection ensures consistent formatting.

Document Generation Engine

Once classification completes:

  1. A new Word document object is created

  2. Header and footer applied

  3. Margins and borders configured

  4. Each classified element styled using config rules

  5. Tables built with alternating row colors

  6. File saved and returned

PDF generation uses DOCX conversion with fallback handling.

Performance benchmarks:

  • 100 lines: ~0.2 seconds

  • 1000 lines: ~1.5 seconds

  • 10,000 lines: ~15 seconds

The system scales efficiently.

Key Features​:

  • 10+ content types auto-detected

  • 50+ commands recognized (expandable)

  • 6 built-in themes

  • 150+ customization options

  • Live preview with statistics

  • Real-time theme switching

  • Modular architecture

  • JSON-based configuration

  • Cross-platform support

Real-World Impact

Manual workflow: ~30 minutes per document
NotesForge workflow: 30–90 seconds

Beyond speed, the real value is:

  • Consistency

  • Reusability

  • Config-driven styling

  • Reduced cognitive load

  • Professional output

This system is now part of my daily workflow.

Why Deterministic Systems Still Matter

There is a growing assumption that AI should power every solution.

But deterministic systems are:

  • Predictable

  • Auditable

  • Lightweight

  • Fast

  • Cost-free after development

Not every problem requires probabilistic reasoning.

Some require structured logic.

NotesForge is an example of choosing architecture over hype.

Future Enhancements

Planned improvements include:

  • Enhanced heading detection

  • LaTeX equation support

  • Dark mode UI

  • Template library

  • Batch processing

  • Cloud sync

  • Optional AI-assisted workflow

The core engine remains deterministic.

Conclusion

NotesForge started as a personal productivity experiment.

It evolved into a deterministic document automation system that replaces repetitive formatting with structured logic.

Innovation is not always about adding intelligence.

Sometimes, it is about removing unnecessary complexity.

Explore the Project

References

Now that you have an overview about NotesForge take a look on official documents for more information,

For discussions: ashish@akpghub.live or LinkedIn: Ashish Krishna Pavan Gade

Leave a Comment