Technical Architecture Summary

Hoike Technologies — VAT API Toolkit (MTDfB VAT, Flat Rate–only)

Scope & HMRC Approval Focus

Hoike Technologies intentionally implements only the two mandatory MTDfB VAT endpoints required for HMRC production credential approval:

The system is Flat Rate–only by design. All other endpoints are deliberately deferred until post-approval.

1) System Overview

The VAT API Toolkit is a Node.js (Express, ESM) web application backed by PostgreSQL (Prisma ORM). It implements a tightly controlled VAT submission pipeline prioritising determinism, auditability, and HMRC compliance.

The platform supports Flat Rate Scheme VAT only, with both automated invoice aggregation and explicit manual turnover entry.

The system is designed with a safety-first submission architecture, enforcing strict environment isolation, deterministic payload generation, and multi-layer validation before any HMRC interaction.

2) Major Components

Web Application (Express)

  • Client-facing routes for obligations → preview → submit.
  • Admin routes for sandbox test-user management and audit tooling.
  • Server-side rendering (EJS) for transparent, reviewable VAT flows.

Data Layer (PostgreSQL + Prisma)

  • Client: VRN, Flat Rate category, percentage, environment flags.
  • Invoice & InvoiceProcessingRun: source data and normalized outputs.
  • VatReturnPreview: authoritative, hash-locked snapshot of a VAT return for a period.
  • VatReturnSubmission: idempotent submission record including HMRC receipts.
  • OAuthCredential (sandbox) and HmrcAuth (production).

HMRC Integration Layer

  • Environment-aware HTTP client (sandbox vs production).
  • Refresh-token–based OAuth lifecycle management.
  • Mandatory fraud-prevention headers enforced in production.
  • Strict separation of sandbox and production OAuth flows.
  • Token storage segregated by environment and identity type.
  • Client connection state tracked via hmrcConnectionStatus.

Background Workers

  • Obligation synchronization worker.
  • VAT payment reconciliation worker.
  • Reminder notification worker.
  • Worker health monitoring with audit tracking.

3) Environment Model

Sandbox and production are strictly isolated at the credential, token, and data level:

Mode Token Store VRN Used Purpose
Sandbox OAuthCredential Sandbox test-user VRN End-to-end functional testing
Production HmrcAuth Live client VRN Real VAT submissions

4) End-to-End VAT Journey

A) Retrieve Obligations

  1. Valid HMRC authorization is verified.
  2. The system retrieves open VAT obligations.
  3. A periodKey is selected for preparation.

B) Preview (Authoritative Snapshot)

  1. Flat Rate category determines data source (AUTO or MANUAL).
  2. For AUTO categories, invoice processing runs are aggregated into gross turnover.
  3. For MANUAL categories, turnover is explicitly entered and confirmed by the user.
  4. A deterministic HMRC payload is generated and written to a VatReturnPreview snapshot.
  5. A payload hash is stored; all subsequent renders use this snapshot.

C) Submit Return

  1. Submission is only allowed from a confirmed preview snapshot.
  2. Payload hash is re-verified immediately before submission.
  3. Idempotent submission records prevent duplicate filings.
  4. HMRC responses and timestamps are persisted for audit.

5) Submission Safety Architecture

VAT submission is governed by a multi-layer safety system designed to prevent accidental, duplicate, or invalid filings.

6) Reliability, Auditability, and Compliance

7) Environment & Deployment Model

Each environment maintains separate configuration, credentials, and database instances to ensure complete isolation and eliminate cross-environment risk.

8) Planned Post-Approval Expansion

After HMRC production approval, Hoike Technologies plans to extend support to additional MTDfB VAT endpoints (liabilities, payments, financial details, penalties) and also MTD for Income Tax, while retaining the same snapshot-based, audit-first architecture.


Document: Technical Architecture Summary • Prepared for HMRC and internal operational review.