Skip to content

elilourens/prophit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prophit

A personal spending prediction app for 20-somethings. Prophit connects to your bank data, pulls in external signals like weather and local events, and uses a council of LLMs to generate probabilistic daily spending forecasts — so you can actually see where your money's going before it's gone.

Built at HackEurope — Monzo track.


Features

Daily Predictions (Home)

  • Weather-aware spending predictions for Dublin, IE
  • Probability bars for predicted spend categories (lunch, coffee, drinks, transport)
  • Live week-ahead calendar generated by multi-LLM consensus (Claude + Gemini + GPT-4o Mini)
  • Morning Briefing widget with daily voice playback

Long Horizon Insights

  • Job quit runway — circular progress ring showing how long you can survive without income (powered by /get_runway API)
  • Seasonal spending comparison (winter vs summer)
  • Monthly spend trajectory with projection line graph
  • Weekly recap with AI accuracy score

Spending History & Patterns

  • Week / Month / Year toggle
  • This week vs last week comparison bars
  • Category breakdown donut chart
  • Unusual spike alerts with merchant details

Scenario Simulator

  • "What if I quit my job?" — runway slider
  • "Cut eating out by 50%" — savings calculator
  • "Move to a cheaper area" — rent comparison
  • AI-generated budget tips from real spending patterns (via /get_tips)

Arena — Blockchain-Staked Social Savings

Create or join competitive savings arenas with friends, backed by real SOL stakes on the Solana devnet.

Arena Modes:

  • Budget Guardian — Stay under your spending target. Lowest spender under budget wins.
  • Vice Streak — Avoid vice categories (coffee, fast food, alcohol, takeaway, shopping, gambling). Last one standing wins.
  • Savings Sprint — First to hit their savings target wins the prize pool. Auto-settles when a member crosses the line.

Arena Flow:

  1. Create an arena: set a name, pick a mode, set a target amount, choose SOL stake, set end date
  2. Share a 6-digit join code with friends
  3. Members' spending is synced in real-time via Supabase
  4. Winner is determined automatically at the end date (or early for Savings Sprint)
  5. SOL prize pool is paid out via on-chain Solana transaction

Blockchain Details:

  • Per-user Solana wallets generated and stored locally (AsyncStorage keypair)
  • New users receive an automatic 0.15 SOL airdrop to get started
  • Arena escrow accounts using Program Derived Addresses (PDAs)
  • Transactions verifiable on Solana Explorer
  • Smart contract handles stake collection, escrow, and winner payout

Morning Briefing

  • Daily voice briefing generated by ElevenLabs TTS (Rachel voice, eleven_turbo_v2_5 model)
  • Compact widget card with weather, top prediction, and a nudge
  • Play/pause controls with animated sound wave
  • Time-of-day greeting, dynamic spending context

AI Chat — "The Prophit"

  • Conversational financial assistant powered by Groq (Llama 3.3-70B)
  • Voice input via Groq Whisper API (speech-to-text)
  • Text-to-speech output toggle (ElevenLabs)
  • Aware of your current spending patterns and predictions
  • Context-aware nudges and budget advice
  • Maintains 20-message conversation history

Pro Tier (Stripe)

  • Free tier with core predictions
  • Pro tier at €1.99/month with 7-day free trial
  • Stripe card payment flow (Apple Pay / Google Pay ready)
  • Pro unlocks: full spending history, weekly recap, scenario simulator, voice briefings, AI chat

Onboarding

  • Bank selection (Monzo, Revolut, AIB, Bank of Ireland, Bank of Scotland)
  • Upload bank statement (JSON, CSV, PDF) or use demo data
  • Guided connect flow with progress steps
  • Auto-parses transactions and seeds the app

Tech Stack

Frontend

Layer Technology
Framework React Native + Expo (SDK 54)
Language TypeScript
Navigation Expo Router (file-based)
Charts react-native-chart-kit + react-native-svg
Audio expo-av (ElevenLabs TTS playback)
Auth & DB Supabase (auth, realtime, CRUD)
Blockchain @solana/web3.js (Solana devnet)
Payments @stripe/stripe-react-native
File handling expo-document-picker + expo-file-system
Local storage @react-native-async-storage/async-storage

