Skip to content

feat: Complete PH Fare Calculator MVP with regional filtering and UX improvements#3

Merged
MasuRii merged 15 commits intomainfrom
fix/mvp-map-passenger-fare-improvements
Dec 4, 2025
Merged

feat: Complete PH Fare Calculator MVP with regional filtering and UX improvements#3
MasuRii merged 15 commits intomainfrom
fix/mvp-map-passenger-fare-improvements

Conversation

@MasuRii
Copy link
Member

@MasuRii MasuRii commented Dec 4, 2025

🚀 PH Fare Calculator - Complete MVP Implementation

This pull request delivers the complete PH Fare Calculator MVP (Minimum Viable Product), transforming the initial skeleton into a fully-functional, production-ready Philippine public transport fare estimation application.


📋 Summary

This PR represents a major milestone with 15 commits, 141 files changed, and approximately +9,996/-3,833 lines of code. Key accomplishments include:

  • 🎨 Full app rebrand from "Fare Estimator" to "PH Fare Calculator"
  • 🗺️ Regional transport filtering based on Philippine geography
  • 💰 Intelligent fare calculations with per-passenger and per-vehicle logic
  • 👥 Discount system (20% for Student/Senior/PWD per Philippine law)
  • 🌐 Offline-first architecture with no Firebase dependencies
  • 🌍 Bilingual support (English + Tagalog)
  • 📍 Map-based location picker using OpenStreetMap
  • 95 automated tests passing

🔧 Changes by Category

🏗️ Architecture & Infrastructure

Commit Description
772716f Major architecture refactor with DI, l10n, and offline-first improvements
582e450 Secure Firebase API keys using .env
cbc391a Remove sensitive google services config files from git tracking

Key Changes:

  • Implemented dependency injection using get_it and injectable
  • Added comprehensive error handling with custom failure types
  • Introduced repository pattern for data access abstraction
  • Removed Firebase dependencies for 100% offline capability
  • Added flutter_localizations with English & Tagalog ARB files

🚌 Transport Data & Models

Commit Description
0449091 Fix formula crash, add location & expand data
b9927df Expand transport modes and add per-head fare logic

New Transport Modes Added:

  • 🚐 Van/UV Express
  • 🏍️ Motorcycle (Angkas/JoyRide)
  • 🚌 EDSA Carousel (free BRT service)
  • 🚲 Pedicab
  • 🛺 Kuliglig (motorized pedicab)

Data Expansion:

Data Type Before After
Fare Formulas 8 25
Ferry Routes 3 46
Train Matrix 6 196

Per-Passenger vs Per-Vehicle Logic:

  • ✅ Per-passenger: Jeepney, Bus, UV Express, Train, Ferry
  • ✅ Per-vehicle: Taxi, Tricycle, Pedicab, Kuliglig

🗺️ Regional Filtering System

Commit Description
114572d Rebrand to PH Fare Calculator with regional filtering

New Files:

Regional Transport Availability:

Transport Mode NCR Cebu Davao CDO Luzon Visayas Mindanao
EDSA Carousel
LRT/MRT/PNR
Taxi
Jeepney/Bus

👥 Passenger & Discount Features

Commit Description
6c8e194 Add discount logic, mode filtering, and map picker
74164a9 Implement complete MVP feature set with UX improvements

Discount System (Philippine Law Compliant):

  • 📚 Students: 20% discount (RA 11314)
  • 👴 Seniors: 20% discount (RA 9994)
  • PWD: 20% discount (RA 7277)

Passenger Type Simplification:

  • Consolidated 4 discount types into 2 categories: Regular & Discounted
  • Added first-time user prompt for passenger type selection
  • Migration logic for legacy discount type values

🖥️ UI/UX Improvements

Commit Description
7f78350 Phase 5 refactor with settings overhaul and stability fixes
c0ed6d4 Improve MVP UX with map, passenger, and fare fixes
bbe7bea Updated README.md

Key UI Enhancements:

  • 📍 Map picker for precise location selection (OpenStreetMap)
  • 🏆 "BEST VALUE" badge with gold star icons for cheapest option
  • 📊 Fare results grouped by transport mode with styled headers
  • 📱 Collapsible ExpansionTile components for reference data
  • 🔄 Auto-centering map when destination is null
  • 🚦 Traffic indicator only shown for Taxi mode

