agentleFS
fracabufracabu/Agent-PayMind/CLAUDE.md

Agent-PayMind

CLAUDE.md2 starsChanged 14 months agoMITView on GitHub

PayMind is an AI-powered payment reminder system with two interfaces: 1. CLI Agents - Three specialized Claude Code agents for invoice analysis, message generation, and response handling 2. Next.js Dashboard - Web interface for visualizing workflows and managing invoices with real AI integration Next.js 16.0.10 application with App Router: - State: Zustand store with localStorage persistence (src/lib/store.ts) - Database: Prisma with SQLite (prisma/schema.prisma) - AI Integration: Multi-provider abstraction via callAI() (src/lib/ai-providers.ts) - API Routes: REST endpoints at src/app/api/ - Theme:…

  • Reads credentials
  • Installs packages

The file

Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

PayMind is an AI-powered payment reminder system with two interfaces:

  1. CLI Agents - Three specialized Claude Code agents for invoice analysis, message generation, and response handling
  2. Next.js Dashboard - Web interface for visualizing workflows and managing invoices with real AI integration

Architecture

Agent Workflow

CSV Upload → [Payment Monitor] → Analysis Report
                    ↓
            [Reminder Generator] → Email/SMS/WhatsApp messages
                    ↓
            [Response Handler] → Intent analysis + Suggested actions

CLI Agents (.claude/agents/)

AgentPurposeOutput
payment-monitor-agentAnalyzes CSV, identifies overdue invoices, calculates priorityReport with metrics and segmentation
reminder-generator-agentGenerates personalized messages for Email/SMS/WhatsAppChannel-appropriate reminder messages
response-handler-agentAnalyzes customer responses, identifies intentActions + draft response

Dashboard (dashboard/)

Next.js 16.0.10 application with App Router:

  • State: Zustand store with localStorage persistence (src/lib/store.ts)
  • Database: Prisma with SQLite (prisma/schema.prisma)
  • AI Integration: Multi-provider abstraction via callAI() (src/lib/ai-providers.ts)
  • API Routes: REST endpoints at src/app/api/
  • Theme: Dark/light mode toggle persisted in Zustand (uses .dark class on <html>)
  • i18n: Italian/English UI toggle (language stored in Zustand)
  • Styling: Tailwind CSS v4 with @custom-variant dark (&:is(.dark *)) for manual dark mode
  • Responsive: Mobile-first with custom xs breakpoint (480px) in globals.css

Data Flow

  1. Frontend → Zustand store manages UI state (agents, invoices, workflow steps, logs, theme, language)
  2. API Routes → Fetch invoices from Prisma DB, call AI provider, return analysis
  3. AI Providers → Unified interface supporting Anthropic, OpenAI, OpenRouter, Gemini

Zustand Persistence

The store persists to localStorage (paymind-storage): invoices, analysisResult, generatedMessages, responseAnalysis, aiSettings, theme, language, and visibility flags.

Commands

# Dashboard development
cd dashboard
npm install
npm run dev          # Start dev server at localhost:3000
npm run build        # Production build
npm run lint         # ESLint
npx tsc --noEmit     # Type checking (no tests defined)

# Database setup
npx prisma db push   # Apply schema to SQLite
npx prisma studio    # Database GUI

# CLI agent invocation
claude "payment-monitor-agent: analizza invoices.csv"
claude "reminder-generator-agent: genera email per FAT-2025-001"
claude "response-handler-agent: analizza questa risposta: [text]"

Environment Variables

Create dashboard/.env:

DATABASE_URL="file:./dev.db"
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...           # Optional
OPENROUTER_API_KEY=...          # Optional
GEMINI_API_KEY=...              # Optional

Priority Calculation

PriorityCriteria
ALTA>90 days overdue OR amount >€1,000 OR disputed status
MEDIA60-90 days overdue
BASSA<60 days overdue

Response Handler Intents

The response handler recognizes these customer intents:

  • payment_confirmed - Customer confirms payment was made
  • request_info - Customer requests invoice copy or details
  • dispute - Customer disputes the invoice
  • request_delay - Customer requests payment extension/installments
  • payment_promise - Customer promises to pay by specific date
  • already_paid - Customer claims already paid
  • error_invoice - Customer reports invoice error

CSV Invoice Format

Required columns: invoice_id, customer_name, amount_total, amount_paid, due_date, status (open/paid/disputed), preferred_channel (email/sms/whatsapp), customer_email, customer_phone

API Routes

RouteMethodPurpose
/api/agents/payment-monitorPOSTRun invoice analysis
/api/agents/reminder-generatorPOSTGenerate reminder messages
/api/agents/response-handlerPOSTAnalyze customer response
/api/invoicesGET/POST/DELETECRUD for invoices
/api/settingsGET/POSTAI provider settings
/api/workflow-runsGET/POST/DELETEWorkflow execution history

Dark Mode (Tailwind v4)

The app uses manual theme toggle with the .dark class selector, NOT the system prefers-color-scheme. Tailwind v4 requires explicit configuration in globals.css:

@custom-variant dark (&:is(.dark *));

Theme flow:

  1. layout.tsx injects inline script to read localStorage('paymind-storage') and apply .dark class before hydration
  2. page.tsx useEffect syncs theme state to document.documentElement.classList
  3. Store persists theme to localStorage via Zustand persist middleware

Key Files

  • dashboard/src/lib/ai-providers.ts - Multi-provider AI abstraction with callAI(), AVAILABLE_MODELS, PROVIDER_INFO
  • dashboard/src/lib/agents.ts - System prompts: PAYMENT_MONITOR_PROMPT, REMINDER_GENERATOR_PROMPT, RESPONSE_HANDLER_PROMPT
  • dashboard/src/lib/store.ts - Global Zustand state including aiSettings, theme, language
  • dashboard/src/lib/i18n.ts - Translation system with useTranslation() hook and formatMessage() for parameterized strings
  • dashboard/src/lib/pdf-export.ts - PDF report generation using jspdf + jspdf-autotable
  • dashboard/src/types/index.ts - TypeScript interfaces: Agent, Invoice, LogEntry, WorkflowStep, AnalysisResult
  • dashboard/prisma/schema.prisma - Database models: Invoice, Message, ResponseAnalysis, WorkflowRun, WorkflowLog
  • dashboard/src/app/globals.css - Tailwind v4 config with dark mode custom variant

OpenRouter Free Models

OpenRouter provides 5 free models that work well for PayMind:

  • google/gemini-2.0-flash-exp:free - General purpose (default)
  • deepseek/deepseek-r1-0528:free - Reasoning tasks
  • meta-llama/llama-3.3-70b-instruct:free - High-quality responses
  • mistralai/devstral-2512:free - Coding tasks
  • mistralai/mistral-small-3.1-24b-instruct:free - Fast responses

Language

Italian business communications. Agent prompts and generated messages use Italian. Dashboard UI supports Italian/English toggle.

CI/CD

GitHub Actions runs on push/PR to main (.github/workflows/ci.yml): validates project structure (README.md, .claude directory).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.