|
| 1 | +--- |
| 2 | +title: Fact Dynamics |
| 3 | +description: A Flutter app for real-time fact-checking of debate, speech and images uses Perplexity's Sonar API. |
| 4 | +sidebar_position: 2 |
| 5 | +keywords: [Sonar API, Flutter, Dart, fact‑checking, hackathon, real-time, speech-to-text, image-verification] |
| 6 | +--- |
| 7 | + |
| 8 | +# Fact Dynamics |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <img |
| 12 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/icon/icon.png" |
| 13 | + alt="Fact Dynamics logo" |
| 14 | + width="80" |
| 15 | + height="80" |
| 16 | + style="border-radius: 14px;" |
| 17 | + /> |
| 18 | +</p> |
| 19 | + |
| 20 | +Fact Dynamics is a cross‑platform Flutter application that leverages Perplexity's Sonar API to provide real‑time fact‑checking for spoken and visual content—perfect for debates, presentations, or on‑the‑fly image verification. Built as a Perplexity Hackathon submission in the Information Tools & Deep Research & Education categories. |
| 21 | + |
| 22 | +## Features |
| 23 | + |
| 24 | +- **Real‑time Speech Analysis** - Transcribes live audio (via `speech_to_text`) and fact‑checks each snippet instantly |
| 25 | +- **Image Fact Verification** - Extracts text from images and verifies claims on‑device |
| 26 | +- **Claim Rating System** - Classifies claims as **TRUE**, **FALSE**, **MISLEADING**, or **UNVERIFIABLE** |
| 27 | +- **Source Citations** - Surfaces authoritative URLs backing each verdict |
| 28 | +- **User Authentication** - Firebase Auth (Google & Email) with secure Firestore persistence |
| 29 | +- **Debate Mode** - Continuous speech recognition with streaming feedback |
| 30 | +- **Cross‑platform** - iOS, Android, Web (macOS testing; Windows coming soon) |
| 31 | + |
| 32 | +## Prerequisites |
| 33 | + |
| 34 | +- Flutter SDK installed on your development machine |
| 35 | +- Firebase account for authentication and data persistence |
| 36 | +- Perplexity Sonar API key |
| 37 | +- Device with microphone access for speech recognition |
| 38 | +- Camera access for image capture (optional) |
| 39 | + |
| 40 | +## Installation |
| 41 | + |
| 42 | +1. **Clone the repository** |
| 43 | + ```bash |
| 44 | + git clone https://github.com/vishnu32510/fact_pulse.git |
| 45 | + cd fact_pulse |
| 46 | + ``` |
| 47 | + |
| 48 | +2. **Install Flutter dependencies** |
| 49 | + ```bash |
| 50 | + flutter pub get |
| 51 | + ``` |
| 52 | + |
| 53 | +3. **Configure Firebase for your platform** |
| 54 | + - Create a Firebase project at [Firebase Console](https://console.firebase.google.com/) |
| 55 | + - Enable Authentication (Google, Email) and Firestore Database |
| 56 | + - Install and configure FlutterFire CLI: |
| 57 | + ```bash |
| 58 | + dart pub global activate flutterfire_cli |
| 59 | + flutterfire configure |
| 60 | + ``` |
| 61 | + - Follow the prompts to select your Firebase project and platforms (iOS/Android/Web) |
| 62 | + |
| 63 | +4. **Set up API key** |
| 64 | + - Create a `.env` file in the project root (use `.env.template` as reference) |
| 65 | + - Add your Perplexity Sonar API key: |
| 66 | + ``` |
| 67 | + PERPLEXITY_API_KEY=your_api_key_here |
| 68 | + ``` |
| 69 | + |
| 70 | +5. **Configure platform permissions** |
| 71 | + - For Android: Microphone and camera permissions are configured in `android/app/src/main/AndroidManifest.xml` |
| 72 | + - For iOS: Permissions are configured in `ios/Runner/Info.plist` |
| 73 | + |
| 74 | +6. **Run the application** |
| 75 | + ```bash |
| 76 | + flutter run |
| 77 | + ``` |
| 78 | + |
| 79 | +## Usage |
| 80 | + |
| 81 | +### Demo & Screenshots |
| 82 | + |
| 83 | +- [Watch the demo video](https://youtu.be/92IoX19Djtc) |
| 84 | +- [Web Demo](https://fact-pulse.web.app/) |
| 85 | + |
| 86 | +<table> |
| 87 | + <tr> |
| 88 | + <td> |
| 89 | + <img |
| 90 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/screenshots/1.%20Login.png" |
| 91 | + alt="Login screen" |
| 92 | + width="200" |
| 93 | + /> |
| 94 | + </td> |
| 95 | + <td> |
| 96 | + <img |
| 97 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/screenshots/2.%20Dashboard.png" |
| 98 | + alt="Dashboard" |
| 99 | + width="200" |
| 100 | + /> |
| 101 | + </td> |
| 102 | + <td> |
| 103 | + <img |
| 104 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/screenshots/5.%20Profile.png" |
| 105 | + alt="Profile screen" |
| 106 | + width="200" |
| 107 | + /> |
| 108 | + </td> |
| 109 | + </tr> |
| 110 | +</table> |
| 111 | + |
| 112 | +<table> |
| 113 | + <tr> |
| 114 | + <td> |
| 115 | + <img |
| 116 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/screenshots/3.%20Facts%20Checked%20List(Speech,%20Debate,%20Image).png" |
| 117 | + alt="Facts checked list" |
| 118 | + width="300" |
| 119 | + /> |
| 120 | + </td> |
| 121 | + <td> |
| 122 | + <img |
| 123 | + src="https://raw.githubusercontent.com/vishnu32510/fact_pulse/main/assets/screenshots/4.%20Fact%20Checks(Speech,%20Debate,%20Image).png" |
| 124 | + alt="Fact checks screen" |
| 125 | + width="300" |
| 126 | + /> |
| 127 | + </td> |
| 128 | + </tr> |
| 129 | +</table> |
| 130 | + |
| 131 | +1. **Authentication**: Sign in with Google or email through Firebase Auth |
| 132 | +2. **Speech Mode**: Tap the microphone to start real-time speech transcription and fact-checking |
| 133 | +3. **Image Mode**: Upload an image or provide a URL to extract and verify text claims |
| 134 | +4. **Debate Mode**: Enable continuous speech recognition for live debate fact-checking |
| 135 | +5. **View Results**: Check claim ratings, explanations, and source citations |
| 136 | + |
| 137 | +## Code Explanation |
| 138 | + |
| 139 | +### Perplexity Sonar API Integration |
| 140 | + |
| 141 | +The app integrates with Perplexity's Sonar API in two main ways: |
| 142 | + |
| 143 | +1. **Debate Fact‑Checking** |
| 144 | + - Stream 5‑second audio chunks → transcribe → send `textSnippet` to Sonar |
| 145 | + - Parse JSON response for `{ claim, rating, explanation, sources }` |
| 146 | + |
| 147 | +2. **Image Analysis** |
| 148 | + - Upload or URL‑point to image → Sonar extracts on‑image text → verify each claim |
| 149 | + |
| 150 | +```dart |
| 151 | +final client = PerplexityClient(apiKey: env.SONAR_API_KEY); |
| 152 | +final response = await client.analyzeClaim(textSnippet); |
| 153 | +print('Rating: ${response.rating}, Confidence: ${response.confidence}'); |
| 154 | +``` |
| 155 | + |
| 156 | +The app processes audio in real-time, transcribes it using Flutter's speech-to-text package, and sends each snippet to the Sonar API for immediate fact verification with source citations. |
| 157 | + |
| 158 | +### Custom SDKs Used |
| 159 | + |
| 160 | +This project uses custom-built Perplexity API SDKs developed specifically for this hackathon: |
| 161 | +- **perplexity_dart** - Core Dart SDK ([pub.dev](https://pub.dev/packages/perplexity_dart), [docs](perplexity-flutter)) |
| 162 | +- **perplexity_flutter** - Flutter widgets and utilities ([pub.dev](https://pub.dev/packages/perplexity_flutter), [docs](perplexity-flutter)) |
| 163 | + |
| 164 | +## Links |
| 165 | + |
| 166 | +- [GitHub Repository](https://github.com/vishnu32510/fact_pulse) |
| 167 | +- [Live Demo](https://fact-pulse.web.app/) |
| 168 | +- [Devpost Submission](https://devpost.com/software/fact-dynamics) |
| 169 | +- [Demo Video](https://youtu.be/92IoX19Djtc) |
| 170 | + |
| 171 | +## Limitations |
| 172 | + |
| 173 | +- Speech recognition accuracy depends on audio quality and background noise |
| 174 | +- Fact-checking is limited to claims that can be verified through available online sources |
| 175 | +- Image text extraction quality varies based on image resolution and text clarity |
| 176 | +- Real-time processing may experience latency depending on network connectivity |
| 177 | +- Cross-platform compatibility is still being tested for macOS and Windows |
| 178 | +- API rate limits may affect continuous usage in high-volume scenarios |
| 179 | +- Android microphone access permissions need to be added for long duration listening |
0 commit comments