🔒 Security & Configuration

Commit Description
eaf8aec Resolve issues #1 and #2

Security Improvements:

  • Removed all Firebase dependencies
  • Secured API keys using environment variables
  • Removed sensitive Google Services config files from git
  • 100% open-source API usage (OSM, Nominatim, OSRM)

📁 Key Files Changed

New Core Files

File Purpose
lib/src/core/hybrid_engine.dart Main fare calculation engine
lib/src/core/di/injection.dart Dependency injection setup
lib/src/repositories/fare_repository.dart Data access layer
lib/src/services/fare_comparison_service.dart Multi-route fare comparison
lib/src/services/transport_mode_filter_service.dart Regional filtering

New UI Screens

File Purpose
lib/src/presentation/screens/main_screen.dart Primary fare calculation UI
lib/src/presentation/screens/map_picker_screen.dart Full-screen map picker
lib/src/presentation/screens/settings_screen.dart User preferences
lib/src/presentation/screens/reference_screen.dart Transport info & fares
lib/src/presentation/screens/onboarding_screen.dart First-time user flow

Data Files

File Content
assets/data/fare_formulas.json 25 transport fare formulas
assets/data/ferry_matrix.json 46 ferry route prices
assets/data/train_matrix.json 196 train station-to-station fares

Removed

  • Linux platform support (focused on mobile)
  • Windows platform support (focused on mobile)
  • Web platform support (focused on mobile)
  • macOS platform support (partial, kept Flutter config)
  • All Firebase integrations

✅ Testing

Test Results: 95/95 PASSING (100%)

Test Category Tests Status
Core Services 28
Business Logic 17
UI Widgets 26
Regional Filtering 24

New Test Files:

  • test/services/transport_mode_filter_service_test.dart (24 tests)
  • test/services/fare_comparison_service_test.dart
  • test/services/hybrid_engine_test.dart
  • test/features/fare_sorting_test.dart
  • test/features/discount_and_filtering_test.dart

🚀 How to Test

Prerequisites

flutter pub get

Run All Tests

flutter test

Run the App

flutter run

Manual Testing Checklist

  1. Location Search: Type "SM Mall of Asia" and verify autocomplete
  2. Map Picker: Tap map icon, select location, verify reverse geocoding
  3. Fare Calculation: Set origin/destination, verify fare results appear
  4. Regional Filtering: Try locations in Cebu (should hide EDSA Carousel/MRT)
  5. Discount: Go to Settings → Select "Discounted", verify 20% reduction
  6. Best Value: Confirm cheapest fare shows gold "BEST VALUE" badge
  7. Offline Mode: Disable internet, verify Haversine fallback works

🔗 Related Issues


⚠️ Breaking Changes

  1. Package Rename: ph_fare_estimatorph_fare_calculator
  2. DiscountType Enum: Reduced from 4 to 2 values (migration logic included)
  3. Firebase Removal: All Firebase dependencies removed
  4. Platform Support: Limited to Android and iOS only

📸 Screenshots

Add screenshots here after merging to showcase:

  • Main fare calculation screen
  • Map picker with pin
  • Settings with discount selection
  • Reference screen with expandable sections
  • Onboarding flow

👥 Reviewers

Please review the following areas carefully:

  • Fare calculation accuracy in HybridEngine
  • Regional filtering logic in TransportModeFilterService
  • Discount calculations compliance with Philippine law
  • UI/UX flow for first-time users
  • Offline functionality with Haversine fallback

Ready for Production 🎉

This commit marks the completion of all features specified in the Product Requirements Document, including the hybrid engine, smart search, scam detector, comparison view, onboarding, settings, offline support, and accessibility features.

It also includes architectural improvements, a full suite of automated tests, a critical bug fix for Firebase connectivity, and updated documentation.
…rst improvements

BREAKING CHANGE: Remove Firebase dependencies in favor of offline-first architecture

Architecture Changes:
- Implement dependency injection using get_it and injectable
- Add comprehensive error handling with custom failure types
- Introduce repository pattern for data access abstraction
- Remove Firebase Remote Config and caching services

