DEV Community

Anthony Leignel
Anthony Leignel

Posted on Edited on

📄 Client-Side Quote Generator Architecture in JavaScript: PDF Generation, International Tax Rules, and Privacy

Client-side quote generator interface

A quote generator does not necessarily require a backend, a database, or an authentication system.

When its purpose is to collect information, apply business rules, calculate amounts, and produce a PDF document, the entire processing workflow can run directly in the browser.

This approach becomes particularly interesting when the application must support different tax systems, multiple currencies, international transactions, and bilingual documents without transmitting user data to a server.

This article presents the architecture of a quote generator designed for businesses and independent professionals established in France and the United States, developed using HTML, CSS, and vanilla JavaScript, with client-side PDF generation.


1. An Architecture Without a Backend

The application relies on a single HTML file containing the user interface, styles, business logic, and document generation.

index.html
│
├── User interface
├── CSS styles
├── JavaScript logic
├── Tax rules
├── Financial calculations
└── PDF generation
Enter fullscreen mode Exit fullscreen mode

These are not six separate files, but distinct responsibilities grouped within the same page.

The technology stack is intentionally limited:

Technology Responsibility
HTML Form structure
CSS Presentation and layout
Vanilla JavaScript Data processing and business logic
jsPDF PDF document generation
DM Sans / DM Mono Typography

No JavaScript framework, NPM installation, or build step is required.

The web server is only responsible for delivering the application. It does not participate in calculations or quote generation.

Web server
     │
     │ Page loading
     ▼
Browser
     │
     ├── Data input
     ├── Calculations
     ├── Tax rules
     └── PDF generation
              │
              ▼
        Local download
Enter fullscreen mode Exit fullscreen mode

The browser therefore becomes the application's complete execution environment.


2. Data Management and Dynamic Calculations

The interface allows users to enter issuer information, client details, services, quantities, prices, and tax parameters.

Service line items are dynamic. Users can add or remove them, while JavaScript recalculates the corresponding amounts.

The calculation logic must remain consistent between the interface and the final document.

A conceptual data model could be represented as follows:

const quote = {
    issuer: {
        country: "FR"
    },
    client: {
        country: "FR",
        type: "business"
    },
    currency: "EUR",
    language: "fr",
    items: [
        {
            description: "Development services",
            quantity: 2,
            unitPrice: 500
        }
    ]
};
Enter fullscreen mode Exit fullscreen mode

This example illustrates the different categories of data required for processing. It is not an excerpt from the application's source code.

A line item calculation relies on the quantity and unit price:

const quantity = 2;
const unitPrice = 500;
const taxRate = 20;

const subtotal = quantity * unitPrice;
const tax = subtotal * taxRate / 100;
const total = subtotal + tax;
Enter fullscreen mode Exit fullscreen mode

In this example, the subtotal is €1,000, the tax is €200, and the total is €1,200.

However, this basic calculation represents only part of the business logic. Before calculating a tax, the system must determine whether it applies to the transaction context.

Handling monetary amounts also requires particular attention to rounding. JavaScript uses floating-point numbers, which can introduce precision discrepancies.

A financial application must therefore define a consistent rounding policy, particularly between displayed amounts, calculated totals, and the generated PDF.


3. Two Issuer Countries, Multiple Tax Contexts

The main complexity of the generator is not PDF production, but adapting the document to its business context.

The application supports two countries of establishment for the issuer:

  • France
  • United States

The client's country may differ from the issuer's country. The generator must therefore distinguish between the country of establishment, the transaction destination, the client type, and the nature of the service.

Issuer country
       │
       ▼
Client country and type
       │
       ▼
Nature of the transaction
       │
       ▼
Tax context
       │
       ├── Applicable tax
       ├── Tax rate
       └── Required notices
Enter fullscreen mode Exit fullscreen mode

This information affects both the calculations and the document content.

The issuer's country must not be confused with the interface language or the quote currency. These parameters represent separate responsibilities.


4. Supporting French Issuers

For an issuer established in France, the generator adapts identification fields and tax rules to the selected context.

It supports, among other scenarios:

  • SIREN, SIRET, and intra-EU VAT identification numbers
  • French VAT
  • VAT exemption under the French small business exemption scheme
  • Intra-EU transactions
  • Reverse charge mechanisms when the applicable conditions are met
  • Transactions with clients located outside the European Union

Tax logic therefore involves more than adding a percentage to the subtotal.

A domestic service subject to VAT and an intra-EU B2B service subject to reverse charge may produce documents with different amounts and tax notices.

In the second case, the absence of VAT charged by the issuer must be accompanied by the notice corresponding to the applicable tax treatment.

The engine must therefore maintain consistency between several elements:

Billing context
       │
       ├── Issuer identification
       ├── Client identification
       ├── Subtotal excluding tax
       ├── VAT treatment
       └── Tax notices
Enter fullscreen mode Exit fullscreen mode

Supporting the French small business VAT exemption scheme also requires logic distinct from that of an international transaction outside the scope of French VAT.

Even when two quotes display the same tax amount, the underlying tax treatment may be different.


5. Supporting US Issuers

For an issuer established in the United States, the generator adapts identification information and tax handling.

Identification includes the Employer Identification Number (EIN), while billing can be performed in US dollars.

The main difference from the French system concerns Sales Tax.

Unlike a national VAT system, Sales Tax obligations and rates can depend on multiple jurisdictions, including states and local authorities.

The generator does not attempt to determine these rates automatically.

For supported domestic transactions, the user indicates whether the issuer is registered for Sales Tax and enters the applicable rate when necessary.

A conceptual calculation could be:

const subtotal = 1000;
const salesTaxRate = 8.25;

const salesTax = subtotal * salesTaxRate / 100;
const total = subtotal + salesTax;
Enter fullscreen mode Exit fullscreen mode

Result:

Subtotal   : $1,000.00
Sales Tax  :    $82.50
Total      : $1,082.50
Enter fullscreen mode Exit fullscreen mode

The 8.25% rate is used for illustration only. It is not a universal rate applicable across the United States.

This separation between determining the rate and applying it allows the application to remain entirely client-side without integrating an external tax lookup service.

The generator also supports certain international contexts, including B2B services supplied to European Union clients with VAT identification.

The objective is not to reproduce the entire US tax system, but to provide the mechanisms required for the documented scenarios while leaving users responsible for entering the applicable parameters.


6. Separating Tax Rules, Language, and Currency

An international application must avoid confusing three different dimensions: tax context, language, and currency.

The generator provides a French and English interface, bilingual PDF generation, and five supported currencies:

EUR  Euro
USD  US Dollar
GBP  British Pound
CHF  Swiss Franc
CAD  Canadian Dollar
Enter fullscreen mode Exit fullscreen mode

For example, a French issuer can prepare an English-language quote for a US client, expressed in US dollars.

Issuer   : France
Client   : United States
Language : English
Currency : USD
Enter fullscreen mode Exit fullscreen mode

The language determines the document labels, while the currency determines how monetary amounts are presented. Tax treatment depends on the transaction context.

Monetary formatting can be handled using native JavaScript functionality.

const amount = 1250.50;

const formatted = new Intl.NumberFormat("en-US", {
    style: "currency",
    currency: "USD"
}).format(amount);

console.log(formatted);
Enter fullscreen mode Exit fullscreen mode

Result:

$1,250.50
Enter fullscreen mode Exit fullscreen mode

This example illustrates a native browser feature suitable for this type of architecture.

Selecting a currency does not mean that a currency conversion is performed. The generator allows amounts to be expressed in different currencies without relying on an exchange rate API.


7. Generating PDFs Directly in the Browser

Document generation relies on jsPDF.

This library allows PDF documents to be constructed from data processed in JavaScript without sending requests to a remote rendering engine.

The final document can include issuer and client information, services, amounts, taxes, applicable notices, and an acceptance section with a date and signature.

