Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .cursor/rules/ai-persona-and-workflow.mdc
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
---
alwaysApply: true
---
# AI Persona and Workflow
# Engineering Workflow

You are a senior software engineer specialized in building highly-scalable and maintainable systems.
Use the existing codebase as the source of truth. Keep changes scoped, review nearby patterns before adding new files, and explain tradeoffs briefly when they matter.

## Guidelines
- When a file becomes too long, split it into smaller files. When a function becomes too long, split it into smaller functions.
- Before creating new files, always check if something similar already exists.
- Always finish one task completely before moving on to the next.
- After writing code, produce a 1-2 paragraph analysis of the code change's scalability and maintainability, and suggest potential improvements or next steps as needed.
- Always maintain a task list to track progress.
- After writing code, summarize what changed, how it was verified, and any meaningful follow-up.

## Planner Mode
When asked to enter "Planner Mode," follow this sequence:
1. Deeply reflect upon the changes being asked and analyze existing code to map the full scope of changes needed.
2. Ask 4-6 clarifying questions based on your findings to ensure complete understanding.
3. Once the questions are answered, draft a comprehensive, step-by-step plan of action.
1. Inspect the relevant code and map the likely scope.
2. Ask only the clarifying questions needed to avoid rework.
3. Draft a step-by-step plan.
4. Ask for approval on the plan before implementing any changes.
5. After completing each step, announce what was just completed and what the next steps are.

## Debugger Mode
When asked to enter "Debugger Mode," follow this exact sequence:
1. Reflect on 5-7 different possible sources of the problem.
2. Distill those down to the 1-2 most likely sources.
3. Add temporary logging to validate assumptions and track data flow before implementing a code fix.
4. Analyze the logs to produce a comprehensive analysis of the issue.
5. Once a fix is implemented, ask for approval to remove the previously added logs.
When asked to enter "Debugger Mode," follow this sequence:
1. Reproduce the issue or identify the closest available signal.
2. List the most likely causes and the evidence for each.
3. Add temporary logging only when existing traces are insufficient, then remove it before finishing.
4. Verify the fix against the failing path.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ADMIN_PASSWORD=your_secure_password_here
# ============================================
# Receipt Scanning Configuration (Optional)
# ============================================
# Receipt scanning will use mock data if not configured
# Receipt scanning returns sample data if no provider key is configured
# Choose one provider and set its API key

# OCR Provider - Choose one: "google" (default), "openai", or "anthropic"
Expand All @@ -35,4 +35,4 @@ ADMIN_PASSWORD=your_secure_password_here
# Google default: gemini-2.0-flash
# OpenAI default: gpt-4o
# Anthropic default: claude-sonnet-4-20250514
# OCR_MODEL=gemini-2.0-flash
# OCR_MODEL=gemini-2.0-flash
4 changes: 2 additions & 2 deletions ANALYTICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

This document describes the comprehensive PostHog analytics integration implemented in SplitSimple to answer key business questions about user behavior and feature usage.
This document describes the PostHog analytics integration used to answer key questions about user behavior and feature usage.

## Key Business Questions Tracked

Expand Down Expand Up @@ -273,4 +273,4 @@ Enable debug mode in development:
debug: process.env.NODE_ENV === "development"
```

This enables PostHog debug logging in browser console.
This enables PostHog debug logging in browser console.
2 changes: 1 addition & 1 deletion INFRASTRUCTURE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🏗️ SplitSimple Infrastructure & Deployment Guide

A comprehensive guide to deploying and managing SplitSimple's infrastructure across different environments.
Deployment and infrastructure notes for SplitSimple.

## 📋 Table of Contents

Expand Down
25 changes: 5 additions & 20 deletions README-testing.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Testing Guide for SplitSimple

This document provides comprehensive information about the testing infrastructure for SplitSimple.
This document explains the testing setup for SplitSimple.

## 🧪 Testing Stack

- **Jest**: JavaScript testing framework
- **React Testing Library**: Testing utilities for React components
- **MSW (Mock Service Worker)**: API mocking for tests
- **ts-jest**: TypeScript support for Jest
- **babel-jest**: Test transform used by the Next.js Jest setup

## 📁 Test Structure

Expand All @@ -17,9 +16,6 @@ This document provides comprehensive information about the testing infrastructur
├── tests/
│ ├── utils/
│ │ └── test-utils.tsx # Custom render function and utilities
│ └── mocks/
│ ├── handlers.ts # MSW request handlers
│ └── server.ts # MSW server setup
├── lib/__tests__/ # Unit tests for business logic
├── components/__tests__/ # Component tests
├── contexts/__tests__/ # Context/state management tests
Expand Down Expand Up @@ -204,19 +200,9 @@ expectCurrencyToBe(actualAmount, expectedAmount)

## 🔍 Mocking

### API Mocking with MSW
### API Mocking

API calls are automatically mocked using MSW. Mock responses are defined in `tests/mocks/handlers.ts`:

```typescript
// Override mock response for specific test
import { mockBillUtils } from '../../tests/mocks/handlers'

