Infrastructure medium complexity backend
0
Dependencies
1
Dependents
1
Entities
1
Integrations

Description

Client-side interface for the Supabase Edge Function that runs server-side auto-approval logic on expense insert. The Edge Function evaluates distance and expense claim presence against configurable thresholds, sets approval status automatically for qualifying records, and routes others to the manual attestation queue.

Feature: Travel & Expense Registration

auto-approval-edge-function-client

Summaries

The Auto-Approval Edge Function Client eliminates manual bottlenecks in expense processing by automatically approving qualifying claims the moment they are submitted. By evaluating distance thresholds and claim completeness in real time at the server edge, the organization dramatically reduces administrative overhead and accelerates reimbursement cycles for drivers and volunteers. Faster approvals improve staff satisfaction, reduce follow-up workload for finance teams, and lower the operational cost per expense claim. Only non-qualifying submissions are routed to human review, meaning staff attention is reserved for genuinely complex cases rather than routine approvals, delivering measurable efficiency gains and a superior submitter experience.

This component is a medium-complexity backend service that wraps Supabase Edge Function invocation logic and must be delivered before any end-to-end expense submission testing can be completed. It has no declared upstream dependencies, but its correctness is tightly coupled to the Edge Function deployment and threshold configuration data, both of which must be finalized before integration testing begins. Key delivery risks include Edge Function cold-start latency affecting perceived submission speed and error-handling coverage for fallback-to-pending scenarios. QA must validate auto-approval path, rejection routing, invocation failure graceful degradation, and threshold injection across multiple organization configurations.

Plan for at least one additional sprint cycle if Edge Function behaviour changes during testing.

The Auto-Approval Edge Function Client is a backend service component that acts as the bridge between the expense submission flow and the Supabase Edge Function responsible for server-side approval logic. It exposes `invokeAutoApproval(expenseId)` and `getApprovalResult(expenseId)` as primary integration points consumed by the submission service, plus `onAutoApprovalComplete(callback)` for async result propagation and `getThresholdConfig(organizationId)` to inject per-org configuration into the Edge Function payload. Error handling must implement graceful fallback: any invocation failure should set approval status to pending rather than blocking the transaction. Since this runs in a backend execution context, care must be taken around idempotency — duplicate Edge Function calls on retry should not double-trigger side effects.

The component owns no persistent state itself; results are relayed to the submission service which writes final status to the expense data model.

Responsibilities

  • Invoke or observe the Supabase Edge Function triggered on expense insert
  • Receive auto-approval outcome and relay to submission service
  • Handle Edge Function invocation errors with graceful fallback to pending state
  • Provide threshold configuration injection for the Edge Function

Interfaces

invokeAutoApproval(expenseId)
getApprovalResult(expenseId)
onAutoApprovalComplete(callback)
getThresholdConfig(organizationId)

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

Used Integrations (1)

External integrations and APIs this component relies on

API Contract

View full contract →
REST /api/v1/auto-approvals 6 endpoints
GET /api/v1/auto-approvals List auto-approval results for an organization
GET /api/v1/auto-approvals/:id Get auto-approval result for an expense
POST /api/v1/auto-approvals Invoke auto-approval edge function for an expense
PUT /api/v1/auto-approvals/:id Update auto-approval record (callback from edge function)
DELETE /api/v1/auto-approvals/:id Cancel a pending auto-approval (admin override)
GET /api/v1/auto-approvals/threshold-config/:organizationId Get auto-approval threshold configuration for organization