The generator also supports custom logos in several image formats, including PNG, JPEG, SVG, and WebP.

The document workflow is as follows:

Form data
    │
    ▼
Calculations and business rules
    │
    ▼
Document preparation
    │
    ▼
  jsPDF
    │
    ▼
Generated PDF document
    │
    ▼
Local download
Enter fullscreen mode Exit fullscreen mode

A minimal jsPDF example illustrates the principle:

const { jsPDF } = window.jspdf;

const doc = new jsPDF();

doc.setFontSize(18);
doc.text("Quote", 20, 20);

doc.setFontSize(12);
doc.text("Development services", 20, 40);
doc.text("Total: EUR 1,200.00", 20, 50);

doc.save("quote.pdf");
Enter fullscreen mode Exit fullscreen mode

This example assumes that the jsPDF library has already been loaded. It illustrates only the local generation mechanism without reproducing the complete implementation of the generator.

Creating a professional quote introduces additional requirements, including text length management, element positioning, pagination when necessary, monetary formatting, and consistency of tax notices.

The PDF library operates at the end of the processing pipeline. It does not determine business rules or calculate taxes.

This separation allows the document presentation to evolve without modifying the tax logic.


8. Privacy by Design

The absence of a processing backend directly changes the application's privacy model.

In a traditional application, quote data may be transmitted to a server for storage, calculations, or PDF conversion.

In this architecture, the data remains within the browser environment during processing.

The generator requires no registration, user account, or authentication system.

It does not store quote data in a database and does not use localStorage to retain the information entered by the user.

User input
    │
    ▼
Browser memory
    │
    ▼
JavaScript processing
    │
    ▼
PDF generation
    │
    ▼
Download
    │
    ▼
Form reset
Enter fullscreen mode Exit fullscreen mode

After the download, the form is automatically reset.

The application therefore does not intentionally maintain a history of quotes, clients, or prices.

However, business data privacy must be distinguished from the general security of a web application.

Loading the page and its resources may require network requests. A client-side architecture does not, by itself, guarantee the absence of all external communications.

The essential property of the generator is that the information entered to create a quote is not transmitted to a processing backend.

This approach reduces the amount of sensitive data that a server must receive, store, and protect.


9. Benefits and Limitations of a Backend-Free Application

A fully client-side architecture is appropriate when operations can be performed locally and remote persistence is not required.

In this context, the application avoids several infrastructure components:

  • An application server responsible for processing quotes
  • A client database
  • User account and session management
  • A remote PDF generation engine
  • Document storage infrastructure

Deployment can rely on static hosting without requiring a PHP, Node.js, or Python runtime on the server.

This infrastructure simplicity does not mean that the business logic is simple. Tax rules, calculations, currencies, and document generation remain components that must be maintained and tested.

The approach also has limitations.

The generator does not provide quote history, centralized accounting numbering, integration with invoicing software, payment processing, or electronic signatures.

It does not automatically determine US Sales Tax rates according to the state, county, or local jurisdiction.

Finally, generating a quote does not constitute automatic legal or tax validation of the transaction.

These features represent different responsibilities and may require a different architecture, particularly when data must be shared between multiple users or persistent state must be maintained.


Conclusion

A web application can incorporate substantial business logic without requiring a processing backend.

Supporting two issuer countries, multiple tax contexts, five currencies, bilingual documents, and local PDF generation illustrates what modern browsers can accomplish with JavaScript.

The value of this architecture lies not only in reducing infrastructure requirements. It also lies in separating business rules, presentation, and document generation while avoiding the collection of data that does not need to be transmitted.

For a tool whose primary responsibility is to produce a document from locally entered data, the browser can provide a sufficient execution environment on its own.


Demo and Technical Documentation

The generator is available directly in the browser, without registration or installation.

Try the quote generator

The GitHub repository presents the project's architecture, features, and design principles. It does not contain downloadable source code or production files.

View the technical documentation on GitHub


https://palks-studio.com

Top comments (0)