CloudPro

Architecture

Author: Will Soltani

1) System Overview

This project combines a Next.js application with AWS managed services to provide secure file conversion and PDF filling.

Browser
  |
  | HTTPS (Next.js routes)
  v
Next.js App Router (UI + API handlers)
  |                \
  |                 \ StartExecution
  |                  v
  |               Step Functions
  |                  |
  |                  v
  |             Convert Worker (Lambda container)
  |
  +--> DynamoDB (project/file metadata)
  +--> S3 Raw Uploads (source objects)
  +--> S3 Outputs (converted + filled artifacts)

2) Frontend Architecture

2.1 App shell and site pages

2.2 Project workspace

Primary orchestrator:

State model (high level):

UI modules:

2.3 PDF fill architecture

Core client:

Support modules:

Pipeline:

  1. Load source bytes via signed URL.
  2. Render pages/widgets with PDF.js (client-only import path).
  3. Maintain editable field + overlay state in React.
  4. Build output bytes with pdf-lib.
  5. Validate bytes (%PDF-, minimum length), then download and persist.

3) Backend API Architecture (Next.js Route Handlers)

3.1 Auth/session boundary

3.2 File APIs

3.3 Conversion submission API

3.4 Filled PDF artifact APIs

4) Conversion Pipeline (Worker)

Worker entrypoint:

Helpers/scripts:

High-level conversion flow:

  1. Read source metadata from DynamoDB.
  2. Download source object from raw bucket.
  3. Detect source kind (content-aware, not filename-only).
  4. Route to conversion path:
    • image -> image/pdf
    • document -> canonical PDF -> target outputs
    • special input handling (SVG sanitization, AVIF/HEIC/ICO paths, PAGES fallback logic)
  5. Upload output to output bucket.
  6. Update output row (status, contentType, size, packaging/page metadata).

4.1 SVG handling

4.2 PAGES handling

5) Capability Matrix and Validation

Single source of truth:

Contains:

Rule: UI can disable options, but backend remains authoritative and rejects unsupported requests.

6) Data and Storage Model

6.1 DynamoDB entity model

Table: SecureDocApp

Primary patterns:

File row fields (selected):

6.2 S3 key model

6.3 Artifact lifecycle

Raw file: queued -> done (upload complete)
Output conversion: processing -> done|failed
Filled PDF: processing -> done|failed
Deleted artifact: explicit user delete only (no implicit cascade)

7) Orchestration and Infrastructure

CDK stack:

Provisions:

Entrypoints:

8) Operational Boundaries and Contracts