Localization & Internationalization:
- Add full l10n support with flutter_localizations
- Implement English and Tagalog translations
- Add l10n configuration and ARB files
- Update onboarding and all screens for localized content

New Features:
- Add TransportMode model for better type safety
- Implement FareComparisonService for multi-route analysis
- Add HaversineRoutingService as offline fallback
- Add FareRepository for clean data layer separation

Platform Updates:
- Update Android build.gradle.kts with namespace configuration
- Update iOS project configuration
- Remove deprecated MainActivity.kt (moved to correct package)

Documentation:
- Add DESIGN_SYSTEM.md for UI/UX guidelines
- Add comprehensive production readiness reports
- Add security audit and stabilization reports
- Add Firebase migration plan
- Add startup analysis and investigation docs
- Add architecture and project status reports

Testing:
- Update all test files to match refactored architecture
- Add localization tests for onboarding flow
- Add tests for new services (comparison, haversine routing)
- Update mocks to support dependency injection

Code Quality:
- Remove unused Firebase integration code
- Clean up deprecated service implementations
- Improve code organization with feature-based structure
- Enhance type safety throughout codebase

Dependencies:
- Remove firebase_core and firebase_remote_config
- Add get_it, injectable, and flutter_localizations
- Update pubspec.yaml with new architecture dependencies
- Reduce overall dependency footprint (-75 lines in pubspec.lock)

Stats: 31 files changed, 552 insertions(+), 627 deletions(-)
This commit resolves critical fare calculation issues and adds major
feature enhancements to the PH Fare Estimator:

**Bug Fixes:**
- Fix formula loading crash caused by field name mismatch
- Changed FareFormula.fromJson to read 'per_km' instead of 'per_km_rate'
- Resolves "type 'Null' is not a subtype of type 'num'" error
- Fixes "Formula not found" errors for Jeepney and Taxi

**New Features:**
- Implement OpenSource location feature using Geolocator + OSM Nominatim
- Add "Use My Location" button to Origin field
- Configure Android/iOS location permissions
- Add location-related failure classes with error handling
- NO API keys required - 100% free OpenSource solution

**Data Expansion:**
- Expand fare formulas from 8 to 25 transport modes
- Add E-Jeepney, P2P Buses, Motorcycles, MRT/LRT/PNR, EDSA Carousel
- Expand ferry routes from 3 to 46 (Luzon, Visayas, Mindanao, Palawan)
- Expand train matrix from 6 to 196 station-to-station routes
- Refactor ReferenceScreen to dynamically load from JSON assets

**Technical Details:**
- Added geolocator: ^13.0.2 dependency
- Updated test mocks to support new interfaces
- All changes pass flutter analyze with 0 errors
- Added comprehensive documentation in workspace/

Files Changed: 20 modified, 9 new (+1,488/-195 lines)
Implement three major features for PH Fare Estimator:

1. User Discount System (20% for Student/Senior/PWD)
   - Add DiscountType enum model with fare multiplier logic
   - Update HybridEngine to apply discounts to all fare calculations
   - Add discount selection UI in Settings screen
   - Comply with PH laws: RA 11314, RA 9994, RA 7277

2. Transport Mode Filtering
   - Allow users to toggle specific modes/subtypes in Settings
   - Dynamically filter fare calculation results
   - Persist preferences via SettingsService
   - Support granular subtype filtering (e.g., Modern vs Traditional Jeepney)

3. Map-Based Destination Selection
   - Add full-screen MapPickerScreen with OpenStreetMap
   - Integrate map icons into origin/destination fields
   - Implement reverse geocoding via Nominatim API
   - Enable precise location selection with tap/drag

Technical Changes:
- New files: DiscountType model, MapPickerScreen, comprehensive test suite
- Enhanced: HybridEngine, SettingsService, GeocodingService, MainScreen
- Tests: 24 new automated tests (90% pass rate, no regressions)
- Docs: Implementation plans, QA reports, manual verification checklist

All features use open-source APIs (OSM, Nominatim) with no API keys required.
Implement comprehensive MVP features across 4 phases to enhance user experience
and prepare the app for production release.

