A comprehensive backend API for trust automation, enforcement actions, and beneficiary management.
- 🔐 Full CRUD APIs - Beneficiaries and credit disputes with validation
- 📊 Supabase Integration - PostgreSQL database with migrations
- 🔗 Webhook Hub - Stripe, Make.com, SendGrid, Postmark integrations
- 🤖 OpenAI Agent-Ready - Tool definitions for AI agent integration
- 📝 Audit Logging - Complete request/response logging with trace IDs
- ⚡ Production-Ready - Error handling, pagination, filtering, sorting
- Node.js 18+
- npm or yarn
- Supabase account (for database)
- Clone this repo
git clone https://github.com/ihoward40/ike-bot.git
cd ike-bot- Install dependencies
npm install- Create
.envfile
PORT=3000
NODE_ENV=development
LOG_LEVEL=info
# Supabase
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
# Stripe (for webhooks)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...- Run database migrations
npm run db:init
npm run db:seed- Start development server
npm run dev- Build for production
npm run build
npm startGET /api/beneficiariesQuery parameters:
page(number): Page number (default: 1)limit(number): Results per page (default: 10, max: 100)sortBy(string): Field to sort by (default: created_at)sortOrder(string): asc or desc (default: desc)search(string): Search by name or email
Example response:
{
"data": [
{
"id": "uuid",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "555-0100",
"relationship": "Primary",
"created_at": "2024-01-01T00:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 50,
"totalPages": 5
}
}GET /api/beneficiaries/:idPOST /api/beneficiaries
Content-Type: application/json
{
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "555-0100",
"relationship": "Primary"
}PUT /api/beneficiaries/:id
Content-Type: application/json
{
"phone": "555-0200"
}DELETE /api/beneficiaries/:idGET /api/credit-disputesQuery parameters:
page(number): Page numberlimit(number): Results per pagesortBy(string): Field to sort bysortOrder(string): asc or descstatus(string): Filter by status (pending, submitted, investigating, resolved, rejected)beneficiary_id(string): Filter by beneficiary UUID
GET /api/credit-disputes/:idPOST /api/credit-disputes
Content-Type: application/json
{
"beneficiary_id": "uuid",
"creditor_name": "Example Credit Corp",
"dispute_reason": "This account does not belong to me",
"dispute_type": "not_mine"
}Dispute types: identity_theft, not_mine, inaccurate, duplicate, paid, other
PUT /api/credit-disputes/:id
Content-Type: application/json
{
"status": "resolved",
"resolution_notes": "Successfully removed from credit report"
}DELETE /api/credit-disputes/:idAll webhook endpoints accept POST requests.
POST /webhooks/stripeHandles Stripe events with signature verification. Supported events:
payment_intent.succeededpayment_intent.payment_failedcharge.succeededcharge.failedinvoice.payment_succeededinvoice.payment_failed
POST /webhooks/makeReceives automation triggers from Make.com scenarios.
Example payload:
{
"action": "create_beneficiary",
"data": {
"first_name": "Jane",
"last_name": "Smith",
"email": "jane@example.com"
}
}Supported actions: create_beneficiary, create_dispute, create_enforcement_packet, billing_alert
POST /webhooks/sendgridProcesses SendGrid email events (delivered, bounced, opened, clicked).
POST /webhooks/postmarkProcesses Postmark email events.
POST /webhooks/inbound-emailHandles inbound emails from SendGrid or Postmark.
POST /webhooks/billing-alertGeneric billing alert endpoint.
Example payload:
{
"source": "payment-gateway",
"alert_type": "payment_overdue",
"beneficiary_id": "uuid",
"amount": 150.00,
"currency": "USD",
"status": "pending",
"severity": "warn",
"message": "Payment is 30 days overdue"
}Tool definitions are available in /agent-tools/ directory. Use the utility functions to load them:
import { loadAllTools, getOpenAITools, getToolByName } from './src/utils/tools';
// Get all tools formatted for OpenAI API
const tools = getOpenAITools();
// Get specific tool
const createBeneficiaryTool = getToolByName('create_beneficiary');Available tools:
list_beneficiaries- List all beneficiaries with filteringcreate_beneficiary- Create a new beneficiarylist_credit_disputes- List credit disputescreate_credit_dispute- Create a new credit disputerun_enforcement_packet- Create enforcement packet (future implementation)
Migrations are stored in supabase/migrations/.
Run migrations:
npm run db:init # Initialize schema
npm run db:seed # Seed test data
npm run db:migrate # Run all migrations
npm run db:reset # Reset database (caution!)See supabase/README.md for detailed migration documentation.
beneficiaries- Trust beneficiariescredit_disputes- Credit dispute trackingbilling_events- Payment and billing eventsenforcement_packets- Enforcement actions (UCC liens, FOIA, etc.)agent_logs- Audit trail and request logs
Every API request is logged with:
- Trace ID - Unique identifier for each request
- Correlation ID - Groups related requests
- Request/Response logging - Method, path, status, duration
- Error logging - Full stack traces
- Database persistence - All logs saved to
agent_logstable
Access trace IDs via response headers:
X-Trace-Id: uuid
X-Correlation-Id: uuid
ike-bot/
├── src/
│ ├── config/ # Configuration (Supabase, logger)
│ ├── controllers/ # Request handlers
│ ├── services/ # Business logic
│ ├── models/ # Zod schemas & types
│ ├── middleware/ # Express middleware
│ ├── routes/ # API routes
│ ├── webhooks/ # Webhook handlers
│ ├── utils/ # Utility functions
│ └── queue/ # Job queue (future)
├── agent-tools/ # OpenAI agent tool definitions
├── supabase/ # Database migrations
└── dist/ # Compiled output
npm run dev- Start development server with hot reloadnpm run build- Compile TypeScript to JavaScriptnpm start- Run production servernpm run db:init- Initialize database schemanpm run db:seed- Seed test datanpm run db:migrate- Run migrationsnpm run db:reset- Reset database
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- Database: PostgreSQL (via Supabase)
- Validation: Zod
- Logging: Pino
- Payments: Stripe
- ORM: Supabase Client
- Input validation with Zod schemas
- Stripe webhook signature verification
- Structured error handling
- SQL injection protection via Supabase client
- CORS enabled
- Request logging and audit trails
- Job queue for background processing (Bull/BullMQ)
- Authentication & authorization (JWT)
- Rate limiting
- API documentation with Swagger/OpenAPI
- Enforcement packet generation
- Document management
- Email notifications
- Unit and integration tests
MIT
For issues or questions, please open an issue on GitHub.