Inspiration
SMBs on corporate cards generate thousands of transactions monthly but lack the intelligence tools that enterprises take for granted. Finance managers are stuck manually reviewing spreadsheets, chasing policy violations over email, and building expense reports by hand. We saw Brim's real anonymized transaction data and asked: what if a finance team could just talk to their spending data and have AI proactively surface what matters?
What it does
Lucid is an AI-powered expense intelligence platform built on 6 months of real anonymized Brim card transaction data (4,180 transactions, 9 cardholders, 3 departments). It delivers four core capabilities:
- Talk to Your Data — Finance managers ask questions in plain English ("What did Fleet Operations spend on fuel vs permits last quarter?") and get back charts, tables, and summaries with full multi-turn context
- Policy Compliance Engine — Digitized Brim's real expense policy with contextual AI analysis. A $200 solo dinner flags a violation; the same $200 dinner with 6 attendees passes — the AI explains why
- AI Pre-Approval Workflow — Pending transactions surface with employee spend history, department budget status, and an AI-generated approve/deny recommendation with reasoning. One click to decide
- Automated Expense Reports — AI-generated reports with category breakdowns, policy compliance checks, and narrative summaries ready for CFO review
Beyond the requirements, we built an AI Autopilot Advisor that autonomously chains 5 tool calls (KPIs, approvals, violations, anomaly detection, budget health) through multi-step reasoning to produce a prioritized action plan — streamed in real-time through a terminal UI. We also built spend forecasting with linear regression, vendor consolidation analysis, and employee peer benchmarking.
How we built it
- Next.js 16 with Turbopack for the frontend and API routes
- SQLite as the data layer — synchronous queries against 4,180 real Brim transactions
- Claude API (Sonnet) for multi-step agentic reasoning with tool use — the agent loop streams results so users see AI thinking in real-time
- Groq and DeepSeek (via OpenRouter) as alternative model options
- Recharts for data visualization — bar charts, pie charts, area charts, all with dark-themed custom tooltips
- Clerk for authentication
- Pattern analysis on 500+ merchant names to break down fleet operations into fuel, permits, tires/parts, and maintenance subcategories
- Real Brim expense policy digitized into structured rules for the compliance engine
Challenges we ran into
- Groq rate limits hit us mid-demo prep. We implemented dual-key rotation with automatic fallback and added DeepSeek as a third model option via OpenRouter's API using native fetch with manual SSE parsing
- Fleet category granularity — the raw data had all 3,500+ fleet transactions lumped under "transportation." We analyzed 500+ distinct merchant names and wrote SQL pattern-matching rules to classify them into 4 meaningful subcategories, making the dashboard actually useful for fleet cost management
- Multi-step agentic reliability — getting the AI Autopilot to consistently call all 5 tools in sequence and produce a structured action plan required careful prompt engineering and a robust streaming agent loop. Some models (like DeepSeek) couldn't handle the tool chaining, so we route Autopilot exclusively through Claude
- Real data, real messiness — anonymized card numbers, inconsistent merchant naming, mixed transaction types. We had to filter credits/point redemptions and build a complete data pipeline from XLSX to JSON to SQLite
Accomplishments that we're proud of
- Contextual compliance — the system understands that a $200 team dinner and a $200 solo dinner are fundamentally different policy situations. This is not threshold matching; it's reasoning
- The Autopilot terminal — watching the AI autonomously scan KPIs, check violations, detect anomalies, and produce a prioritized action plan in real-time is genuinely impressive. Multi-step agentic workflows, not single-prompt wrappers
- Fleet cost discovery — breaking "transportation" into fuel ($731k), permits ($359k), tires ($232k), and maintenance ($47k) was a genuine insight from the data that a finance manager would immediately act on
- Three-model architecture — Sonnet for depth, Groq for speed, DeepSeek as a free fallback. Users toggle with one click
What we learned
- AI depth beats feature breadth — two features that work beautifully create more impact than six that half-work. We focused on making compliance contextual and the autopilot truly agentic rather than adding more screens
- Real data changes everything — working with actual Brim transactions forced us to solve problems we'd never encounter with synthetic data: merchant name disambiguation, category inference, handling anonymized employee IDs
- Prompt engineering is architecture — the difference between a single-prompt wrapper and a multi-step agent is not just more API calls, it's designing tool schemas, managing conversation context across turns, and handling partial failures gracefully
- Streaming matters for trust — showing the AI's thinking process in real-time (tool calls scrolling through the terminal) builds user confidence in a way that a loading spinner never could
What's next for Lucid
- Receipt matching — OCR integration to auto-match uploaded receipts against transactions
- Slack/Teams integration — push approval requests and violation alerts directly into team channels
- Multi-company support — let Brim offer Lucid as a white-label intelligence layer for all their SMB clients
- Predictive policy violations — flag likely policy breaches before the transaction clears, using spending pattern analysis
- Custom policy builder — let finance teams define and modify expense rules through natural language instead of configuration forms
Built With
claude-api, next.js, react, typescript, tailwindcss, sqlite, better-sqlite3, recharts, clerk, groq, deepseek, openrouter, motion, turbopack
Log in or sign up for Devpost to join the conversation.