Skip to main content

Architecture Decision Records (ADRs)

AI-First Open-Source FP&A Platform


ADR-001: PostgreSQL as Primary Database

Status: Accepted
Date: 2026-02-03
Decision Makers: Platform Architecture Team

Context

The platform requires a reliable, scalable OLTP database for financial data with strict consistency requirements, multi-tenant isolation, and regulatory compliance capabilities.

Decision

Adopt PostgreSQL 16 as the primary OLTP database.

Rationale

FactorPostgreSQLSQL ServerMySQL
CostOpen source$15K+/coreOpen source
RLS SupportNativeLimitedNone
JSONBNativeJSONJSON
ExtensionsRich ecosystemLimitedLimited
Cloud SupportAll providersAzure-preferredAll providers
ComplianceExcellentExcellentGood

Consequences

Positive:

  • Zero license cost
  • Native Row-Level Security for multi-tenancy
  • Rich extension ecosystem (TimescaleDB, pgvector)
  • Excellent tooling and community

Negative:

  • Team training needed (from SQL Server background)
  • Different optimization patterns

Implementation Notes

  • Use RLS for tenant isolation
  • Enable logical replication for CDC
  • Partition large tables by date
  • Use pgvector for embeddings

ADR-002: TimescaleDB for Time-Series Data

Status: Accepted
Date: 2026-02-03

Context

Financial forecasts, metrics, and audit logs generate large volumes of time-series data requiring efficient storage and querying.

Decision

Deploy TimescaleDB 2.x as PostgreSQL extension for time-series workloads.

Rationale

  • 10-100x compression vs standard PostgreSQL
  • Native PostgreSQL compatibility
  • Continuous aggregates for real-time dashboards
  • Automatic data retention policies

Consequences

Positive:

  • Single database technology (PostgreSQL + extension)
  • Efficient storage for forecast values
  • Built-in downsampling

Negative:

  • Additional operational complexity
  • Learning curve for hypertables

ADR-003: Airbyte for Data Integration

Status: Accepted
Date: 2026-02-03

Context

The platform must integrate with 50+ ERP systems, banking APIs, and other data sources with minimal custom development.

Decision

Adopt Airbyte as the primary ELT platform for data integration.

Rationale

FactorAirbyteMeltanoFivetran
Connectors600+300+400+
CostOpen sourceOpen source$$/connector
Self-hostedYesYesNo
Custom connectorsCDKSDKLimited
Brazilian ERPsCommunityLimitedNone

Consequences

Positive:

  • 600+ pre-built connectors
  • Open-source, self-hosted option
  • Active community developing Brazilian ERP connectors
  • Visual mapping interface

Negative:

  • Operational overhead for self-hosting
  • Some connector quality varies

Implementation Notes

  • Deploy Airbyte on Kubernetes
  • Use CDC mode where available
  • Implement dbt for transformations
  • Build custom connectors for Omie, Conta Azul

ADR-004: Dagster for Pipeline Orchestration

Status: Accepted
Date: 2026-02-03

Context

Financial close processes require reliable, observable workflow orchestration with complex dependencies and compliance requirements.

Decision

Adopt Dagster 1.6+ as the data pipeline orchestration platform.

Rationale

FactorDagsterAirflowPrefect
Asset-centricYesNoPartial
Data lineageNativeLimitedLimited
TestingExcellentBasicGood
ObservabilityBuilt-inExternalBuilt-in
ComplianceAudit logsManualManual

Consequences

Positive:

  • Asset-centric paradigm fits FP&A well
  • Native data lineage for audit
  • Software-defined assets for consistency
  • Built-in testing framework

Negative:

  • Smaller community than Airflow
  • Team retraining required

ADR-005: DeepSeek-R1 for Local LLM

Status: Accepted
Date: 2026-02-03

Context

Regulated financial environments require local LLM deployment to prevent sensitive data from leaving the infrastructure while maintaining reasoning capabilities.

Decision

Deploy DeepSeek-R1-Distill-Qwen-32B as the primary local LLM for financial reasoning.

Rationale

FactorDeepSeek-R1-32BLlama 3.1-70BGPT-4 API
ReasoningExcellentGoodExcellent
Local DeployYes (2x A100)Yes (4x A100)No
Cost/month$8K (hardware)$15K (hardware)$20K+ (API)
Data PrivacyFull controlFull controlThird-party
ComplianceSOC2/HIPAA readySOC2/HIPAA readyDepends

Consequences

Positive:

  • Full data sovereignty
  • Predictable costs
  • No API rate limits
  • Compliance friendly

Negative:

  • GPU infrastructure required
  • Model updates require redeployment
  • Smaller context than GPT-4

