Developer Overview
Welcome, Developer
This section provides a comprehensive technical reference for NeoCash’s internals. Whether you’re contributing to the codebase, building integrations, or just curious about how a privacy-first AI financial app works under the hood, you’ll find everything here.
Architecture at a Glance
NeoCash is a Next.js 15 application with a local-first architecture:
- Frontend: React 19 with custom hooks for IndexedDB state management
- Backend: Next.js API routes that proxy to Anthropic’s Claude API
- Storage: Browser IndexedDB via
idb— no cloud database - AI: Claude models (Sonnet, Haiku, Opus) with tool use and streaming
- Agent System: 5 specialist agents with keyword + AI-based routing
Data Flow
User Input → Agent Router → Specialist System Prompt
→ Claude API (streaming) → Tool Calls → IndexedDB
→ Signal Detection (Haiku) → Dashboard Updates
Key Subsystems
Chat & Streaming
The /api/chat endpoint handles message streaming with tool execution. Messages are windowed to fit within a 160k token budget, keeping recent messages intact while trimming older ones.
Goal Management
Goals extend conversations with structured dashboards, action items, and AI insights. Each goal has a typed schema (currency, percentage, date, text, number, boolean) that’s auto-generated by Claude based on the goal’s context.
Memory System
Long-term user context is stored as facts (biographical data) and decisions (financial choices). Memories are auto-extracted from conversations and injected into system prompts for personalized responses.
Signal Detection
After each AI response, Claude Haiku analyzes the text against all active goals to detect cross-pollination opportunities — data points from one conversation that are relevant to another goal.
Agent Routing
A three-tier classification system routes messages to the right specialist:
- Goal category override — instant, no API call
- Haiku classification — fast AI classification into 5 agent types
- Keyword fallback — local keyword scoring
Section Guide
| Page | What You’ll Find |
|---|---|
| Architecture | System architecture, data flow diagrams, component structure |
| Hooks | All 7 custom React hooks with signatures and usage |
| Tools | 18 AI tool definitions with schemas and parameters |
| API Routes | All API endpoints with request/response formats |
| Types | Complete TypeScript interface reference |
| System Prompts | How system prompts are built and composed |
| Message Windowing | Token budget management and conversation trimming |
Key Files
| Path | Purpose |
|---|---|
src/hooks/ | 7 custom hooks for IndexedDB store access |
src/lib/tool-schemas.ts | All tool definitions with JSON schemas |
src/lib/tool-executor.ts | Tool execution engine |
src/lib/system-prompt.ts | System prompt composition |
src/lib/agent-profiles.ts | 5 specialist agent definitions |
src/lib/agent-router.ts | Three-tier agent classification |
src/lib/message-windowing.ts | Token budget and message trimming |
src/types/index.ts | All TypeScript interfaces |
src/app/api/ | API route handlers |