Backend

Layer Technology
Runtime Python (FastAPI + Gradio)
LLMs Claude Haiku 4.5, Gemini 2.5 Flash Lite, GPT-4o Mini
Deployment Vercel
Voice ElevenLabs TTS API

AI / Voice

Service Model Used for
Anthropic Claude Haiku 4.5 Transaction analysis, consensus synthesis
Google Gemini 2.5 Flash Lite Parallel transaction analysis
OpenAI GPT-4o Mini Spending pattern detection
Groq Llama 3.3-70B Chat assistant responses
Groq Whisper Large v3 Voice-to-text input
ElevenLabs eleven_turbo_v2_5 (Rachel) Morning briefing TTS

Supabase

Resource Purpose
users table User profiles, username, avatar
arenas table Arena config, mode, targets, stakes, status
arena_members table Member spend tracking, last synced
arena_bets table Bet records and outcomes
Auth Email/password sign up and sign in
Realtime Live arena updates via Postgres subscriptions

Solana

Component Detail
Network Devnet
Wallet Per-user keypair, generated on onboarding
Airdrop 0.15 SOL auto-airdrop to new wallets
Escrow PDAs per arena for trustless stake holding
Settlement On-chain payout to winner's wallet
Explorer Solana Explorer links for every transaction

Design System (Monzo-inspired)

Token Value
Primary / CTA Hot Coral #FF4F40
Headers / Text Deep Navy #112231
Background Soft White #F2F8F3
Accent Deep Teal #004E60
Accent Neon Yellow #C3FF34
Accent Mid Orange #FE8B18
Corner radius 24pt+
Font Inter / system sans-serif

Project Structure

prophit/
├── frontend/                      # React Native / Expo app
│   ├── app/
│   │   ├── (tabs)/                # Bottom-tab screens
│   │   │   ├── index.tsx          # Home — daily predictions
│   │   │   ├── insights.tsx       # Long horizon insights
│   │   │   ├── history.tsx        # Spending history & patterns
│   │   │   ├── simulator.tsx      # Scenario simulator
│   │   │   ├── arena.tsx          # Social savings arenas
│   │   │   └── profile.tsx        # User profile & stats
│   │   ├── briefing.tsx           # Morning briefing card
│   │   ├── chat.tsx               # AI chat assistant
│   │   ├── onboarding.tsx         # Bank connect flow
│   │   ├── login.tsx              # Auth (sign in / sign up)
│   │   ├── upgrade.tsx            # Stripe Pro upgrade
│   │   ├── add-transaction.tsx    # Manual transaction entry
│   │   ├── arena-create.tsx       # Create arena
│   │   ├── arena-join.tsx         # Join arena by code
│   │   ├── arena-detail.tsx       # Arena detail & member spending
│   │   └── arena-results.tsx      # Arena results & Solana payout
│   ├── services/
│   │   ├── backendApi.ts          # Gradio API client
│   │   ├── chatService.ts         # Groq LLM chat service
│   │   ├── ttsService.ts          # ElevenLabs TTS service
│   │   ├── voiceService.ts        # Groq Whisper STT service
│   │   ├── transactionService.ts  # Transaction CRUD
│   │   ├── transactionSyncService.ts  # Arena spend syncing
│   │   ├── arenaSettlementService.ts  # Arena winner logic
│   │   ├── arenaSyncService.ts    # Real-time arena sync
│   │   └── solana/
│   │       └── solanaService.ts   # Solana wallet & escrow
│   ├── contexts/
│   │   ├── ArenaContext.tsx       # Supabase arena state & auth
│   │   ├── SolanaContext.tsx      # Solana wallet state
│   │   └── UserDataContext.tsx    # User transactions & predictions
│   ├── components/                # Reusable UI components
│   └── package.json
├── test-backend/                  # FastAPI + Gradio backend (local dev)
│   ├── main.py
│   ├── ui.py
│   └── requirements.txt
└── README.md

Getting Started

Prerequisites

  • Node.js 18+
  • Expo CLI (npm install -g expo-cli)
  • iOS Simulator / Android Emulator or Expo Go on device