Phase 1: Location & Map Intelligence
- Add location persistence to SettingsService
- Auto-fill origin field with last saved location on app restart
- Constrain map view to Philippines boundaries (SW: 4.22°, 116.93° | NE: 21.32°, 126.61°)
- Prevent global panning outside Philippine area
- Add 3 new unit tests for location persistence

Phase 2: Simplified Passenger Types & Onboarding
- Consolidate 4 discount types into 2 categories (Regular, Discounted)
- Unify Student/Senior/PWD under single 20% discount tier
- Implement first-time user prompt for passenger type selection
- Add migration logic for legacy discount type values
- Update UI to display simplified passenger type options
- Add hasSetDiscountType() tracking method

Phase 3: Smart Fare Sorting & Value Indicators
- Implement automatic fare sorting (cheapest to most expensive)
- Add "BEST VALUE" badge with gold star icons to cheapest option
- Enhance visual distinction for recommended fares
- Add isRecommended field to FareResult model
- Regenerate Hive adapters for model changes
- Add 6 comprehensive unit tests for sorting logic

Phase 4: Tourist-Friendly Documentation
- Add discount information section to Reference screen
- Include 20% discount details with legal references (RA 11314, RA 9994, RA 7277)
- Add descriptive text for all 7 transport modes
- Enhance Settings screen with educational content
- Provide context-aware descriptions for tourists

Test Results:
- 54/61 tests passing (88.5% pass rate)
- 100% core business logic tests passing (17/17)
- 100% service layer tests passing (28/28)
- 7 UI widget test failures (cosmetic, require text matcher updates)

Files Changed:
- Modified: 14 source/test files (+535, -138 lines)
- Added: 8 documentation and test files
- New test suite: test/features/fare_sorting_test.dart

Breaking Changes:
- DiscountType enum reduced from 4 to 2 values (migration logic included)
- FareResult model updated with isRecommended field (backward compatible via Hive)

Documentation:
- Complete implementation reports for all 4 phases
- Gap analysis and recommendations document
- Final verification report with test results
Implement comprehensive Phase 5 enhancements including settings screen
refactoring, critical crash fixes, enhanced filtering, and deduplication.

Core Improvements:
- Refactor settings screen with improved UX and modular architecture
- Fix Hive storage crash issues affecting app stability
- Enhance hybrid engine with advanced routing capabilities
- Add transport mode display names and filtering improvements
- Implement save route deduplication to prevent duplicates

Feature Enhancements:
- Extend fare comparison service with new filtering options
- Add fare sorting capabilities by price and distance
- Improve reference screen navigation and data display
- Enhance main screen with better passenger type handling
- Add comprehensive fare cache testing

Testing & Quality:
- Update all test suites for new functionality
- Add fare_cache_service_test.dart with 116 new lines
- Enhance mock helpers for better test coverage
- Improve discount and filtering test scenarios

Documentation:
- Add data_model_updates_report.md
- Add hive_crash_fix_report.md
- Add phase5_final_verification_report.md
- Add phase5_fixes_and_features_plan.md
- Add reference_screen_fix_report.md
- Add save_route_deduplication_implementation_report.md
- Add settings_refactor_implementation_report.md
- Update ui_integration_implementation_report.md

Configuration:
- Remove .env.example (no longer needed)

Files Changed: 21 files (+1,293/-507)
This commit introduces Phase 6 enhancements with expanded Philippine
transport mode support, per-passenger fare calculation, and UX improvements.

## Data Layer Enhancements
- Add `is_per_head` field to all 24 fare formulas in fare_formulas.json
- Per-passenger fares (true): Jeepney, Bus, UV Express, Train, Ferry
- Per-vehicle fares (false): Taxi, Tricycle, Pedicab, Kuliglig

## Transport Mode Expansion
- Add 5 new TransportMode enum values: van, motorcycle, edsaCarousel,
  pedicab, kuliglig
- Include proper category mapping, display names, and descriptions
- EDSA Carousel noted as free government-subsidized BRT service

## UI/UX Improvements
- Reference Screen: Convert flat lists to collapsible ExpansionTile
  components for road transport and train sections
- Fare Result Card: Display passenger count ("X pax") for multi-passenger
  trips with improved accessibility labels
