Skip to content

Mobile expense sharing app helping friends and groups split bills fairly. Track shared expenses, calculate balances automatically, and settle up seamlessly. Built with React Native, Node.js, and Terraform-managed GCP infrastructure.

License

Notifications You must be signed in to change notification settings

Clestique/CoinBreakr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Expense Splitting Platform

A complete full-stack expense splitting platform with mobile app, backend API, marketing website, and cloud infrastructure. This repository contains all components needed to deploy and maintain a comprehensive expense sharing solution.

πŸ—οΈ Project Architecture

This project consists of four main components that work together to provide a complete expense splitting solution:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Marketing     β”‚    β”‚   Mobile App    β”‚    β”‚   Backend API   β”‚
β”‚    Website      β”‚    β”‚    (Client)     β”‚    β”‚   (Services)    β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚  Brand Image    β”‚    β”‚ Expense Splittingβ”‚    β”‚ User Management β”‚
β”‚  App Downloads  β”‚    β”‚ Friend Managementβ”‚    β”‚ Friend System   β”‚
β”‚  Information    β”‚    β”‚ Group Creation  β”‚    β”‚ Group Managementβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚ Balance Trackingβ”‚    β”‚ Expense Trackingβ”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚ Balance Calc    β”‚
                                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                       β”‚
                                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                              β”‚ Cloud Infrastructureβ”‚
                                              β”‚   (Terraform)   β”‚
                                              β”‚                 β”‚
                                              β”‚ GCP Deployment  β”‚
                                              β”‚ VPC & Networkingβ”‚
                                              β”‚ DNS Management  β”‚
                                              β”‚ VM + Kubernetes β”‚
                                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Deployment Architectures

Production & Staging (VM-based)

Internet β†’ Load Balancer β†’ VM Instances (2-10) β†’ MongoDB
           (SSL/TLS)        (Auto-scaling)

Testing (Kubernetes-based) πŸ†•

Internet β†’ Load Balancer β†’ Kubernetes Pods (2-10) β†’ MongoDB
           (External IP)    (GKE Auto-scaling)
           
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    GKE Cluster Architecture                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

    Internet
        β”‚
        β–Ό
    Load Balancer (External IP)
        β”‚
        β”œβ”€β–Ί Pod 1 (API:3000)
        β”œβ”€β–Ί Pod 2 (API:3000)
        └─► Pod N (API:3000)
             β”‚
             β–Ό
        Kubernetes Service
             β”‚
        β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
        β”‚         β”‚
    Node 1    Node N
    (e2-medium)

See ARCHITECTURE_DIAGRAM.md for detailed diagrams

πŸ“± User Journey & System Flow

1. Discovery & Marketing (website/)

User discovers app β†’ Visits marketing website β†’ Learns about features β†’ Downloads mobile app

Purpose: Brand presence and user acquisition

  • Technology: Next.js 16, TypeScript, Tailwind CSS
  • Features: SEO-optimized landing pages, app store links, feature showcases
  • Deployment: Static website hosting (Vercel/Netlify)

2. Mobile Application (Client/)

User downloads app β†’ Registers account β†’ Adds friends β†’ Creates groups β†’ Splits expenses β†’ Tracks balances

Purpose: Core expense splitting functionality

  • Technology: React Native, Expo, TypeScript
  • Features:
    • User authentication and profile management
    • Friend management with contact sync
    • Group creation and member management
    • Expense creation and splitting
    • Real-time balance calculations
    • Settlement tracking
  • Platforms: iOS and Android via Expo/EAS

3. Backend Services (services/)

Mobile app β†’ API requests β†’ Authentication β†’ Business logic β†’ Database operations β†’ Response

Purpose: Core business logic and data management

  • Technology: Node.js, Express, MongoDB, JWT
  • Features:
    • RESTful API with comprehensive endpoints
    • JWT-based authentication system
    • User and friend management
    • Group operations with role-based access
    • Expense tracking with automatic balance calculations
    • Security middleware and input validation
  • Database: MongoDB with Mongoose ODM

4. Cloud Infrastructure (terraform/)