Frontend Setup

cd frontend
npm install

Create a .env file in frontend/:

EXPO_PUBLIC_SUPABASE_URL=your_supabase_url
EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
EXPO_PUBLIC_ELEVENLABS_API_KEY=your_elevenlabs_key
EXPO_PUBLIC_GROQ_API_KEY=your_groq_key

Start the app:

npm start        # Expo dev server
npm run ios      # iOS simulator
npm run android  # Android emulator

Backend Setup (local dev only)

cd test-backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Create a .env file in test-backend/:

ANTHROPIC_API_KEY=your_anthropic_key
GEMINI_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key

Run the Gradio UI:

python ui.py

Or run the FastAPI server:

uvicorn main:app --reload --port 8001

Backend API

Production base URL: https://prophit-ashy.vercel.app

All endpoints follow the Gradio async pattern:

// Step 1: Submit
const { event_id } = await fetch('/gradio_api/call/{endpoint}', {
  method: 'POST',
  body: JSON.stringify({ data: [...args] }),
}).then(r => r.json());

// Step 2: Poll for result (SSE stream)
const text = await fetch(`/gradio_api/call/{endpoint}/${event_id}`).then(r => r.text());
const result = JSON.parse(text.split('\n').find(l => l.startsWith('data: ')).slice(6));

Endpoints

Endpoint Input Output Used for
/analyse_uploaded Transaction file (JSON/CSV/PDF/TXT) 3× markdown analyses (Claude, Gemini, OpenAI) Insights, History screens
/calendar_uploaded Transaction file Week-ahead calendar markdown + JSON predictions Home screen predictions
/get_tips Spending pattern text AI budget tips (markdown) Simulator, Chat
/get_runway Financial summary text Income runway analysis (markdown) Insights runway ring
/_runway_summary_from_file Transaction file Financial summary text Feed into /get_runway

Calendar JSON shape

{
  "week_start": "2026-03-01",
  "daily_predictions": [
    {
      "date": "2026-03-02",
      "day": "Monday",
      "predictions": [
        {
          "behavior": "Coffee",
          "likelihood": 83,
          "avg_spend": 5.50,
          "agreed_by": ["claude", "openai"]
        }
      ]
    }
  ]
}

How the Multi-LLM Engine Works

  1. File parsing — transactions enriched with day_of_week
  2. Parallel analysis — Claude, Gemini, and GPT-4o Mini each analyse the full history simultaneously
  3. Pattern detection — each model identifies recurring spending behaviours by day and category
  4. Consensus calendar — Claude synthesises all three outputs into a single week-ahead calendar
  5. Deduplication — duplicate merchants merged, most accurate predictions surfaced

How the Arena Settlement Works

  1. Creator sets arena mode, target, stake amount (SOL), and end date
  2. All members' Solana wallets fund the escrow PDA on creation/join
  3. During the arena, member transactions are synced to Supabase in real-time
  4. At end date (or early trigger for Savings Sprint), the settlement service runs:
    • Budget Guardian: member with lowest spend under target wins
    • Vice Streak: member who avoided vice categories longest wins
    • Savings Sprint: first member to reach savings target wins (auto-settles immediately)
  5. Winner's wallet receives the full SOL prize pool via on-chain transaction
  6. Solana Explorer link displayed in arena results screen

Environment Variables

Variable Where Purpose
EXPO_PUBLIC_SUPABASE_URL frontend/.env Supabase project URL
EXPO_PUBLIC_SUPABASE_ANON_KEY frontend/.env Supabase anon key
EXPO_PUBLIC_ELEVENLABS_API_KEY frontend/.env ElevenLabs TTS voice briefings
EXPO_PUBLIC_GROQ_API_KEY frontend/.env Groq (chat LLM + Whisper STT)
ANTHROPIC_API_KEY test-backend/.env Claude API
GEMINI_API_KEY test-backend/.env Gemini API
OPENAI_API_KEY test-backend/.env OpenAI API

Never commit .env files — they are in .gitignore.

About

hackeurope submission Risk & Reward

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors