Case Study

Engineering a Document Lifecycle & Service Billing Platform

Building an operational platform that tracks government document lifecycles, automates renewal reminders, and manages service billing through a structured quote-to-invoice workflow.

Document Lifecycle Tracking
Quote → Invoice Billing Workflow
Secure Document Storage
Overview

Engineering a centralized operational engine to bridge government service compliance with structured financial workflows.

The Business Context

A Dubai-based operational services firm serving as the critical intermediary for passport renewals, driving licenses, and corporate documentation.

Project Objectives

Document Lifecycle

End-to-end tracking of gov-issued assets with multi-stage status management.

Financial Workflows

Dynamic creation of quotes and invoices linked directly to service fulfillment.

Expiry Monitoring

Automated alert system for critical document deadlines and renewal windows.

Operational BI

Unified dashboards providing visibility into document health and revenue.

The Operational Unified Platform

The resulting system transformed fragmented manual tasks into a unified operational dashboard, combining deep document management with integrated financial reporting.

Problem

Before this platform, operational workflows were paralyzed by manual processes and disconnected data silos.

The Manual Bottleneck

Documents were stored in unstructured folders, expiry dates were monitored via spreadsheets, and invoices were manually drafted—creating a high risk of operational failure.

Critical Operational Risks

Missed Deadlines

Late renewals leading to government fines and service interruptions.

Billing Leakage

Inconsistent invoice generation and tracking causing revenue loss.

Zero Visibility

Lack of centralized tracking for real-time document status across the firm.

Coordination Gaps

Manual handovers between staff members creating data silos and errors.

The Strategic Need

The company required an immediate pivot toward a unified system that could automate expiry intelligence and enforce strict financial governance.

Requirements

Engineering the core operational capabilities to handle multi-tenant document workflows and financial governance.

Document Lifecycle Management

Documents can be stored for both customers and employees. Each document contains metadata such as document type, owner, expiry date, and an attached file.

The platform continuously monitors document expiry timelines to ensure renewal processes begin before deadlines.

Sources
Customers & Staff
Document Record
TypeOwnerExpiryFile
Monitoring Active
Expiry Intelligence Engine
POLLING...

Calculates renewal windows and triggers proactive notifications to relevant stakeholders.

Notification System

Users must receive reminders when documents are approaching expiration. Notifications are delivered through both the platform dashboard and email alerts.

Escalation Windows

10 DaysWarning
5 DaysUrgent
1 DayCritical

Customer & Employee Hierarchy

The system supports complex organizational structures where customers can exist as either individuals or organizations with multiple nested employees.

Multi-Entity Architecture

This required separating the data model into distinct but linked entities, allowing for granular document control at both the corporate and individual staff level.

Quote & Invoice Workflow

A structured financial lifecycle beginning with service quotes and progressing through approvals into automated invoices and payment tracking.

Quote
Approval
Invoice

Reporting & Intelligence

Operational reporting provides real-time insights into document health, revenue tracking, and employee performance metrics.

Excel Export Engine Integrated
System

The platform follows a modular backend architecture where different operational domains are implemented as logical modules.

Core Modules

document management
customer management
employee management
invoicing
notifications
reporting

The frontend communicates with the backend through REST APIs. The backend is responsible for business logic, validation, authorization, document processing, and report generation.

                ┌──────────────────────────┐
                │        Frontend           │
                │   Next.js + Tailwind     │
                │   Hosted on AWS Amplify  │
                └─────────────┬────────────┘
                              │
                              │ REST API
                              │
                ┌─────────────▼────────────┐
                │       API Server          │
                │   NestJS + Fastify       │
                │   Hosted on AWS EC2      │
                └─────────────┬────────────┘
                              │
            ┌─────────────────┼─────────────────┐
            │                 │                 │
            ▼                 ▼                 ▼
     ┌─────────────┐   ┌─────────────┐   ┌─────────────┐
     │ PostgreSQL  │   │  AWS S3     │   │  Cron Jobs  │
     │ AWS RDS     │   │ Document    │   │ Expiry      │
     │             │   │ Storage     │   │ Notifications│
     └─────────────┘   └─────────────┘   └─────────────┘

System architecture separating application logic, storage, and infrastructure services.

Cloud Infrastructure

