pay-flown

PayFlown - Digital Wallet App

A full-featured digital wallet application similar to GCash, built with Next.js, Supabase, and TypeScript.

Features

Core Functionality

Security Features

Tech Stack

Project Structure

app/
├── (dashboard)/              # Protected dashboard routes
│   ├── page.tsx             # Dashboard home
│   ├── send/               # Send money page
│   ├── request/            # Request money page
│   ├── history/            # Transaction history
│   ├── contacts/           # Contacts management
│   ├── topup/              # Top-up wallet
│   ├── cashout/            # Cash out
│   ├── settings/           # User settings
│   └── layout.tsx          # Dashboard layout
├── auth/
│   ├── login/              # Phone OTP login
│   ├── signup/             # Phone OTP signup
│   └── error/              # Auth error page
├── api/
│   ├── contacts/
│   │   └── search/         # Search users by phone
│   └── transactions/
│       ├── send/           # Send money API
│       └── request/        # Request money API
└── page.tsx                # Root redirect page

components/
├── dashboard-header.tsx     # Dashboard header with user info
├── dashboard-nav.tsx        # Navigation sidebar
├── protected-route.tsx      # Auth guard component
├── wallet-card.tsx          # Wallet balance display
└── recent-transactions.tsx  # Recent transactions widget

hooks/
├── useAuth.ts              # Authentication hook
└── useWallet.ts            # Wallet data hook

lib/
├── supabase/
│   ├── client.ts           # Browser client setup
│   ├── server.ts           # Server client setup
│   └── proxy.ts            # Session proxy for middleware
└── utils.ts                # Utility functions

Database Schema

Tables

auth.users (Supabase built-in)

profiles

wallets

transactions

payment_requests

contacts

All tables have Row-Level Security (RLS) policies enabled to ensure users can only access their own data.

Getting Started

Prerequisites

Installation

  1. Clone and setup
    npm install
    # or
    pnpm install
    
  2. Environment Variables Create .env.local:
    NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
    SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_key
    STRIPE_SECRET_KEY=your_stripe_secret
    
  3. Run migrations
    # The database schema is created via the setup-schema.sql script
    
  4. Start development server
    npm run dev
    # or
    pnpm dev
    

Visit http://localhost:3000 to see the app.

Usage

Sign Up

  1. Go to /auth/signup
  2. Enter your full name and phone number
  3. Receive OTP via SMS
  4. Verify OTP to create account
  5. Wallet auto-creates with 0 balance

Send Money

  1. Go to Send Money from dashboard
  2. Enter recipient’s phone number and search
  3. Enter amount and optional message
  4. Confirm and send
  5. Both wallets are updated instantly

Request Money

  1. Go to Request Money
  2. Enter payer’s phone number
  3. Specify amount and reason
  4. Payer receives notification

Top-up

  1. Go to Top-up Wallet
  2. Enter amount or select quick amount
  3. Click “Proceed to Payment”
  4. Complete Stripe payment
  5. Balance updated upon success

API Routes

POST /api/contacts/search

Search for user by phone number

Request: { "phone": "+63 9XX XXX XXXX" }
Response: { "profile": { "id", "display_name", "phone_number" } }

POST /api/transactions/send

Send money to another user

Request: { "recipientPhone", "amount", "message" }
Response: { "success": true, "message": "..." }

POST /api/transactions/request

Create payment request

Request: { "recipientPhone", "amount", "reason" }
Response: { "success": true, "paymentRequest": {...} }

Authentication Flow

  1. Signup: User enters phone → OTP sent → Verified → Profile & Wallet created
  2. Login: User enters phone → OTP sent → Verified → Session established
  3. Protected Routes: Middleware checks auth state → Redirects to login if needed

Security Considerations

Future Enhancements

Demo Mode

The app runs in demo mode by default:

Support

For issues or questions, please refer to the documentation or create an issue in the repository.

License

MIT License - Feel free to use this project for personal or commercial purposes.