<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rahul kumar</title>
    <description>The latest articles on DEV Community by rahul kumar (@rahulshiraj).</description>
    <link>https://dev.to/rahulshiraj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3974321%2Ffe3e391a-bc6a-42b7-b833-aae3b00a1fcc.png</url>
      <title>DEV Community: rahul kumar</title>
      <link>https://dev.to/rahulshiraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahulshiraj"/>
    <language>en</language>
    <item>
      <title>Building a Local-First Flutter App with Drift, SQLCipher, and Riverpod 3.0</title>
      <dc:creator>rahul kumar</dc:creator>
      <pubDate>Mon, 06 Jul 2026 17:56:42 +0000</pubDate>
      <link>https://dev.to/rahulshiraj/building-a-local-first-flutter-app-with-drift-sqlcipher-and-riverpod-30-1k6p</link>
      <guid>https://dev.to/rahulshiraj/building-a-local-first-flutter-app-with-drift-sqlcipher-and-riverpod-30-1k6p</guid>
      <description>&lt;p&gt;Building local-first apps is becoming the standard for modern mobile developers. Users expect high performance, offline functionality, and strict privacy controls over their personal data.&lt;/p&gt;

&lt;p&gt;In this article, we will look at the core architecture patterns for building a secure, offline-first application in Flutter using &lt;strong&gt;Drift&lt;/strong&gt; (SQLite), &lt;strong&gt;SQLCipher&lt;/strong&gt; (local database encryption), and the new &lt;strong&gt;Riverpod 3.0&lt;/strong&gt; code generator.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Security Challenge
&lt;/h3&gt;

&lt;p&gt;For health, fitness, or financial logs, storing raw text on a device is a vulnerability. If a device is compromised, database files can be easily extracted. &lt;/p&gt;

&lt;p&gt;To solve this, we initialize &lt;code&gt;Drift&lt;/code&gt; on top of an encrypted database connection using &lt;code&gt;SQLCipher&lt;/code&gt;. Here is the conceptual flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve a secure key (e.g., from Flutter Secure Storage).&lt;/li&gt;
&lt;li&gt;Open the SQLite database connection using &lt;code&gt;EncryptedDatabase&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Generate Drift tables automatically using &lt;code&gt;@DriftDatabase&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  State Management with Riverpod 3.0
&lt;/h3&gt;

&lt;p&gt;We decouple UI from logic using Riverpod's new generator syntax. For example, to track the active workout state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nd"&gt;@riverpod&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ActiveWorkout&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;_$ActiveWorkout&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;WorkoutState&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;WorkoutState&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;startWorkout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WorkoutPlan&lt;/span&gt; &lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WorkoutState&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get the Complete Source Boilerplate
&lt;/h3&gt;

&lt;p&gt;If you want to skip the configuration hassle and start coding features immediately, I have packaged my complete production-grade codebase—including full Gemini AI integration, localizations (English, Hindi, Marathi), a 3D body mapper UI layout, and a pre-seeded database of 1,000+ exercises:&lt;/p&gt;

&lt;p&gt;👉 COMPLETE STARTER KIT: &lt;a href="https://rahulsaroh.gumroad.com/l/sovgjy" rel="noopener noreferrer"&gt;https://rahulsaroh.gumroad.com/l/sovgjy&lt;/a&gt;&lt;br&gt;
Use launch coupon code &lt;strong&gt;LAUNCH30&lt;/strong&gt; for 30% off!&lt;/p&gt;

&lt;p&gt;You can download and check app on play store too..&lt;br&gt;
&lt;a href="https://play.google.com/store/apps/details?id=com.aigymmentor.app" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.aigymmentor.app&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>database</category>
      <category>security</category>
    </item>
    <item>
      <title>How I Built an Offline-First AI Gym App in Flutter with SQLCipher + Gemini AI</title>
      <dc:creator>rahul kumar</dc:creator>
      <pubDate>Mon, 08 Jun 2026 14:10:17 +0000</pubDate>
      <link>https://dev.to/rahulshiraj/how-i-built-an-offline-first-ai-gym-app-in-flutter-with-sqlcipher-gemini-ai-g5h</link>
      <guid>https://dev.to/rahulshiraj/how-i-built-an-offline-first-ai-gym-app-in-flutter-with-sqlcipher-gemini-ai-g5h</guid>
      <description>&lt;blockquote&gt;
&lt;h2&gt;
  
  
  The Problem I Was Solving
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most fitness apps sync your health data to the cloud. I wanted an app where everything stays on-device — encrypted and private. No subscriptions, no cloud dependency.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;AI Gym Mentor&lt;/strong&gt; in Flutter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Architecture
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Encrypted Local Database with Drift + SQLCipher
&lt;/h3&gt;

&lt;p&gt;The biggest technical challenge was implementing encrypted local storage. I used &lt;strong&gt;Drift&lt;/strong&gt; (formerly Moor) as the ORM and &lt;strong&gt;SQLCipher&lt;/strong&gt; for encryption on top of SQLite.&lt;/p&gt;

&lt;p&gt;This means all workout logs, body measurements, and user data are AES-256 encrypted on-device.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Google Gemini AI Integration
&lt;/h3&gt;

&lt;p&gt;I integrated the &lt;strong&gt;Gemini AI&lt;/strong&gt; API to provide real-time coaching. After a workout, the app sends your session data to Gemini and returns personalized feedback, recovery suggestions, and progression advice.&lt;/p&gt;

&lt;p&gt;The key was keeping the prompt context tight — sending only relevant recent session data rather than the full history.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Riverpod 3.0 State Management
&lt;/h3&gt;

&lt;p&gt;The app uses &lt;strong&gt;Riverpod 3.0&lt;/strong&gt; with annotated generators for clean, scalable state management. This was essential given the complexity of syncing Wear OS data, chart state, and AI responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Full Tech Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Flutter 3.22+ (iOS, Android, Web)&lt;/li&gt;
&lt;li&gt;Riverpod 3.0 (Annotated Generators)&lt;/li&gt;
&lt;li&gt;Drift + SQLCipher (encrypted local DB)&lt;/li&gt;
&lt;li&gt;Google Gemini AI&lt;/li&gt;
&lt;li&gt;GoRouter 17.2+&lt;/li&gt;
&lt;li&gt;Wear OS sync&lt;/li&gt;
&lt;li&gt;fl_chart for analytics (1RM, volume, body measurements)&lt;/li&gt;
&lt;li&gt;Lottie + Shimmer animations&lt;/li&gt;
&lt;li&gt;1,000+ exercise database&lt;/li&gt;
&lt;li&gt;Multi-language: English, Hindi, Marathi&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why I Packaged It as a Template
&lt;/h2&gt;

&lt;p&gt;After finishing the app, I realized it had taken months to build all these pieces together correctly. The SQLCipher setup alone took days. The Gemini integration required multiple iterations.&lt;/p&gt;

&lt;p&gt;So I packaged the complete source code as a developer template — &lt;strong&gt;AI Gym Mentor&lt;/strong&gt; — so other developers can build on top of it instead of starting from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Included
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Complete, buildable Flutter source code&lt;/li&gt;
&lt;li&gt;README with full setup guide&lt;/li&gt;
&lt;li&gt;Seeded exercise database (exercises.json)&lt;/li&gt;
&lt;li&gt;.env.example for Gemini API key setup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The template is available here: &lt;a href="https://rahulsaroh.gumroad.com/l/sovgjy" rel="noopener noreferrer"&gt;https://rahulsaroh.gumroad.com/l/sovgjy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Launch price: &lt;strong&gt;$29&lt;/strong&gt;. Use code &lt;strong&gt;LAUNCH30&lt;/strong&gt; for 30% off (first 10 buyers).&lt;/p&gt;

&lt;h2&gt;
  
  
  Happy to Discuss
&lt;/h2&gt;

&lt;p&gt;If you have questions about the SQLCipher + Drift setup, the Gemini integration pattern, or the Riverpod architecture — drop a comment below!&lt;/p&gt;

</description>
      <category>flutter</category>
    </item>
  </channel>
</rss>