Code deployment β†’ Terraform provisioning β†’ GCP resources β†’ Load balancer β†’ Auto scaling β†’ DNS routing

Purpose: Scalable cloud infrastructure with high availability

  • Technology: Terraform, Google Cloud Platform
  • Features:
    • Multi-environment support (production/staging)
    • Global HTTP(S) Load Balancer with SSL termination
    • Auto Scaling Groups with health-based scaling
    • Managed SSL Certificates for HTTPS security
    • VPC with public/private subnets
    • Instance Templates for consistent deployments
    • Cloud DNS management
    • Advanced firewall and security rules
    • Automated infrastructure deployment

πŸ”„ Complete System Workflow

Development to Production Pipeline

  1. Development Phase

    Developer codes β†’ Local testing β†’ Git commit β†’ Push to branch
    
  2. Infrastructure Provisioning

    Terraform plan β†’ Infrastructure validation β†’ Apply changes β†’ Resources created
    
  3. Backend Deployment

    Services build β†’ Docker containerization β†’ VM deployment β†’ Health checks
    
  4. Mobile App Distribution

    Client build β†’ EAS build service β†’ App store submission β†’ User downloads
    
  5. Website Deployment

    Website build β†’ Static optimization β†’ CDN deployment β†’ SEO indexing
    

πŸ“‚ Repository Structure

β”œβ”€β”€ Client/                      # React Native Mobile Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ screens/             # App screens (auth, friends, groups, expenses)
β”‚   β”‚   β”œβ”€β”€ services/            # API integration and data management
β”‚   β”‚   β”œβ”€β”€ navigation/          # App navigation setup
β”‚   β”‚   └── theme/               # Design system and styling
β”‚   β”œβ”€β”€ app.json                 # Expo configuration
β”‚   β”œβ”€β”€ package.json             # Dependencies and scripts
β”‚   └── README.md                # Mobile app documentation
β”‚
β”œβ”€β”€ services/                    # Node.js Backend API
β”‚   β”œβ”€β”€ controllers/             # Request handlers and business logic
β”‚   β”œβ”€β”€ models/                  # Database schemas (User, Group, Expense)
β”‚   β”œβ”€β”€ routes/                  # API endpoint definitions
β”‚   β”œβ”€β”€ middleware/              # Authentication and security
β”‚   β”œβ”€β”€ config/                  # Database and app configuration
β”‚   β”œβ”€β”€ docker-compose.yml       # Container orchestration
β”‚   β”œβ”€β”€ package.json             # Dependencies and scripts
β”‚   └── README.md                # Backend API documentation
β”‚
β”œβ”€β”€ website/                     # Next.js Marketing Website
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                 # Next.js pages (home, contact, privacy)
β”‚   β”‚   β”œβ”€β”€ components/          # React components (hero, features, footer)
β”‚   β”‚   └── lib/                 # Utility functions
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”œβ”€β”€ next.config.ts           # Next.js configuration
β”‚   β”œβ”€β”€ package.json             # Dependencies and scripts
β”‚   └── README.md                # Website documentation
β”‚
β”œβ”€β”€ terraform/                   # Infrastructure as Code (VM-based)
β”‚   β”œβ”€β”€ provider.tf              # GCP provider configuration
β”‚   β”œβ”€β”€ vpc.tf                   # Network and compute resources
β”‚   β”œβ”€β”€ dns.tf                   # Domain and DNS management
β”‚   β”œβ”€β”€ variables.tf             # Input variable definitions
β”‚   β”œβ”€β”€ terraform.main.tfvars    # Production environment config
β”‚   β”œβ”€β”€ terraform.staging.tfvars # Staging environment config
β”‚   └── README.md                # Infrastructure documentation
β”‚
β”œβ”€β”€ terraform-k8s/               # Kubernetes Infrastructure (Testing)
β”‚   β”œβ”€β”€ provider.tf              # GCP and Kubernetes provider config
β”‚   β”œβ”€β”€ gke.tf                   # GKE cluster configuration
β”‚   β”œβ”€β”€ artifact-registry.tf     # Docker image registry
β”‚   β”œβ”€β”€ variables.tf             # Input variable definitions
β”‚   β”œβ”€β”€ outputs.tf               # Output values
β”‚   β”œβ”€β”€ terraform.testing.tfvars # Testing environment config
β”‚   └── README.md                # K8s infrastructure documentation
β”‚
β”œβ”€β”€ k8s/                         # Kubernetes Manifests (Testing)
β”‚   β”œβ”€β”€ deployment.yaml          # Application deployment
β”‚   β”œβ”€β”€ service.yaml             # LoadBalancer service
β”‚   β”œβ”€β”€ hpa.yaml                 # Horizontal Pod Autoscaler
β”‚   β”œβ”€β”€ configmap.yaml           # Configuration
β”‚   β”œβ”€β”€ secret-template.yaml     # Secret template
β”‚   └── README.md                # K8s deployment guide
β”‚
└── README.md                    # This comprehensive overview

