An enterprise-grade accounts receivable automation platform that replaces manual collection workflows with intelligent, automated multi-channel follow-up generation. It orchestrates communication cycles from initial reminders to payment reconciliation.
The platform is structured as a decoupled, multi-service system comprising three core components:
- Frontend Dashboard: A responsive web portal built with React, TypeScript, and Vite.
- Backend Engine: A central API service built with Express, TypeScript, and Drizzle ORM, backed by a PostgreSQL database.
- AI-ML Service: A high-performance Python FastAPI service dedicated to agent execution, risk analysis, and generative AI features.
graph TD
A[React Frontend] <-->|REST API / Auth| B[Express Backend API]
B <-->|Drizzle ORM| C[(PostgreSQL Database)]
B <-->|Session / Caching| D[(Redis Cache)]
B <-->|Service Auth| E[FastAPI AI-ML Service]
B -->|Email Dispatch| G[SendGrid / SMTP]
B <-->|Webhooks / Payments| H[Razorpay Payment Gateway]
E <-->|Inference| F[Groq LLaMA 3.1 8B LLM]
- Authentication: JWT-based session security with bcryptjs password hashing and route protection.
- Tenant Isolation: Complete database and route-level namespace isolation for multiple organizations.
- Invoice & Collections Management: Automated workflows for tracking payment statuses (Pending, Paid, Overdue, Written Off).
- Communication Engine: Scheduled follow-ups using a timezone-aware scheduling system with support for SendGrid or custom SMTP credentials.
- Payment Gateway Integration: Custom adapters for Razorpay supporting dynamic payment link generation and automated webhooks validation.
- Dead Letter Queue (DLQ): Isolates failed communications and halts retry loops on high-consecutive failures.
- Idempotency Guard: Guarantees that only one collection message is dispatched within a 20-hour window per invoice. 1
- Dashboard: High-level collection summaries, aging pyramids, and analytics charts using Recharts.
- Invoice Portal: Invoices view, importing from CSV, tracking communication logs, and sending manual overrides.
- Agent Controls: Visibility into active agent execution runs, success metrics, and DLQ reviews.
- Team Management: User role configurations (Admin, Manager, Viewer) and invitations handling.
- System Settings: Configurable email templates, tenant parameters, and payment integration setups.
- FastAPI Endpoint Routing: Dedicated endpoints for
/health,/generation,/risk, and/agents. - Structured LLM Generation: Prompts tailored to a 5-Stage Tone Escalation Matrix (Warm, Firm, Serious, Stern, Legal Stop).
- Output Validation: Structure validators ensure subjects and payment links are formatted correctly.
- Security & Redaction: Prompt injection filtering and automated PII masking on outbound payloads.
- Risk Assessment: Score-based models evaluating likelihood of default to dynamically adjust communication parameters.
The collection logic follows an incremental escalation matrix designed to maximize cash flow while retaining commercial relationships:
- Stage 1 (Warm Reminder): Sent 1-7 days past due. Informative and helpful tone.
- Stage 2 (Firm Follow-up): Sent 8-14 days past due. Direct request for payment confirmation.
- Stage 3 (Serious Notice): Sent 15-21 days past due. Mentions potential access constraints or terms breach.
- Stage 4 (Stern Warning): Sent 22-30 days past due. Explicit payment deadlines.
- Stage 5 (Legal Stop): Halts the automated pipeline. Requires manual human override and legal review.
.
├── backend/ # Express + TypeScript + Drizzle ORM API
│ ├── src/
│ │ ├── db/ # PostgreSQL schema & database client
│ │ ├── middleware/ # Auth, rate-limiter, error handling
│ │ └── modules/ # Domain services (auth, agent, invoices)
│ └── migrations/ # Drizzle SQL migration output files
├── frontend/ # React + TypeScript SPA Dashboard
│ ├── src/
│ │ ├── pages/ # View pages (Dashboard, Invoices, DLQ)
│ │ └── components/ # Shared UI components
├── ai-ml/ # Python FastAPI service & agent scripts
│ ├── api/ # FastAPI router endpoints & middlewares
│ └── src/ # Agent core, safety filters, prompt registry
└── implementation_plan/ # System vision documents & phase plans