LOC Service Documentation

Overview

The LOC Service is a multi-product lending platform built as AWS Lambda functions with a DynamoDB backend. It hosts two distinct products that share common infrastructure (payments, notifications, feature flags, DynamoDB helpers) while keeping product-specific business logic fully isolated.

Product Description

Installment Loan (pkg/installmentloan)

Fixed-term installment loans with biweekly payment schedules, automated collections, ACH/pinless disbursement and repayment, and PDF loan agreement generation.

Credit Line (pkg/creditline)

Revolving line of credit with a draw period, monthly billing cycle (interest accrual, statement generation, minimum payment calculation), and RTP→Pinless→ACH disbursement.

Installment Loan Features

  • Loan Applications — Underwriting, approval/rejection, and loan term generation

  • Loan Disbursements — Sending funds via ACH or pinless debit

  • Installment Scheduling — Biweekly payment schedules with flexible due dates

  • Automated Collections — Scheduled jobs for autopay, notifications, and retries

  • Payment Processing — ACH and pinless debit with webhook handling

  • Loan Agreement Generation — PDF agreements via LaTeX templates

  • Audit Logging — Complete payment and installment change history via DynamoDB streams

Credit Line Features

  • Application & KYC — MLA check, credit limit offer, agreement PDF, TTL expiry handling

  • Draw Period — RTP→Pinless→ACH disbursement, fixed or membership-gated draw period

  • Monthly Billing — Interest accrual, statement generation, minimum payment calculation

  • Collections — Autopay and manual payment notifications with 14-day grace window

  • Repayment Period — Transition triggered by membership downgrade or fixed draw period expiry

Lambda Functions

Installment Loan

Lambda Description Trigger

cmd/api

REST API — loan applications, disbursements, payments, queries

API Gateway

cmd/ach-handler

Processes ACH/pinless payment webhooks (returns, completions, chargebacks)

Kinesis Stream

cmd/loc-collections-job

Queries installments due and enqueues payment events

CloudWatch Events

cmd/loc-collections-worker

Executes payment collection from SQS queue

SQS Queue

cmd/loan-balance-worker

Loan balance reconciliation

SQS Queue

cmd/agreements-generator

Generates PDF loan agreements using LaTeX templates

SQS / Direct Invoke

cmd/log-handler

Creates audit log entries from DynamoDB stream events

DynamoDB Streams

Credit Line

Lambda Description Trigger

cmd/creditline-api

REST API — draw requests, account queries, payment management

API Gateway

cmd/creditline-billing-job

Monthly billing: accrues interest, generates statement, calculates NextMinPaymentDue

CloudWatch Events

cmd/creditline-collections-job

loc_due / loc_overdue / loc_upcoming collection and notification jobs

CloudWatch Events

cmd/creditline-ach-handler

Processes ACH/RTP payment webhooks (returns, chargebacks)

Kinesis Stream

cmd/creditline-draw-period-job

Transitions FIXED draw period lines to repayment when DrawPeriodEnd is reached

CloudWatch Events

Shared

Lambda Description Trigger

cmd/expiration-handler

TTL expiry handler — marks abandoned loan applications (LOAN#) and credit line applications (LOCAPP#)

DynamoDB Streams

Development

For development setup and commands, see the README.md.

make generate.host   # Regenerate code from OpenAPI spec + mocks
make test.host       # Run tests with coverage
make lint.host       # Run all linters
make format.host     # Format code
make build.host      # Build all Lambda binaries