beforeEach(() => {
mockBillUtils.clear()
mockBillUtils.set('test-bill-id', testBill)
})
```
API route tests currently use direct Jest mocks for external services such as Redis.

### Component Mocking

Expand Down Expand Up @@ -303,7 +289,6 @@ Add to `.vscode/launch.json`:

- [Jest Documentation](https://jestjs.io/docs/getting-started)
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/)
- [MSW Documentation](https://mswjs.io/docs/)
- [Testing Best Practices](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library)

## 🤝 Contributing
Expand All @@ -328,4 +313,4 @@ When adding new features:
**Solution**: Check if all required props are provided and providers are wrapped correctly

### Issue: API tests failing
**Solution**: Verify MSW handlers are set up correctly and Redis mock is configured
**Solution**: Verify Redis and other external-service mocks are configured
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ A modern, collaborative bill-splitting app with real-time sync and universal sha
* **No Accounts Required**: Anonymous, temporary bill storage (auto-deletes after ~6 months)

### 💰 **Smart Bill Management**
* **Intelligent Status System**: Draft → Active → Closed workflow with contextual actions
* **Flexible Splitting**: Split items evenly, by shares, percentage, or exact amounts
* **Tax & Tip Allocation**: Distribute proportionally or evenly among participants
* **Accurate Calculations**: Precision math to avoid "penny problems"
Expand Down Expand Up @@ -62,7 +61,7 @@ A modern, collaborative bill-splitting app with real-time sync and universal sha
* `pnpm test:watch` - Run tests in watch mode
* `pnpm test:coverage` - Run tests with coverage report
* `pnpm lint` - Check code style
* `pnpm type-check` - Run TypeScript checks
* `pnpm typecheck` - Run TypeScript checks

### Deployment
Deploy to Vercel with Redis KV for full sharing functionality:
Expand Down Expand Up @@ -95,22 +94,21 @@ Deploy to Vercel with Redis KV for full sharing functionality:
### Key Features Implementation
* **Mathematical Precision** - Cent-based calculations to avoid floating-point errors
* **XSS Prevention** - Input sanitization and validation
* **Drag & Drop** - Smooth item reordering with @dnd-kit
* **Keyboard Reordering** - Move items through the app's undoable bill state
* **Responsive Design** - Mobile-first approach with adaptive layouts

## 🧪 Testing & Quality Assurance

### Testing Stack
* **Jest** - Test framework with 70% coverage targets
* **Jest** - Test framework and coverage reports
* **React Testing Library** - Component testing utilities
* **MSW** - API mocking for integration tests
* **GitHub Actions** - Automated CI/CD pipeline

### Test Coverage
* **98% calculations.ts** - Business logic validation
* **96% validation.ts** - Input sanitization and security
* **95% BillContext.tsx** - State management integrity
* **79 passing tests** - Comprehensive test suite
* **Comprehensive test suite** - Component, context, API route, and utility coverage

### Running Tests
```sh
Expand Down
5 changes: 3 additions & 2 deletions README.simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ REDIS_URL="redis://..."
NEXT_PUBLIC_POSTHOG_KEY="optional analytics"
NEXT_PUBLIC_POSTHOG_HOST="https://app.posthog.com"
OCR_PROVIDER="google" # or openai/anthropic
GOOGLE_GENERATIVE_AI_API_KEY="optional receipt image scanning"
```

If OCR keys are missing the app falls back to mock data.
If OCR keys are missing, receipt image scanning returns a configuration error. Paste-text receipt import still works without OCR keys.

## Deploy

Expand All @@ -54,7 +55,7 @@ If OCR keys are missing the app falls back to mock data.
- `contexts/` – `BillContext` reducer/history, sync helpers
- `lib/` – calculations, validation, sharing/export helpers
- `app/api/` – Next.js route handlers for sharing
- `tests/` – Jest helpers + MSW mocks
- `tests/` – Jest helpers and shared test utilities

## CI

Expand Down
Loading
Loading