Offline Mode
Offline Mode - 100% Available
Civix is designed to work 100% offline. Users can study for their citizenship test anytime, anywhere, without requiring an internet connection.
Offline-First Architecture
Core Principle
All essential features work without internet. Data is stored locally first, with optional cloud sync in the future.
Data Storage
AsyncStorage (Local)
├── User Settings (language, theme, test date)
├── Question Stats (SM-2 algorithm data)
├── Practice Results (session history)
├── Gamification (XP, level, badges, streak)
├── Favorites (bookmarked questions)
└── Premium Status (cached from RevenueCat)
Feature Availability
| Feature | Offline | Online |
|---|---|---|
| Quiz Mode | Yes | Yes |
| Practice Mode | Yes | Yes |
| Mock Interview | Yes | Yes |
| Speaking Practice | Yes | Yes |
| Reading Practice | Yes | Yes |
| Writing Practice | Yes | Yes |
| 128 Questions | Yes | Yes |
| SM-2 Algorithm | Yes | Yes |
| XP & Levels | Yes | Yes |
| Badges | Yes | Yes |
| Daily Streak | Yes | Yes |
| Progress Tracking | Yes | Yes |
| Settings | Yes | Yes |
| AI Interview | No* | Yes |
| Purchase/Restore | No | Yes |
*AI Interview falls back to local Mock Interview when offline.
Technical Implementation
Network Detection
// lib/offline.ts
import * as Network from 'expo-network';
export async function checkNetworkStatus() {
const state = await Network.getNetworkStateAsync();
return {
isConnected: state.isConnected,
isInternetReachable: state.isInternetReachable,
type: state.type,
};
}
React Hook
// Usage in components
import { useNetworkStatus } from '@/lib/offline';
function MyComponent() {
const { isOffline, isConnected } = useNetworkStatus();
if (isOffline) {
// Handle offline state
}
}
Offline Indicator
The app shows a non-intrusive banner when offline:
- Blue banner at top of screen
- "Offline Mode - 100% Available" message
- Auto-expands on first offline detection
- Tap to see detailed message
Question Bank
All 128 USCIS 2025 Civics Test questions are bundled with the app:
lib/bank/
├── en.ts # 128 English questions
├── fa.ts # Farsi translations (future)
├── ps.ts # Pashto translations (future)
└── index.ts
No Network Required
- Questions are compiled into the app bundle
- Zero API calls needed to fetch questions
- Works immediately after install
Senior/State-Dependent Handling Offline
- Senior practice/exam mode remains strictly in the senior 65/20 pool.
- State-dependent civics items (for example governor/senator prompts) are only prioritized when local
stateProfiledata exists. - If state profile data is missing, the algorithm prioritizes evaluatable senior questions to avoid dead-end prompts.
State Persistence
Using Zustand with AsyncStorage middleware:
// store/useAppStore.ts
import { persist } from 'zustand/middleware';
import AsyncStorage from '@react-native-async-storage/async-storage';
const useAppStore = create(
persist(
(set, get) => ({
// All state here
}),
{
name: 'civix-store',
storage: createJSONStorage(() => AsyncStorage),
}
)
);
Persisted Data
lang- Selected languagetheme- Light/Dark mode preferencetestDate- User's test datequestionStatsV2- SM-2 algorithm stats per questionpracticeResults- All session historyxp,dailyStreak,badges- Gamificationfavorites- Bookmarked question IDsisUnlocked- Premium status (cached)
Offline Graceful Degradation
AI Interview
When offline:
- Detect no connection
- Show "Use Mock Interview for offline practice"
- Mock Interview works with local questions
- Full interview simulation available
Purchases
When offline:
- Use cached premium status
- Show "Purchases require internet"
- Restore button disabled
- Features based on last known status
Files Created
| File | Purpose |
|---|---|
lib/offline.ts | Network status detection, offline utilities |
components/OfflineIndicator.tsx | UI banner for offline state |
docs/OFFLINE-MODE.md | This documentation |
Testing Offline Mode
Simulator/Emulator
- iOS: Features > Toggle In-Call Status Bar (doesn't simulate offline)
- Better: Use Network Link Conditioner
- Android: Settings > Network > Airplane Mode
Physical Device
- Enable Airplane Mode
- Launch app
- Verify all features work
- Check offline indicator appears
Test Checklist
- App launches offline
- Quiz works offline
- Practice works offline
- Mock Interview works offline
- Progress saves offline
- XP/Levels work offline
- Settings persist offline
- Offline indicator shows
- No crashes or errors
Future Enhancements
Cloud Sync (Not Implemented)
Future: Optional cloud backup
├── Sync progress across devices
├── Backup question stats
├── Restore on new device
└── Requires user account
Dynamic Content Updates (Not Implemented)
Future: Update current officials
├── President, VP, Speaker changes
├── Fetch when online
├── Cache locally
└── Use cached if offline
Key Points for Users
-
Download Once, Use Anywhere
- All 128 questions included
- No internet needed after install
-
Progress Always Saved
- XP, levels, badges saved locally
- Never lose your progress
-
Study Anywhere
- On airplane, subway, remote areas
- Full functionality offline
-
AI Features Need Internet
- AI Interview requires connection
- Mock Interview works offline as alternative
100% Offline - Because citizenship prep shouldn't depend on WiFi.