πŸš€ Quick Start Guide

Prerequisites

  • Node.js 18+
  • Terraform 1.0+
  • Google Cloud SDK + gke-gcloud-auth-plugin
  • kubectl
  • Docker
  • Expo CLI
  • MongoDB (local or cloud)

Option A: VM-based Deployment (Main/Staging)

1. Infrastructure Setup

cd terraform
terraform init
terraform plan -var-file="terraform.main.tfvars"
terraform apply -var-file="terraform.main.tfvars"

2. Backend Services

cd services
npm install
cp .env.example .env
# Configure environment variables
npm run dev

Option B: Kubernetes Deployment (Testing) πŸ†•

1. Deploy GKE Infrastructure

cd terraform-k8s
terraform init
terraform apply -var-file="terraform.testing.tfvars"

2. Configure kubectl & Deploy

# Install auth plugin
gcloud components install gke-gcloud-auth-plugin

# Get cluster credentials
gcloud container clusters get-credentials coinbreakr-testing-cluster \
  --zone us-central1-a --project coinbreakr

# Create secrets
kubectl create secret generic coinbreakr-secrets \
  --from-literal=mongo-url='YOUR_MONGO_URL' \
  --from-literal=jwt-secret='YOUR_JWT_SECRET'

# Deploy application
cd ../k8s
kubectl apply -f .

# Get external IP
kubectl get service coinbreakr-api-service

3. Test Deployment

