Skip to content

Cross-platform Flutter app for Readmigo - AI-powered English reading companion with native C++ typesetting engine

License

Notifications You must be signed in to change notification settings

readmigo/flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter 3.41 Dart 3.11 C++17 License: MIT CI Status

Readmigo Flutter

Read English classics with AI-powered assistance - a cross-platform Flutter app featuring a native C++ typesetting engine for book-quality text rendering.

Readmigo helps readers improve their English by providing AI-assisted reading of classic literature from Standard Ebooks, with features like vocabulary building, inline translations, and audiobook listening.


Highlights

  • Native C++ Typesetting Engine - Shared cross-platform engine via FFI for pixel-perfect text layout with hyphenation, justified text, and typography features
  • Canvas-Based Rendering - Direct CustomPainter rendering (no WebView) for smooth 60fps page turns
  • 1,200+ Classic Books - Curated library from Standard Ebooks with Goodreads ratings
  • AI Reading Assistant - Context-aware word lookup, sentence translation, and vocabulary building
  • Audiobook Support - TTS-powered audiobooks with synchronized highlighting
  • Global + China - Dual build variants with --dart-define for different app stores

Architecture

readmigo/flutter
├── lib/
│   ├── app/                    # App entry, router, themes
│   │   ├── app.dart            # Root MaterialApp with Riverpod
│   │   ├── router.dart         # GoRouter with 4-tab shell navigation
│   │   └── theme/              # Material 3 theming (light/dark/sepia)
│   ├── core/
│   │   ├── config/             # Environment & build configuration
│   │   ├── network/            # Dio HTTP client + JWT auth interceptor
│   │   ├── storage/            # Secure token storage
│   │   ├── localization/       # 11-language i18n support
│   │   └── typesetting/        # C++ FFI bindings & Dart engine wrapper
│   ├── features/               # Feature modules
│   │   ├── reader/             # Book reader with Canvas rendering
│   │   ├── library/            # Personal book library
│   │   ├── bookstore/          # Book discovery & recommendations
│   │   ├── audiobook/          # Audiobook playback
│   │   ├── auth/               # Apple/Google/Email sign-in
│   │   ├── vocabulary/         # SRS vocabulary review
│   │   ├── search/             # Book & content search
│   │   ├── subscription/       # IAP subscription management
│   │   ├── quotes/             # Highlighted quotes collection
│   │   ├── settings/           # App preferences
│   │   ├── profile/            # User profile
│   │   └── analytics/          # Event tracking (Sentry + PostHog)
│   ├── models/                 # Data models (Book, User, Chapter, etc.)
│   └── shared/                 # Shared widgets & extensions
├── native/
│   ├── typesetting/            # Symlink → shared C++ engine
│   ├── c_api/                  # C wrapper for FFI (extern "C")
│   └── CMakeLists.txt          # Native build configuration
└── .github/
    └── workflows/              # CI/CD pipelines

Typesetting Engine

The core differentiator is a shared C++ typesetting engine (~3,500 lines, zero external dependencies) that performs book-quality text layout:

┌─────────────────────────────────────────────────────┐
│                   Flutter App                        │
│  ┌──────────────┐    ┌────────────────────────────┐ │
│  │ PageCanvas    │    │ TypesettingEngine (Dart)   │ │
│  │ CustomPainter │◄───│ NativeCallable callbacks   │ │
│  └──────────────┘    └─────────┬──────────────────┘ │
│                                │ dart:ffi            │
├────────────────────────────────┼─────────────────────┤
│  C API Layer (extern "C")      │                     │
│  typesetting_c_api.h/cpp       │                     │
├────────────────────────────────┼─────────────────────┤
│  C++ Typesetting Engine        │                     │
│  ┌──────────┐ ┌──────────┐ ┌──┴───────┐            │
│  │ HTML     │ │ Line     │ │ Platform │            │
│  │ Parser   │ │ Breaker  │ │ Adapter  │            │
│  └──────────┘ └──────────┘ └──────────┘            │
└─────────────────────────────────────────────────────┘

Key capabilities:

  • HTML/CSS parsing for ebook content
  • Knuth-Plass line breaking with hyphenation
  • Justified text alignment
  • Small caps, drop caps, and decorative elements
  • Platform-agnostic via callback-based PlatformAdapter

The same engine powers the Android app via JNI and will power the iOS app in a future migration.

Tech Stack

Category Technology
Framework Flutter 3.41 / Dart 3.11
State Management Riverpod 2.x with code generation
Routing GoRouter with StatefulShellRoute
Networking Dio with JWT auth interceptor
Native Engine C++17 via dart:ffi + NativeCallable
Rendering CustomPainter with ui.ParagraphBuilder
Auth Sign in with Apple, Google Sign-In
Storage Hive (local), flutter_secure_storage (tokens)
Audio just_audio + audio_service
IAP in_app_purchase
Analytics Sentry + PostHog
Serialization Freezed + json_serializable
i18n Flutter intl (11 languages)

Getting Started

Prerequisites

  • Flutter SDK 3.41+ (flutter --version)
  • Xcode 16+ (for iOS)
  • Android Studio / Android SDK (for Android)
  • C++ compiler (for native engine)

Setup

# Clone with submodules (for C++ engine)
git clone --recursive https://github.com/readmigo/flutter.git
cd flutter

# Install dependencies
flutter pub get

# Run code generation
dart run build_runner build

# Run on device
flutter run

Build Variants

# Global version (Google Play / App Store)
flutter run --dart-define=STORE=global

# China version (Chinese app stores)
flutter run --dart-define=STORE=china

Build for Release

# Android APK
flutter build apk --release --dart-define=STORE=global

# Android App Bundle
flutter build appbundle --release --dart-define=STORE=global

# iOS
flutter build ios --release --dart-define=STORE=global

# Web
flutter build web --release

CI/CD

Workflow Trigger Description
CI Push/PR to main, develop Analyze, test, build Android/iOS/Web
Release Android Tag v* Build signed APK + AAB, create GitHub Release
Release iOS Tag v* Build signed IPA with provisioning
Deploy Web Push to main Build and deploy to GitHub Pages
Dependency Review PR with pubspec changes Check for outdated/conflicting packages
Dependabot Weekly (Monday) Auto-update Dart packages and GitHub Actions

Required Secrets (for release workflows)

Android:

  • KEYSTORE_BASE64 - Base64-encoded release keystore
  • KEY_STORE_PASSWORD, KEY_PASSWORD, KEY_ALIAS

iOS:

  • P12_BASE64 - Base64-encoded signing certificate
  • P12_PASSWORD - Certificate password
  • PROVISION_PROFILE_BASE64 - Provisioning profile
  • KEYCHAIN_PASSWORD - Temporary keychain password

API

The app communicates with the Readmigo API:

  • Base URL: https://api.readmigo.app/api/v1
  • Auth: JWT Bearer tokens with automatic refresh
  • 270+ endpoints covering books, library, reading progress, vocabulary, audio, subscriptions, and more

Related Projects

Project Description
readmigo/ios Native iOS app (Swift/SwiftUI)
readmigo/android Native Android app (Kotlin)
readmigo/typesetting Shared C++ typesetting engine
readmigo/api Backend API (Fly.io + Neon PostgreSQL)

License

This project is licensed under the MIT License - see the LICENSE file for details.


Readmigo - Making classic literature accessible to English learners worldwide

About

Cross-platform Flutter app for Readmigo - AI-powered English reading companion with native C++ typesetting engine

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors