A ChatGPT App that integrates with Splitwise to manage expenses, track spending, and provide analytics - all through natural conversation.
- 🔐 Secure Authentication: Email-based registration with JWT session tokens
- 💰 Payment Gating: 3 free messages, then one-time payment ($0.99 - 90% OFF!)
- 📊 Expense Management: Add expenses to Splitwise via natural language
- 📈 Analytics: View spending trends, category breakdowns, and budget insights
- ⚙️ Smart Defaults: Set default groups and split types
- 🎯 Category Matching: Auto-suggests Splitwise categories from conversation context
- Framework: Next.js 14 with App Router
- MCP Server: Model Context Protocol for ChatGPT integration
- Database: Upstash Redis (serverless)
- Payments: Stripe
- OAuth: Splitwise API integration
- UI: React with TypeScript
- Deployment: Vercel
- Project structure created
- Dependencies installed
- Environment variables configured
- Redis database schema designed
- Core libraries implemented:
- Database helper (Redis CRUD operations)
- Authentication & session management (JWT)
- Encryption utilities (for Splitwise tokens)
- Usage tracking (message limits)
- User registration flow
- Payment gating logic
- Stripe integration
- Node.js 18+
- Upstash Redis account
- Stripe account
- Splitwise developer app
-
Clone and install dependencies:
cd splitwise-app npm install -
Configure environment variables:
cp .env.example .env
Fill in the required values:
UPSTASH_REDIS_REST_URL- From Upstash dashboardUPSTASH_REDIS_REST_TOKEN- From Upstash dashboardSTRIPE_SECRET_KEY- From Stripe dashboardSTRIPE_PUBLISHABLE_KEY- From Stripe dashboardSPLITWISE_CLIENT_ID- From Splitwise app settingsSPLITWISE_CLIENT_SECRET- From Splitwise app settingsJWT_SECRET- Generate a random 32+ character stringENCRYPTION_KEY- Generate a random 32+ character string
-
Run development server:
npm run dev
┌─────────────────────────────────────────────────────────────┐
│ ChatGPT Interface │
└─────────────────────────────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────────┐
│ MCP Server (Next.js) │
│ • Splitwise OAuth & API Integration │
│ • Expense Management Tools │
│ • Analytics Tools │
│ • User Management │
│ • Payment Gating │
└─────────────────────────────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────────┐
│ React Widget (Skybridge) │
│ • Expense Entry Form │
│ • Analytics Dashboard │
│ • Payment Gate UI │
│ • Settings Panel │
└─────────────────────────────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────────┐
│ External Services │
│ • Splitwise API (OAuth + REST) │
│ • Stripe (Payment Processing) │
│ • Upstash Redis (User Data) │
└─────────────────────────────────────────────────────────────┘
Key: user:{session_token}
Type: Hash
Fields:
- id: UUID
- email: string
- session_token: JWT
- created_at: ISO timestamp
- splitwise_user_id: string (optional)
- splitwise_access_token: encrypted string (optional)
- splitwise_refresh_token: encrypted string (optional)
- default_group_id: string (optional)
- default_split_type: string (optional)
- payment_status: 'free' | 'paid'
- message_count: integer
- paid_at: ISO timestamp (optional)
Key: email:{email}
Type: String
Value: session_token
Key: payment:{payment_intent_id}
Type: Hash
Fields:
- payment_intent_id: string
- user_session_token: string
- amount: number (in cents)
- status: 'pending' | 'completed' | 'failed'
- created_at: ISO timestamp
Key: usage:{session_token}:{date}
Type: List
Items: JSON objects with {tool_name, timestamp}
TTL: 30 days
- User CRUD operations
- Payment tracking
- Usage logging
- Message count management
- Splitwise category caching
- JWT token generation and verification
- User registration
- Session management
- Email validation
- AES encryption for Splitwise tokens
- Secure token storage
- Hash generation
- Message limit enforcement
- Tool usage categorization
- Free vs paid user logic
- Usage summaries
-
Counted operations:
add_expenseset_defaultscreate_payment
-
Free operations (unlimited):
get_groupsget_categoriesget_expense_analyticsget_budget_statuscheck_payment_statusconnect_splitwise
- Unlimited access to all tools
- Lifetime access
- Encryption: All Splitwise tokens encrypted with AES-256
- JWT: Secure session tokens with 1-year expiration
- Rate Limiting: Usage tracking prevents abuse
- Environment Variables: All secrets stored securely
- CORS: Proper headers for ChatGPT integration
splitwise-app/
├── app/ # Next.js App Router
│ └── api/ # API routes
│ ├── mcp/ # MCP endpoint
│ ├── auth/ # OAuth handlers
│ ├── stripe/ # Payment webhooks
│ └── user/ # User management
├── src/
│ ├── server/
│ │ ├── lib/ # Core libraries ✅
│ │ │ ├── database.ts
│ │ │ ├── auth.ts
│ │ │ ├── encryption.ts
│ │ │ └── usage.ts
│ │ └── tools/ # MCP tools (next phase)
│ └── web/ # React widget (next phase)
├── scripts/
│ └── build-widget.ts
├── public/
│ └── widget.html # Generated widget
└── .env # Environment variables
# Development
npm run dev # Next.js dev server (Vercel)
npm run dev:local # Local MCP server with ngrok
# Build
npm run build # Build Next.js app
npm run build:widget # Build React widget
# Production
npm start # Start production serverSee tasks/todo.md for the complete implementation plan.
- User registration flow with email
- Payment gate enforcement
- Stripe checkout integration
- Webhook handling
- OAuth flow implementation
- Splitwise API client
- Expense management tools
- Category matching
- Expense form component
- Analytics dashboard
- Payment gate UI
- Settings panel
This is a personal project for ChatGPT App development. Feel free to fork and adapt for your own use.
MIT
For issues or questions, please refer to the documentation in /context folder.