# Get IP and test
EXTERNAL_IP=$(kubectl get service coinbreakr-api-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
curl http://$EXTERNAL_IP/v1/healthz

πŸ“š Full Kubernetes Guide: See START_HERE.md or KUBERNETES_DEPLOYMENT_GUIDE.md

Mobile Application & Website

3. Mobile Application

cd Client
npm install
cp .env.example .env
# Configure API endpoints
npm start

4. Marketing Website

cd website
npm install
npm run dev

🌐 Environment Management

Multi-Environment Architecture

Production Environment

  • Infrastructure: terraform.main.tfvars
  • API: Production MongoDB, optimized settings
  • Mobile: Production builds via EAS
  • Website: Production deployment with CDN
  • Domain: api.${domain} for API, ${domain} for website

Staging Environment

  • Infrastructure: terraform.staging.tfvars
  • API: Staging database, debug settings
  • Mobile: Development builds for testing
  • Website: Staging deployment for review
  • Domain: staging.${domain} for all services

Testing Environment (NEW - Kubernetes)

  • Infrastructure: terraform-k8s/terraform.testing.tfvars
  • Deployment: Docker containers on GKE
  • API: Kubernetes deployment with auto-scaling (2-10 pods)
  • Load Balancer: Kubernetes LoadBalancer service
  • Registry: GCP Artifact Registry for Docker images
  • Access: External IP (no DNS configured)

Development Environment

  • Infrastructure: Local or minimal cloud resources
  • API: Local MongoDB, development settings
  • Mobile: Expo development server
  • Website: Local Next.js development server

πŸ” Security & Best Practices

Authentication Flow

User Registration β†’ JWT Token Generation β†’ API Authentication β†’ Resource Access

Data Security

  • Password Hashing: bcrypt with salt rounds
  • JWT Tokens: Secure token-based authentication
  • Input Validation: Comprehensive request validation
  • Rate Limiting: Brute force protection
  • HTTPS: SSL/TLS encryption for all communications

Infrastructure Security

  • Network Segmentation: VPC with public/private subnets
  • Firewall Rules: Restrictive access control
  • Environment Isolation: Separate resources per environment
  • Secret Management: Environment variables and secure storage

πŸ“Š Key Features & Capabilities

Mobile App Features

  • βœ… User registration and authentication
  • βœ… Friend management with contact sync
  • βœ… Group creation and member management
  • βœ… Expense creation and splitting
  • βœ… Real-time balance calculations
  • βœ… Settlement tracking and history
  • βœ… Offline support with sync
  • βœ… Push notifications (planned)

Backend API Features

  • βœ… RESTful API with 20+ endpoints
  • βœ… JWT-based authentication
  • βœ… User and friend management
  • βœ… Group operations with roles
  • βœ… Expense tracking and calculations
  • βœ… Automatic balance management
  • βœ… Health monitoring and logging

Infrastructure Features

VM-based (Main & Staging)

  • βœ… Multi-environment support
  • βœ… Auto-scaling capabilities with CPU-based scaling (2-10 VMs)
  • βœ… Global Load Balancer with SSL termination
  • βœ… Managed SSL Certificates for automatic HTTPS
  • βœ… Health Checks and auto-healing instances
  • βœ… Automated deployments via Packer
  • βœ… DNS management with Cloud DNS
  • βœ… Security and compliance

Kubernetes-based (Testing) πŸ†•

  • βœ… GKE Cluster with auto-scaling nodes (1-5)
  • βœ… Horizontal Pod Autoscaler (2-10 pods)
  • βœ… Docker containerization with Artifact Registry
  • βœ… Rolling updates with zero downtime
  • βœ… Health checks (liveness + readiness probes)
  • βœ… Automated CI/CD via GitHub Actions
  • βœ… Load Balancer with external IP
  • βœ… Resource limits and requests per pod

πŸ”§ Development Workflow

Git Branch Strategy

main branch     β†’ Production deployments (VM-based)
staging branch  β†’ Staging environment testing (VM-based)
testing branch  β†’ Testing environment (Kubernetes-based) πŸ†•
dev branch      β†’ Development and feature work
feature/*       β†’ Individual feature development

Deployment Workflows

Main & Staging Branches (VM-based)

Push to branch β†’ Packer builds VM image β†’ Terraform deploys β†’ Load balancer routes traffic

Workflow: .github/workflows/packer-build.yml

Testing Branch (Kubernetes-based) πŸ†•

PR to testing β†’ Docker build test + security scan + K8s validation
                ↓
Merge to testing β†’ Build Docker image β†’ Push to Artifact Registry 
                   β†’ Deploy to GKE β†’ Health checks

Workflows:

  • .github/workflows/docker-test.yml (PR validation)
  • .github/workflows/docker-push-k8s-deploy.yml (Deployment)

Architecture Flow:

Developer
    β”‚
    β”‚ git push origin testing
    β”‚
    β–Ό
GitHub Actions
    β”‚
    β”œβ”€β–Ί Build Docker Image
    β”œβ”€β–Ί Security Scan (Trivy)
    β”œβ”€β–Ί Push to Artifact Registry
    β”‚   └─► us-central1-docker.pkg.dev/coinbreakr/coinbreakr-testing
    β”‚
    β–Ό
Deploy to GKE
    β”‚
    β”œβ”€β–Ί Apply ConfigMap
    β”œβ”€β–Ί Apply Deployment (2-10 pods)
    β”œβ”€β–Ί Apply Service (LoadBalancer)
    β”œβ”€β–Ί Apply HPA (Auto-scaling)
    β”‚
    β–Ό
Health Check
    └─► curl http://EXTERNAL_IP/v1/healthz

CI/CD Pipeline (Planned)

Code Push β†’ Automated Tests β†’ Build β†’ Deploy β†’ Health Checks β†’ Monitoring

Testing Strategy

  • Unit Tests: Individual component testing
  • Integration Tests: API endpoint testing
  • E2E Tests: Complete user flow testing
  • Performance Tests: Load and stress testing

πŸ“ˆ Monitoring & Maintenance

Health Monitoring

  • API Health: /v1/healthz endpoint monitoring
  • Database: Connection and performance monitoring
  • Infrastructure: GCP monitoring and alerting
  • Mobile App: Crash reporting and analytics

Performance Metrics

  • API Response Times: Track endpoint performance
  • Database Queries: Monitor query efficiency
  • Mobile App: Track user engagement and performance
  • Website: Core Web Vitals and SEO metrics

🚧 Future Enhancements

Planned Features

  • Push notifications for expense updates
  • Receipt scanning with OCR
  • Multi-currency support
  • Advanced analytics and reporting
  • Integration with payment platforms
  • Web application version
  • Advanced group permissions
  • Expense categories and budgeting

Infrastructure Improvements

  • βœ… Auto-scaling implementation (CPU-based with 2-10 instances)
  • βœ… Load balancer setup (Global HTTP(S) with SSL)
  • CDN integration
  • Advanced monitoring and alerting
  • Backup and disaster recovery
  • Multi-region deployment

πŸ“‹ Essential Commands

Kubernetes (Testing Environment)

# Get cluster status
kubectl get all -l app=coinbreakr-api

# View pods
kubectl get pods -l app=coinbreakr-api

# View logs
kubectl logs -f deployment/coinbreakr-api

# Get external IP
kubectl get service coinbreakr-api-service

# Check auto-scaling
kubectl get hpa

# Update deployment
kubectl set image deployment/coinbreakr-api \
  api=us-central1-docker.pkg.dev/coinbreakr/coinbreakr-testing/services:NEW_TAG

# Rollback deployment
kubectl rollout undo deployment/coinbreakr-api

# Scale manually
kubectl scale deployment coinbreakr-api --replicas=5

# Restart deployment
kubectl rollout restart deployment/coinbreakr-api

# Get load balancer IP
kubectl get service coinbreakr-api-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

# Test API
curl http://$(kubectl get service coinbreakr-api-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')/v1/healthz

Full Command Reference: COMMANDS_REFERENCE.md
Kubernetes Guide: k8s/README.md

Terraform

# VM Infrastructure (Main/Staging)
cd terraform
terraform init
terraform plan -var-file="terraform.main.tfvars"
terraform apply -var-file="terraform.main.tfvars"

# Kubernetes Infrastructure (Testing)
cd terraform-k8s
terraform init
terraform plan -var-file="terraform.testing.tfvars"
terraform apply -var-file="terraform.testing.tfvars"

Docker

# Build image
docker build -t coinbreakr-api:latest ./services

# Push to Artifact Registry
docker tag coinbreakr-api:latest \
  us-central1-docker.pkg.dev/coinbreakr/coinbreakr-testing/services:latest
docker push us-central1-docker.pkg.dev/coinbreakr/coinbreakr-testing/services:latest

🀝 Contributing

Development Setup

  1. Fork the repository
  2. Create feature branch from dev
  3. Set up local development environment
  4. Make changes and test thoroughly
  5. Submit pull request with detailed description

Code Standards

  • TypeScript: Strict type checking
  • ESLint: Follow configured rules
  • Testing: Write tests for new features
  • Documentation: Update relevant README files

πŸ“„ License

This project is proprietary software. All rights reserved.

πŸ“š Documentation

Getting Started

Architecture & Design

Deployment Guides

Operations & Maintenance

Component Documentation


Project Type: Full-stack expense splitting platform
Architecture: Microservices with mobile-first approach
Deployment: Multi-environment cloud infrastructure (VM + Kubernetes)
Target Users: Individuals and groups sharing expenses
Kubernetes: βœ… Testing environment ready
Auto-scaling: βœ… Pods (2-10) + Nodes (1-5)

About

Mobile expense sharing app helping friends and groups split bills fairly. Track shared expenses, calculate balances automatically, and settle up seamlessly. Built with React Native, Node.js, and Terraform-managed GCP infrastructure.

Topics

Resources

License

Stars

Watchers

Forks