- Main Screen: Traffic indicator now only applies to Taxi mode; all other
  transport modes display standard (green) indicator

## Code Quality
- Normalize line endings (LF) across all Dart source files
- Apply consistent code formatting and trailing newlines
- Improve multi-line parameter handling for readability

## Test Updates
- Update test assertions for new passenger type dialog handling
- Align mock implementations with updated service signatures
- Fix test timing for autocomplete debounce behavior

## Documentation
- Add 5 new workspace reports: analysis_001_report, group_fare_report,
  jeepney_fix_report, reference_ui_fix_report, traffic_color_fix_report

Files changed: 49 (44 modified, 5 new)
Lines: +936, -726
This commit completes a major MVP milestone including a full rebrand from
"Fare Estimator" to "PH Fare Calculator" and introduces intelligent
region-based transport mode filtering.

## App Rebranding
- Renamed app from "Fare Estimator" to "PH Fare Calculator" across:
  - pubspec.yaml (package name: ph_fare_calculator)
  - AndroidManifest.xml (android:label)
  - iOS Info.plist (CFBundleDisplayName, CFBundleName)
  - All localization files (app_en.arb, app_tl.arb, generated l10n)
  - All Dart import statements (40+ files updated)

## Regional Transport Filtering System
- Created RegionConfig model with static transport mode availability map
- Implemented TransportModeFilterService with:
  - Bounding box region detection for NCR, Cebu, Davao, CDO
  - Latitude-based fallback for Luzon/Visayas/Mindanao
  - Transport mode validation per region
- Regional restrictions based on Philippines transport research:
  - EDSA Carousel: NCR only (Metro Manila busway)
  - LRT/MRT/PNR Trains: NCR and Luzon only
  - Taxi: Major cities (NCR, Cebu, Davao, CDO)
  - Jeepney, Bus, Tricycle, Ferry: Nationwide

## Fare Comparison Service Enhancements
- Injected TransportModeFilterService via dependency injection
- Added regional filtering in compareFares() method
- Implemented filterByRegion() for direct region-based filtering
- Added groupFaresByMode() for UI grouping functionality

## UI Improvements
- MainScreen now displays fare results grouped by transport mode
- Each group has styled section headers with transport mode icons
- Dynamic map adjustment when origin/destination selected

## Documentation
- Created transport_availability_research.md with PH transport data
- Created mvp_features_architecture.md with implementation plan
- Updated mvp_final_verification_report.md with test results

## Testing
- Added 24 new tests for TransportModeFilterService
- Updated existing tests for new FareComparisonService signature
- All 95 tests passing with zero static analysis issues

Files Changed: 40 files (33 modified, 7 new)
New Files:
  - lib/src/core/constants/region_constants.dart
  - lib/src/models/region_config.dart
  - lib/src/services/transport_mode_filter_service.dart
  - test/services/transport_mode_filter_service_test.dart
  - docs/workspace/mvp_features_architecture.md
  - docs/workspace/transport_availability_research.md
Three key MVP fixes implemented:

Map Auto-Centering:
- Destination map picker now falls back to origin location when
  destination is null, eliminating need to manually drag map

Passenger Type Sync:
- Settings discount type now syncs to main screen passenger state
- Auto-applies discount when user is sole passenger with discount type
- UI controls take precedence when multiple passengers added

Transport Mode Parsing:
- TransportMode.fromString() now handles "Mode (SubType)" format
- Example: "Jeepney (Traditional)" correctly parses to Jeepney
- Fixes fare results grouping by transport mode

Additional changes:
- Removed 49 obsolete documentation files
- Added macos platform support files
- Updated generated files and tests

Verified: All 95 tests passing
@MasuRii MasuRii added the enhancement New feature or request label Dec 4, 2025
@MasuRii MasuRii merged commit 865a03e into main Dec 4, 2025
@MasuRii MasuRii deleted the fix/mvp-map-passenger-fare-improvements branch March 16, 2026 01:21
MasuRii added a commit that referenced this pull request Mar 16, 2026
…r-fare-improvements

feat: Complete PH Fare Calculator MVP with regional filtering and UX improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unsupported platform-specific files Android startup results in a black screen

1 participant