AWS Amplify
AWS EC2
AWS RDS
AWS S3
Route 53
PostgreSQL
Data

The platform is built around a set of core business entities that represent the operational workflow.

Key Entities

CompanyUserCustomerEmployeeDocumentQuoteInvoiceInvoiceLineItemServiceExpenseNotification

Key Relationships

  • Company → Users
  • Company → Customers
  • Customer → Employees
  • Customer/Employee → Documents
  • Quote → Invoice
  • Invoice → LineItems
  • Invoice → Expenses
           Company
              │
      ┌───────┼────────┐
      │       │        │
    Users  Customers  Documents
                │
            Employees
                │
               Files (S3)

 Quotes ─────► Invoices
                │
        ┌───────┼────────┐
        │                │
   Invoice Items     Expenses

 Notifications

Core data model supporting organizations, document tracking, and financial workflows.

This structure allows the system to support both individual customers and organizational customers with multiple employees.

Billing

A structured billing lifecycle was implemented to ensure service transactions follow a clear progression from proposal to payment.

        Quote Created
              │
              ▼
        Quote Sent
              │
              ▼
      Customer Approval
              │
              ▼
       Invoice Generated
              │
              ▼
         Invoice Sent
              │
              ▼
        Payment Received

Structured billing lifecycle ensuring invoices follow a controlled financial workflow.

Invoice State Transitions

Draft → Sent → Paid
        │
        ├─ Rejected
        └─ Cancelled

Invoices can contain service line items and optional internal expenses, allowing the platform to capture the full cost of service delivery.

Documents

Customer and employee documents are stored using AWS S3 with strict access controls to protect sensitive personal information.

Two storage categories were implemented to balance delivery performance with maximum security requirements.

Public Assets

Non-sensitive data such as company logos and UI assets are stored in a public bucket for high-performance delivery.

Sensitive Records

Identity documents and contracts are accessed exclusively through short-lived cryptographic pre-signed URLs.

5-Minute Expiration

Signed URLs expire quickly to prevent unauthorized access from exposed links.

PDFs

Invoices are generated dynamically on-demand, ensuring customers always receive the most up-to-date financial record.

Instead of storing generated PDFs in object storage, the system generates invoices dynamically using the latest invoice data stored in the database.

Engine

jsPDF Library

Strategy

On-Demand Rendering

Zero Storage Overhead

Eliminating the need to store static PDF files in S3, significantly reducing storage costs over time.

Real-Time Accuracy

Generated invoices always reflect the latest line items, discounts, or state changes from the database.

Notifications

A lightweight scheduled task system ensures users are proactively alerted before any document expiration.

To notify users about expiring documents, a lightweight scheduled task system was implemented directly in the backend server, maintaining a balance between reliability and infrastructure simplicity.

Cron Schedule

00:00

Daily Run

12:00

Daily Run

Delivery Channels

In-app platform dashboard alerts
Automated email notifications

During each scheduled run, the system queries the database for documents approaching expiry and generates unified notification records for simultaneous multi-channel delivery.

Infra

The system is deployed on AWS infrastructure with a clear separation between compute, storage, and database services.

Technology Stack

FrontendNext.js + Tailwind + Motion
BackendNestJS + Fastify
DatabasePostgreSQL (AWS RDS)
ComputeAWS EC2
File StorageAWS S3
DNSRoute 53
Frontend HostingAWS Amplify

Backend Protections

Additional security layers include adaptive API rate limiting and strict request payload size restrictions to protect the infrastructure from misuse and ensure high availability.

Engineering

Several challenges emerged during development due to evolving product requirements and infrastructure constraints.

Infrastructure Evolution

The project initially began on Azure infrastructure but was later migrated to AWS due to operational issues. This migration required reconfiguring database infrastructure, file storage, and deployment environments.

Email Delivery Strategy

The system initially used AWS SES, but approval delays required switching to Zoho Mail SMTP during development to maintain delivery timelines.

Beyond technical implementation, the engineering process also involved helping the client shape the product itself. Key workflows such as the quote‑to‑invoice lifecycle and the separation of customers and employees were introduced during development to better reflect real operational processes.

This highlights how early stage SaaS platforms often evolve through engineering‑led product design rather than predefined specifications.