Skip to content
malip23Public

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CalcGuard

A calculator app that hides personal safety features behind secret codes. Designed for women and vulnerable individuals who need a discreet way to call for help in dangerous situations.

Built for HackViolet 2026.

How It Works

CalcGuard looks and functions exactly like a standard iOS calculator. However, when the user types a specific numeric code followed by =, it silently triggers a safety action in the background — no visible change on screen, no alerts, no notifications.

Default Secret Codes

Code Action Description
100= Open Settings Opens the hidden settings dashboard (fixed, cannot be changed)
911= Emergency Alert Sends email with GPS location to all emergency contacts
200= Directions Voice-activated navigation via Gemini AI
300= Start Recording Begins background audio recording
400= Fake Call Triggers a fake incoming call with AI-generated voice
500= Safe Check-in Sends "I'm safe" email to contacts
600= Fake Shutdown Screen goes completely black (triple-tap to exit)
700= Stop All Stops recording and uploads saved audio

All codes except 100= (settings) are fully customizable by the user.

First Launch Flow

  1. Open the app — you see a normal calculator
  2. Type 100= — the hidden settings dashboard opens
  3. Add emergency contacts (name + email)
  4. Customize your secret codes if desired
  5. Tap Save — all codes become active
  6. You're back on the calculator, ready to use

Tech Stack

  • React Native with Expo SDK 54 (TypeScript)
  • Firebase — Cloud Functions, Cloud Storage, Firestore
  • Nodemailer + Gmail — Silent email delivery via Firebase Cloud Functions
  • Google Gemini 2.0 Flash — AI-generated emergency messages and voice-activated directions
  • ElevenLabs — AI voice synthesis for fake incoming calls
  • expo-location — GPS coordinates for emergency alerts and directions
  • expo-av — Audio recording and voice input
  • expo-secure-store — Encrypted local storage for contacts and codes

Features

Emergency Alert (911=)

Sends an email to all emergency contacts containing:

  • A custom or AI-generated message
  • A Google Maps link with the user's current GPS coordinates

When AI messages are enabled, Gemini generates natural-sounding texts like "Hey can you come pick me up? I'm at [location]" instead of obvious emergency alerts — important if someone dangerous is watching the phone screen.

Voice Directions (200=)

Speak a destination and get turn-by-turn directions displayed on the calculator screen:

  1. Type 200= — countdown (5, 4, 3, 2, 1) while recording your voice
  2. Speak your destination (e.g., "How do I get to 555 Main Street?")
  3. Gemini processes the audio + your GPS location
  4. Directions appear as short steps: R 200ft, L 0.3mi, STR 500ft, DEST
  5. Press = to cycle through steps, AC to exit

Audio Recording (300=)

Silently starts recording audio in the background. Recordings are saved locally and uploaded to Firebase Cloud Storage for safekeeping. View and play back recordings from the settings dashboard.

Fake Call (400=)

Displays a realistic incoming call screen with:

  • Customizable caller name (default: "Mom")
  • Phone vibration pattern
  • Answer/Decline buttons
  • AI-generated voice conversation (via ElevenLabs) when answered
  • Call timer display

Safe Check-in (500=)

Sends a simple "I'm safe. Just checking in." email to all contacts.

Fake Shutdown (600=)

Screen goes completely black, making it appear the phone has shut off. The status bar is hidden. Background recording continues to run. Triple-tap anywhere to exit back to the calculator.

Stop All (700=)

Immediately stops all active recording. Uploads any recorded audio to Firebase Storage.

Setup

Prerequisites

  • Node.js 18+
  • Expo CLI
  • Firebase CLI
  • API keys for: Firebase, Google Gemini, ElevenLabs

App Configuration

  1. Copy the example keys file:
    cp src/config/keys.example.ts src/config/keys.ts
  2. Fill in your API keys in src/config/keys.ts

Firebase Functions Configuration

  1. Copy the example env file:
    cp firebase/functions/.env.example firebase/functions/.env
  2. Fill in your Gmail credentials in firebase/functions/.env

Running Locally

# Install dependencies
npm install

# Start the Expo dev server
npx expo start

# Run tests
npx jest --verbose

Deploying Cloud Functions

cd firebase/functions
npm install
firebase login
firebase deploy --only functions

Project Structure

JCM/
  App.tsx                          # Root component, screen routing, code detection
  app.json                         # Expo config with permissions
  firebase.json                    # Firebase deployment config
  firebase/
    functions/
      index.ts                     # Cloud Functions (sendEmergencyAlert, sendLocationUpdate)
      .env                         # Gmail credentials (gitignored)
      .env.example                 # Template for .env
  src/
    config/
      keys.ts                      # API keys (gitignored)
      keys.example.ts              # Template for keys.ts
    screens/
      CalculatorScreen.tsx         # Main calculator UI
      DashboardScreen.tsx          # Hidden settings (contacts, codes, messages)
      RecordingsScreen.tsx         # Audio recordings viewer with playback
      FakeCallScreen.tsx           # Fake incoming call with ElevenLabs voice
      FakeShutdownScreen.tsx       # Black screen with triple-tap exit
    components/
      calculator/
        Button.tsx                 # iOS-style round calculator button
        Display.tsx                # Auto-shrinking number display
        Keypad.tsx                 # Standard calculator layout
      dashboard/
        ContactCard.tsx            # Emergency contact editor
        CodeEditor.tsx             # Secret code editor row
    services/
      calculator.ts               # Calculator engine with input buffer for code detection
      codeDetection.ts            # Code matching (first-launch map vs full map)
      storage.ts                   # Encrypted storage (expo-secure-store)
      firebase.ts                  # Firebase init, recording upload
      sms.ts                       # Email alerts via Firebase Cloud Functions
      emergency.ts                 # Orchestrates all safety actions
      gemini.ts                    # Gemini AI (messages, directions, transcription)
      elevenlabs.ts                # ElevenLabs voice synthesis
      location.ts                  # GPS location
      recording.ts                 # Audio recording (expo-av)
    hooks/
      useCalculator.ts             # Calculator state management hook
    constants/
      codes.ts                     # Default codes and fixed settings code
      config.ts                    # App configuration
      theme.ts                     # Calculator and dashboard themes
    types/
      index.ts                     # TypeScript type definitions
    __tests__/
      calculator.test.ts           # 31 calculator engine tests
      codeDetection.test.ts        # 24 code detection tests

Testing Notes

  • The settings code 100= is always active, even before first setup.
  • On first launch, only 100= works. All other codes activate after saving settings.
  • The calculator functions normally for math at all times.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages