How khayaai/a-card works
A-CARD provides scoped virtual cards and prepaid wallets for AI agents, with a human-operated dashboard and merchant directory. The principal flow is an agent request through MCP or another API client, API authorization, policy/rules and approval checks, then a ledger hold and payment rail; outcomes are recorded and exposed as transactions. Core domain logic is separated from API adapters and durable stores. The README documents capabilities beyond the sampled excerpts; those branches are included where documented, while uncertain internal call paths are omitted.
Main entry points: app.ts REST API · platform.ts Platform operations · afp.ts AFP routing and ledger · workers.ts Settlement workers
Components 24
Client surfaces
- MCP tools
apps/mcp/src/server.ts - API client
apps/mcp/src/client.ts - CLI
apps/cli/src/index.ts - Dashboard
apps/dashboard/app/page.tsx - Merchant portal
apps/dashboard/app/merchant/page.tsx
API and controls
- REST API
apps/api/src/app.ts - Platform service stores
apps/api/src/service - PayFast
apps/api/src/payfast.ts
Core domain
- Identity and RBAC
packages/core/src/auth.ts - Platform operations
packages/core/src/platform.ts - Cards and wallets
packages/core/src/cards.ts - Double-entry ledger
packages/core/src/ledger.ts - Rules and approvals
packages/core/src/rules.ts - Enterprise governance
packages/core/src/enterprise.ts - Billing tiers
packages/core/src/billing.ts
Payments and compliance
- KYC KYB AML
apps/api/src/compliance/didit.ts - AFP routing and ledger
packages/core/src/afp.ts - Payment rails
apps/api/src/rails - Settlement workers
apps/api/src/afp/workers.ts
Merchant network
- Merchant directory
packages/core/src/merchants.ts - Merchant stores
apps/api/src/merchant/postgres.ts - Merchant webhooks
apps/api/src/merchant/webhooks.ts
Other components
- AI agent
- Human operator
Connections 27
- AI agent → MCP tools: uses tools
- MCP tools → API client: calls
apps/mcp/src/server.ts - API client → REST API: HTTP requests
apps/mcp/src/client.ts - Human operator → Dashboard: manages
- Dashboard → REST API: uses API
- Human operator → CLI: runs commands
- CLI → REST API: uses API
- Human operator → Merchant portal: manages catalog
- REST API → Platform operations: handles operations
- REST API → Identity and RBAC: guards requests
- REST API → Platform service stores: persists state
apps/api/src/app.ts - Platform service stores → Double-entry ledger: implements ledger
- Platform operations → Cards and wallets: manages lifecycle
- Platform operations → Rules and approvals: checks authorization
- Platform operations → Enterprise governance: enforces policy
- Platform operations → Double-entry ledger: records holds
- REST API → KYC KYB AML: routes screening
apps/api/src/app.ts - REST API → AFP routing and ledger: routes AFP
apps/api/src/app.ts - AFP routing and ledger → Payment rails: selects rail
apps/api/src/rails/types.ts - Settlement workers → Payment rails: confirms outcomes
apps/api/src/afp/workers.ts - Settlement workers → AFP routing and ledger: updates transactions
apps/api/src/afp/workers.ts - REST API → Merchant directory: serves directory
- REST API → Merchant stores: persists merchant data
- REST API → Merchant webhooks: delivers events
apps/api/src/app.ts - Merchant webhooks → Merchant directory: sends signed events
apps/api/src/merchant/webhooks.ts - REST API → PayFast: handles billing
apps/api/src/app.ts - REST API → Billing tiers: enforces tiers