Implementation Notes

  • Deploy via vLLM with tensor parallelism
  • Use INT8 quantization for efficiency
  • Implement prompt caching
  • Monitor GPU utilization

ADR-006: LangGraph for Agent Workflows

Status: Accepted
Date: 2026-02-03

Context

AI agents for FP&A (reconciliation, variance analysis, forecasting) require stateful, controllable workflows with human-in-the-loop capabilities and compliance checkpoints.

Decision

Adopt LangGraph 0.1+ as the agent workflow framework.

Rationale

FactorLangGraphCrewAIAutoGPT
DeterminismHighMediumLow
State ManagementPostgreSQL nativeIn-memoryExternal
ComplianceCheckpoints built-inManualNone
Control FlowExplicit graphsImplicitAutonomous
Human-in-loopNativeLimitedLimited

Consequences

Positive:

  • Deterministic, auditable workflows
  • PostgreSQL-based state persistence
  • Native checkpoint/resume
  • Explicit compliance gates

Negative:

  • More code than declarative frameworks
  • Learning curve for graph-based thinking

Implementation Notes

# Core pattern for FP&A agents
workflow = StateGraph(AgentState)
workflow.add_node("compliance_check", compliance_gate)
workflow.add_conditional_edges("action", should_escalate, {...})

ADR-007: OpenFGA for Authorization

Status: Accepted
Date: 2026-02-03

Context

Multi-tenant FP&A platform requires fine-grained authorization with relationship-based access control, segregation of duties, and audit capabilities.

Decision

Adopt OpenFGA as the authorization engine following the Zanzibar model.

Rationale

FactorOpenFGACerbosCustom RBAC
ModelReBAC (Zanzibar)Policy-basedRole-based
PerformanceSub-msSub-msVaries
Segregation of DutiesNativeManualManual
Audit TrailBuilt-inLimitedManual
ComplexityMediumMediumHigh

Consequences

Positive:

  • Relationship-based authorization
  • Native segregation of duties (approver ≠ creator)
  • Sub-millisecond check latency
  • Audit-ready

Negative:

  • New paradigm for team
  • Requires careful model design

Authorization Model Summary

organization → tenant → account/journal_entry/budget
user → can_view/can_edit/can_approve
Segregation: can_approve = admin AND NOT author

ADR-008: immudb for Audit Trails

Status: Accepted
Date: 2026-02-03

Context

Financial platforms require tamper-evident audit trails for SOX, SOC 2, and FDA 21 CFR Part 11 compliance with cryptographic verification capabilities.

Decision

Adopt immudb as the immutable audit log database alongside PostgreSQL.

Rationale

FactorimmudbPostgreSQLBlockchain
ImmutabilityCryptographicLogical (can bypass)Cryptographic
VerificationMerkle proofsNoneNative
Performance100K+ ops/secExcellentPoor
ComplexityLowN/AVery High
ComplianceSOX/SOC2 readyNeeds controlsOverkill

Consequences

Positive:

  • Cryptographic tamper evidence
  • Built-in verification APIs
  • High performance
  • SQL-like query interface

Negative:

  • Additional database to operate
  • Synchronization complexity

Implementation Notes

  • Write all state changes to immudb
  • Store verification hashes in PostgreSQL
  • Implement periodic verification jobs
  • Generate compliance reports from immudb

ADR-009: NeuralProphet for Forecasting

Status: Accepted
Date: 2026-02-03

Context

Cash flow and financial forecasting requires accurate, explainable predictions that can incorporate business drivers and seasonal patterns.

Decision

Adopt NeuralProphet 0.8+ as the primary forecasting engine with ensemble fallbacks.

Rationale

FactorNeuralProphetProphetARIMAXGBoost
AccuracyHighestGoodMediumHigh
ExplainabilityHighHighLowLow
SeasonalityAuto-detectManualManualManual
RegressorsNativeNativeExternalNative
GPU AccelerationYesNoNoYes

Consequences

Positive:

  • 55-92% accuracy improvement over Prophet
  • Interpretable components
  • GPU-accelerated training
  • Native trend changepoint detection

Negative:

  • More complex than Prophet
  • Longer training times

Implementation Notes

  • Use ensemble with XGBoost fallback
  • Implement automatic model selection
  • Track accuracy metrics per account type
  • Retrain weekly with latest data

ADR-010: Multi-Tenant RLS Strategy

Status: Accepted
Date: 2026-02-03

Context

Platform serves multiple tenants with strict data isolation requirements. Must prevent cross-tenant data leaks while maintaining query performance.

Decision

Implement Row-Level Security (RLS) at the database level with application-level tenant context.

