SplitTab is a comprehensive expense sharing and bill splitting application inspired by Splitwise. It features receipt scanning with OCR, real-time notifications, advanced analytics, and seamless expense management across groups.
- Features
- Tech Stack
- Prerequisites
- Local Development Setup
- Docker Setup
- Environment Variables
- Database Setup
- Running the Application
- Testing
- API Documentation
- Project Structure
- Development Workflow
- Troubleshooting
- Contributing
- User authentication (JWT-based)
- Group management
- Expense creation and tracking
- Multiple split methods (equal, unequal, percentage)
- Balance calculation
- Settlement tracking
- Basic notifications
- Receipt scanning with OCR (Google Cloud Vision, AWS Textract)
- Background job processing with Bull Queue
- Manual OCR correction
- Advanced split methods
- File upload management with S3
- Real-time updates with Socket.IO
- Comprehensive notification system
- Analytics and reporting
- Spending trends
- Priority-based notifications
- Runtime: Node.js 20+
- Framework: Express.js
- Language: TypeScript
- Database: PostgreSQL 15+
- ORM: Prisma
- Cache: Redis 7+
- Queue: Bull
- Real-time: Socket.IO
- Authentication: JWT
- Validation: Zod
- Containerization: Docker, Docker Compose
- CI/CD: GitHub Actions
- File Storage: AWS S3
- OCR: Google Cloud Vision, AWS Textract
- Monitoring: Winston Logger
Before you begin, ensure you have the following installed:
- Node.js >= 20.0.0
- npm >= 10.0.0
- PostgreSQL >= 15
- Redis >= 7
- Docker and Docker Compose (optional, for containerized setup)
- Git
git clone <repository-url>
cd SplitTabcd backend
npm installCreate a .env file in the backend directory:
cp .env.example .envThen edit .env with your configuration (see Environment Variables section).
docker run -d --name splittab-postgres \
-e POSTGRES_USER=splittab \
-e POSTGRES_PASSWORD=your_password \
-e POSTGRES_DB=splittab_dev \
-p 5432:5432 \
postgres:15-alpine
docker run -d --name splittab-redis \
-p 6379:6379 \
redis:7-alpineEnsure PostgreSQL and Redis are running on your system.
cd backend
npx prisma migrate deploy
npx prisma generatenpm run db:seed# Terminal 1: Start API server
npm run dev
# Terminal 2: Start OCR worker
npm run dev:workerThe API will be available at http://localhost:3000/api/v1
-
Create
.envfilecd backend cp .env.example .env # Edit .env with your configuration
-
Start all services
docker-compose up -d
This will start:
- PostgreSQL (port 5432)
- Redis (port 6379)
- API Server (port 3000)
- OCR Worker (background process)
-
Run database migrations
docker-compose exec api npx prisma migrate deploy -
View logs
# All services docker-compose logs -f # Specific service docker-compose logs -f api docker-compose logs -f worker
-
Stop all services
docker-compose down
-
Stop and remove volumes
docker-compose down -v
Create a .env file in the backend directory with the following variables:
# Environment
NODE_ENV=development
# Server
PORT=3000
API_VERSION=v1
# Database
DATABASE_URL=postgresql://splittab:password@localhost:5432/splittab_dev
# Redis
REDIS_URL=redis://localhost:6379
# JWT
JWT_ACCESS_SECRET=your-super-secret-access-key-change-in-production
JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-in-production
JWT_ACCESS_EXPIRY=15m
JWT_REFRESH_EXPIRY=30d
# CORS
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
# File Upload
UPLOAD_DIR=./uploads/receipts
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_REGION=us-east-1
AWS_S3_BUCKET=splittab-uploads
# OCR Configuration
OCR_PROVIDER=google # Options: google, aws, both
GOOGLE_CLOUD_PROJECT_ID=your-project-id
GOOGLE_APPLICATION_CREDENTIALS=./google-cloud-credentials.json
AWS_TEXTRACT_REGION=us-east-1
OCR_CONFIDENCE_THRESHOLD=0.8
OCR_MAX_RETRIES=3
# Background Jobs (Bull Queue)
BULL_REDIS_HOST=localhost
BULL_REDIS_PORT=6379
BULL_REDIS_PASSWORD=
OCR_QUEUE_CONCURRENCY=5
# Logging
LOG_LEVEL=debug# Run all pending migrations
npm run migrate
# Create a new migration
npx prisma migrate dev --name migration_name
# Reset database (WARNING: destroys all data)
npx prisma migrate resetView and edit data using Prisma Studio:
npm run studioOpen http://localhost:5555 in your browser.
# Start API server with hot reload
npm run dev
# Start OCR worker with hot reload
npm run dev:worker# Build the application
npm run build
# Start API server
npm start
# Start OCR worker
npm run start:worker# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage# Run ESLint
npm run lint
# Fix ESLint issues
npm run lint:fix
# Format code with Prettier
npm run formathttp://localhost:3000/api/v1
GET /api/v1/health
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- Login userPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/logout- Logout user
GET /api/v1/users/me- Get current userPATCH /api/v1/users/me- Update current userGET /api/v1/users/:id- Get user by ID
GET /api/v1/groups- List user's groupsPOST /api/v1/groups- Create groupGET /api/v1/groups/:id- Get group detailsPATCH /api/v1/groups/:id- Update groupDELETE /api/v1/groups/:id- Delete group
GET /api/v1/expenses- List expensesPOST /api/v1/expenses- Create expenseGET /api/v1/expenses/:id- Get expense detailsPATCH /api/v1/expenses/:id- Update expenseDELETE /api/v1/expenses/:id- Delete expense
POST /api/v1/receipts/upload- Upload receiptGET /api/v1/receipts/:id- Get receipt detailsPATCH /api/v1/receipts/:id/corrections- Submit OCR corrections
GET /api/v1/notifications- List notificationsGET /api/v1/notifications/unread/count- Get unread countPATCH /api/v1/notifications/:id/read- Mark as readPATCH /api/v1/notifications/mark-all-read- Mark all as readDELETE /api/v1/notifications/:id- Delete notification
GET /api/v1/analytics/overview- Get overview statisticsGET /api/v1/analytics/receipts- Get receipt analyticsGET /api/v1/analytics/expenses- Get expense analyticsGET /api/v1/analytics/trends- Get spending trends
Connect to ws://localhost:3000 with authentication token:
Client β Server:
join:group- Join a group roomleave:group- Leave a group room
Server β Client:
connected- Connection establishednotification:new- New notification receivedreceipt:updated- Receipt updatedexpense:updated- Expense updatedsettlement:updated- Settlement updated
SplitTab/
βββ backend/
β βββ prisma/
β β βββ migrations/ # Database migrations
β β βββ schema.prisma # Database schema
β βββ src/
β β βββ config/ # Configuration files
β β βββ controllers/ # Route controllers
β β βββ middleware/ # Express middleware
β β βββ routes/ # API routes
β β βββ services/ # Business logic
β β βββ types/ # TypeScript types
β β βββ utils/ # Utility functions
β β βββ workers/ # Background workers
β β βββ app.ts # Express app setup
β β βββ index.ts # Server entry point
β βββ tests/ # Test files
β β βββ api/ # API integration tests
β β βββ integration/ # Integration tests
β β βββ unit/ # Unit tests
β βββ uploads/ # File uploads directory
β βββ .env.example # Environment variables template
β βββ docker-compose.yml # Docker Compose configuration
β βββ Dockerfile # Development Dockerfile
β βββ Dockerfile.prod # Production Dockerfile
β βββ jest.config.js # Jest configuration
β βββ package.json # Dependencies
β βββ tsconfig.json # TypeScript configuration
βββ docs/ # Project documentation
β βββ API-Specifications.md
β βββ Data-Models.md
β βββ Implementation-Roadmap.md
β βββ Phase-1-MVP.md
β βββ Phase-2-Enhanced-Features.md
β βββ Phase-3-Advanced-Features.md
β βββ Security-Compliance.md
β βββ Technical-Architecture.md
β βββ Testing-Strategy.md
β βββ UI-UX-Guidelines.md
βββ README.md # This file
git checkout -b feature/your-feature-name- Write code following the project's coding standards
- Add tests for new functionality
- Update documentation as needed
npm test
npm run lint
npm run formatgit add .
git commit -m "feat: add your feature description"git push origin feature/your-feature-name# Find process using port 3000
lsof -ti:3000
# Kill the process
kill -9 <PID># Check if PostgreSQL is running
docker ps | grep postgres
# Check connection
psql -h localhost -U splittab -d splittab_dev# Check if Redis is running
docker ps | grep redis
# Test connection
redis-cli ping# Regenerate Prisma Client
npx prisma generate
# Reset database
npx prisma migrate reset# Remove all containers and volumes
docker-compose down -v
# Rebuild containers
docker-compose build --no-cache
# View container logs
docker-compose logs -f- Never commit
.envfiles - Use.env.exampleas a template - Use strong JWT secrets in production
- Enable HTTPS in production
- Keep dependencies updated - Run
npm auditregularly - Follow rate limiting - Already configured in the application
- Sanitize user input - Using Zod validation
- Use prepared statements - Prisma handles this automatically
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License.
- Product Team: product@splittab.com
- Engineering Team: engineering@splittab.com
- Design Team: design@splittab.com
Built with β€οΈ by the SplitTab Team
Last Updated: 2025-11-21