Architecture & Reconciliation Engine
Snapline is an enterprise declarative reconciliation and multi-protocol test automation platform. This document specifies the logical diffing pipeline and physical runtime topology.
Part I: Logical Architecture
The logical architecture decouples multi-protocol execution (REST, GraphQL, SOAP, SQL, Kafka) from the pure, in-memory reconciliation engine. Snapline operates as a 4-stage deterministic pipeline transforming live service outputs and expected fixtures into canonical ASTs for structural diffing.
dataMapping), key lexicographical sorting,
and dynamic regex masking (ignoreFields) to isolate non-deterministic tokens (timestamps, UUIDs).
snapline-engine performs recursive structural diffing, floating-point epsilon matching,
unordered array reconciliation, and produces JSON Patch compliance diffs.
redactFields),
and streams metrics to the centralized Snapline Hub.
Part II: Technical Architecture
The technical architecture specifies the monorepo package encapsulation, zero-runtime-dependency core design, container sandbox boundaries, SSRF security defenses, network port topology, and execution profiles.
1. Monorepo Package Topology & Zero-Dependency Design
Snapline enforces strict modularity across five published npm packages and an internal demo workspace:
-
@vaagatech/snapline-core(Entrypoint): Provides the high-level orchestration API (testSuite,runApiFixtureCases,publishAndPoll). Has zero external runtime dependencies. SQL drivers are never forced on consumers; instead, consumers pass their existing driver instance satisfying theDbConnectionLikeinterface. -
@vaagatech/snapline-engine(Reconciliation Core): A pure algorithm module performing deep object comparison, floating point epsilon checks, and diff generation. Executes completely in-memory with zero disk, zero network, and sub-millisecond execution overhead. -
@vaagatech/snapline-api-adapters(Protocol Clients): Contains hardened HTTP clients with built-in SSRF protection (assertSafeUrl), DNS rebinding shields, and enforced 30-second default request deadlines. -
@vaagatech/snapline-auth-adapters(Authentication Engines): Acquires, validates, and caches OAuth2 client credential tokens, OpenID tokens, and HTTP Basic credentials in memory. -
@vaagatech/snapline-messaging-adapters(Event Broker Adapters): Provides asynchronous queue publish and partition polling for Apache Kafka and low-overhead in-memory event buses.
2. Physical Port Matrix & Firewall Boundaries
| Component / Service | Port | Protocol | Direction | Security Boundary |
|---|---|---|---|---|
snapline-api-adapters (HTTP/REST) |
80 / 443 | HTTP/1.1, HTTP/2 | Outbound | SSRF Guard (assertSafeUrl blocks 169.254.169.254) |
snapline-auth-adapters (OAuth2 / OIDC) |
443 | HTTPS | Outbound | TLS 1.3 + In-Memory Token Isolation |
snapline-messaging-adapters (Kafka) |
9092 / 9094 | TCP / SSL | Outbound | SASL/SCRAM or mTLS Client Authentication |
| SQL Databases (PostgreSQL / MySQL) | 5432 / 3306 | TCP / TLS | Outbound | DbConnectionLike consumer-managed connection pool |
snapline-hub (Web UI / API) |
8080 | HTTP | Inbound / Outbound | Internal Corporate Subnet / API Key Auth |
snapline-hub (Prometheus) |
9090 | HTTP | Inbound | Internal Monitoring Scraper Only |
3. Resource Envelopes & Memory Governor
| Workload Mode | RAM Allocation | CPU Allocation | Execution Guarantees |
|---|---|---|---|
| CLI Local Run | 64 MiB - 128 MiB | Single-threaded Node.js | Sub-second completion; zero residual process leaks. |
| CI/CD Sharded Worker | 512 MiB limit | 1 vCPU | Bounded AST buffers; automated garbage collection. |
| Snapline Hub Service | 256 MiB - 1.0 GiB | 0.5 - 2 vCPU | Paged disk caching for historical reports; SQLite WAL mode. |
4. High Availability & Disaster Recovery Matrix
| Dimension | Target Metric | Implementation Mechanism |
|---|---|---|
| Recovery Point Objective (RPO) | RPO = 0 |
All test fixtures and expected JSON files are committed to Git VCS as immutable source of truth. |
| Recovery Time Objective (RTO) | RTO < 100ms |
Local and CI runners spawn instantaneously with zero external infrastructure cold-starts. |
| Reconciliation Idempotency | 100% Deterministic | Pure functional diffing algorithm guarantees identical outputs for identical AST inputs. |
| Hub Backup / Restore | RPO < 1 hr / RTO < 5m | SQLite / PostgreSQL automated volume snapshots and S3 report archival. |
Package Layers & Responsibilities
| Package | Responsibility | Key exports |
|---|---|---|
@vaagatech/snapline-core |
Orchestration — wires auth, HTTP, DB, fixtures, reports | testSuite, runApiFixtureCases, runDbComparison, runWarehouseComparison, DbConnectionLike, writeTestReport |
@vaagatech/snapline-engine |
Pure reconciliation — zero I/O | snapline, assertAgainstFile |
@vaagatech/snapline-api-adapters |
Protocol executors with SSRF guards and timeouts | executeApi, api.rest, api.graphql, api.soap |
@vaagatech/snapline-auth-adapters |
Token acquisition for API calls | auth.oauth2, auth.openid, auth.basic |
@vaagatech/snapline-messaging-adapters |
Queue publish/consume — Kafka, in-memory, custom | messaging.memory, messaging.kafkaPublisher, publishMessage |
Snapline Hub Integration
Snapline Hub is an optional reporting service that stores and visualizes TestRunReport history. Push reports via pushTestReportToHub() or configure the SNAPLINE_HUB_URL environment variable. The Python edition provides the identical push_test_report_to_hub() integration.
Security & SSRF Protections
- SSRF protection —
assertSafeUrlvalidates target URLs before socket creation, blocking link-local addresses (169.254.169.254), private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), and loopbacks unless explicitly allowlisted. - HTTP timeouts — Strict 30-second default request deadlines on all protocol executors prevent worker deadlocks.
- Path sandboxing — Fixture path resolution restricts file reading strictly within the configured root directory, preventing directory traversal attacks (
../). - Report redaction — The
redactFieldsutility systematically scrubs authentication headers, passwords, and sensitive keys before writing HTML/JSON test run artifacts.