Rationale

  • Defense in depth (even SQL injection can't access other tenants)
  • Transparent to application code
  • Single database, lower operational cost
  • Supported natively by PostgreSQL

Implementation Pattern

-- Enable RLS
ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;

-- Create policy
CREATE POLICY tenant_isolation ON accounts
USING (tenant_id = current_setting('app.current_tenant')::UUID);

-- Set context at connection
SET app.current_tenant = '550e8400-...';

Consequences

Positive:

  • Database-enforced isolation
  • Cannot bypass via application bugs
  • Works with all PostgreSQL tools

Negative:

  • Slight performance overhead (~5%)
  • Must manage connection-level context
  • Backup/restore requires care

ADR-011: Event-Driven Architecture

Status: Accepted
Date: 2026-02-03

Context

Loose coupling between services, audit trail generation, and real-time updates require an event-driven communication pattern.

Decision

Adopt Apache Kafka as the event backbone with event sourcing for critical domains.

Rationale

  • Guaranteed delivery for financial events
  • Natural audit trail from event log
  • Enables real-time dashboards
  • Decouples services effectively

Event Categories

CategoryExamplesRetention
Domain Eventsjournal_entry.posted1 year
Integration Eventssync.completed30 days
Audit Eventsuser.login7 years
Analytics Eventsreport.viewed90 days

Consequences

Positive:

  • Loose coupling
  • Natural audit trail
  • Enable CQRS pattern

Negative:

  • Eventual consistency
  • Operational complexity

ADR-012: API-First Design

Status: Accepted
Date: 2026-02-03

Context

Platform must support multiple clients (web, mobile, API) and enable third-party integrations.

Decision

Adopt API-first design with OpenAPI 3.1 specification as the contract.

Standards

  • REST for CRUD operations
  • WebSocket for real-time updates
  • GraphQL considered but rejected (complexity)
  • gRPC for internal service communication

Versioning Strategy

  • URL versioning: /v1/, /v2/
  • No breaking changes within version
  • 12-month deprecation notice
  • Sunset header for deprecated endpoints

ADR-013: Encryption Strategy

Status: Accepted
Date: 2026-02-03

Context

Financial data requires encryption at rest and in transit with proper key management.

Decision

Implement comprehensive encryption:

  • TLS 1.3 for all network traffic
  • AES-256 for data at rest
  • AWS KMS / HashiCorp Vault for key management
  • Field-level encryption for PII

Implementation

LayerMethodKey Management
NetworkTLS 1.3Certificate Manager
DatabaseTDE (Transparent)KMS
BackupsAES-256-GCMKMS
PII FieldsApplication-levelVault

ADR-014: Observability Strategy

Status: Accepted
Date: 2026-02-03

Context

Production systems require comprehensive observability for debugging, performance optimization, and compliance monitoring.

Decision

Adopt OpenTelemetry as the standard with the following stack:

  • Tracing: Jaeger / Tempo
  • Metrics: Prometheus + Grafana
  • Logging: Loki / ELK
  • Alerting: PagerDuty integration

Key Metrics

CategoryMetrics
Businessclose_days, reconciliation_rate, forecast_accuracy
Performancelatency_p95, throughput, error_rate
Infrastructurecpu, memory, disk, network
AIllm_latency, token_usage, accuracy

ADR-015: Compliance Framework

Status: Accepted
Date: 2026-02-03

Context

Platform serves regulated industries requiring SOX, SOC 2, HIPAA, and FDA 21 CFR Part 11 compliance.

Decision

Implement compliance as a first-class architectural concern with:

  • Automated evidence collection
  • Policy-as-code for controls
  • Continuous compliance monitoring
  • Audit-ready documentation

Framework Mapping

ControlSOXSOC 2FDA 21 CFR Part 11
Audit Trail302/404CC6.111.10(e)
Access Control302CC6.1-6.311.10(d)
Data Integrity404CC1.111.10(a)
Electronic SignaturesN/AN/A11.50-11.200
Change Management404CC8.111.10(k)

Implementation

  • OpenFGA for access control
  • immudb for audit trails
  • Git-based change management
  • Automated compliance reports

Summary Table

ADRDecisionStatus
ADR-001PostgreSQL 16 for OLTPAccepted
ADR-002TimescaleDB for time-seriesAccepted
ADR-003Airbyte for ELTAccepted
ADR-004Dagster for orchestrationAccepted
ADR-005DeepSeek-R1 for local LLMAccepted
ADR-006LangGraph for agentsAccepted
ADR-007OpenFGA for authorizationAccepted
ADR-008immudb for audit trailsAccepted
ADR-009NeuralProphet for forecastingAccepted
ADR-010Multi-tenant RLSAccepted
ADR-011Event-driven architectureAccepted
ADR-012API-first designAccepted
ADR-013Encryption strategyAccepted
ADR-014Observability with OpenTelemetryAccepted
ADR-015Compliance frameworkAccepted