Skip to content

koniz-dev/grex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Grex

A production-ready Grex project with Clean Architecture, enterprise-grade configuration management, and comprehensive developer tooling.

Flutter Dart License Tests Architecture codecov

✨ Features

πŸ—οΈ Architecture & Code Quality

  • βœ… Clean Architecture - Separation of concerns with Domain, Data, and Presentation layers
  • βœ… State Management - BLoC pattern for reactive state management
  • βœ… Code Generation - Freezed for immutable classes and JSON serialization
  • βœ… Linting - Very Good Analysis for comprehensive code quality checks
  • βœ… Testing - Comprehensive test coverage with 87 property-based tests (100+ iterations each)

βš™οΈ Configuration & Environment

  • βœ… Multi-Environment Support - Development, Staging, Production
  • βœ… Flexible Configuration - .env files for local dev, --dart-define for CI/CD
  • βœ… Feature Flags - Local and remote (Firebase Remote Config) feature flags
  • βœ… Environment-Aware Defaults - Smart defaults based on environment
  • βœ… Type-Safe Configuration - Typed getters with fallback chain

🌐 Internationalization

  • βœ… Multi-Language Support - English, Vietnamese, Spanish, Arabic
  • βœ… RTL Support - Right-to-left language support for Arabic
  • βœ… Locale Persistence - Save and restore user language preference
  • βœ… Standardized Localization - Context extension for easy access (context.l10n)

πŸ” Security & Storage

  • βœ… Secure Storage - Flutter Secure Storage for sensitive data
  • βœ… Shared Preferences - Simple key-value storage for non-sensitive data
  • βœ… Storage Migration - Version-based storage migration system
  • βœ… Error Handling - Comprehensive error handling with custom exceptions

πŸ” Authentication & Social Login

  • βœ… Email/Password Authentication - Complete auth system with email verification
  • βœ… Social Login - Google OAuth and Apple Sign In integration (98% complete)
  • βœ… Account Linking - Link social providers to existing accounts
  • βœ… Profile Setup - Guided profile completion for new social users
  • βœ… Deep Link Handling - OAuth callback processing with performance optimization
  • βœ… Session Management - Persistent sessions across app restarts
  • βœ… Security Compliance - HTTPS-only, minimal scopes, secure token storage

πŸ’° Expense Sharing Features

  • βœ… Group Management - Create and manage expense groups with role-based permissions
  • βœ… Expense Tracking - Record expenses with 4 split methods (equal, percentage, exact, shares)
  • βœ… Payment Recording - Track payments between group members
  • βœ… Balance Calculation - Real-time balance calculations with settlement plan generation
  • βœ… Data Export - Export group data in CSV/PDF formats
  • βœ… Search & Filter - Advanced search and filtering across expenses

🌐 Network Layer

  • βœ… HTTP Client - Dio with interceptors support
  • βœ… Configurable Timeouts - Environment-based timeout configuration
  • βœ… Request/Response Logging - Debug-friendly HTTP logging
  • βœ… Error Interceptors - Automatic error handling and conversion
  • βœ… Auth Interceptors - Automatic token injection and refresh

🎨 UI & UX

  • βœ… Material Design - Material 3 theme support
  • βœ… Dark Mode - Built-in dark theme support
  • βœ… Accessibility - Semantic labels and accessibility support
  • βœ… Responsive Design - Adaptive layouts for different screen sizes

🧭 Routing & Navigation

  • βœ… Type-Safe Routing - GoRouter with type-safe route definitions
  • βœ… Deep Linking - Support for deep links and URL navigation
  • βœ… Auth-Based Routing - Protected routes with authentication redirects
  • βœ… Navigation Logging - Automatic route tracking and logging

πŸ“Š Logging & Monitoring

  • βœ… Comprehensive Logging - Multi-level logging with file and console output
  • βœ… Log Rotation - Automatic log file rotation
  • βœ… Structured Logging - JSON formatting for production
  • βœ… Performance Monitoring - Firebase Performance integration
  • βœ… Screen Tracking - Automatic screen load time tracking

πŸš€ Deployment & CI/CD

  • βœ… Multi-Platform - Android, iOS, Web, Linux, macOS, Windows support
  • βœ… CI/CD Ready - GitHub Actions workflows included (disabled by default, uncomment triggers to enable)
  • βœ… Version Management - Automated version bumping scripts
  • βœ… Fastlane Integration - iOS and Android deployment automation

πŸ“š Documentation

  • βœ… Comprehensive Docs - Architecture, guides, API documentation
  • βœ… Migration Guides - From MVC, GetX, Bloc, and other architectures
  • βœ… Best Practices - Code examples and patterns
  • βœ… API Documentation - Complete API reference
  • βœ… Example Features - Complete features demonstrating Clean Architecture (Auth, Groups, Expenses, Balances, etc.)

πŸ§ͺ Testing

  • βœ… 66 Test Files - Comprehensive test coverage
  • βœ… Unit Tests - Domain and data layer testing
  • βœ… Widget Tests - UI component testing
  • βœ… Integration Tests - End-to-end flow testing
  • βœ… Test Helpers - Reusable test utilities and fixtures

πŸ› οΈ Tech Stack

Core Dependencies

  • Flutter - UI framework
  • Riverpod - State management
  • Dio - HTTP client
  • Freezed - Code generation for immutable classes
  • Equatable - Value equality comparison

Firebase

  • Firebase Core - Firebase initialization
  • Firebase Remote Config - Remote feature flags
  • Firebase Performance - Performance monitoring and tracking

Storage

  • flutter_secure_storage - Secure storage for sensitive data
  • shared_preferences - Simple key-value storage

Localization

  • flutter_localizations - Flutter localization support
  • intl - Internationalization utilities

Routing & Navigation

  • go_router - Declarative routing with deep linking

Logging & Monitoring

  • logger - Comprehensive logging solution
  • path_provider - File system access for log files

Development Tools

  • build_runner - Code generation runner
  • very_good_analysis - Linting rules
  • mocktail - Testing and mocking

πŸ“ Project Structure

lib/
β”œβ”€β”€ core/                    # Core infrastructure
β”‚   β”œβ”€β”€ config/             # Configuration system
β”‚   β”œβ”€β”€ constants/          # App constants
β”‚   β”œβ”€β”€ di/                 # Dependency injection (Riverpod providers)
β”‚   β”œβ”€β”€ errors/             # Error handling
β”‚   β”œβ”€β”€ feature_flags/      # Feature flags infrastructure
β”‚   β”œβ”€β”€ localization/       # Localization service
β”‚   β”œβ”€β”€ logging/            # Logging service
β”‚   β”œβ”€β”€ network/            # Network layer (Dio setup)
β”‚   β”œβ”€β”€ performance/        # Performance monitoring
β”‚   β”œβ”€β”€ routing/            # Routing system (go_router)
β”‚   β”œβ”€β”€ storage/            # Storage services (with migration)
β”‚   └── utils/              # Utility functions
β”‚
β”œβ”€β”€ features/                # Feature modules (Clean Architecture)
β”‚   β”œβ”€β”€ auth/               # Authentication feature with social login
β”‚   β”‚   β”œβ”€β”€ data/          # Data layer (models, data sources, repositories)
β”‚   β”‚   β”‚   β”œβ”€β”€ handlers/  # OAuth deep link handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ models/    # User, profile, social auth models
β”‚   β”‚   β”‚   └── repositories/ # Social auth and user repositories
β”‚   β”‚   β”œβ”€β”€ domain/        # Domain layer (entities, use cases, repository interfaces)
β”‚   β”‚   β”‚   β”œβ”€β”€ entities/  # User, SocialAuthProvider, ProfileSetupData
β”‚   β”‚   β”‚   └── repositories/ # SocialAuthRepository interface
β”‚   β”‚   └── presentation/  # Presentation layer (screens, widgets, providers)
β”‚   β”‚       β”œβ”€β”€ pages/     # Login, register, profile setup pages
β”‚   β”‚       └── widgets/   # Social login buttons, dialogs, error widgets
β”‚   β”œβ”€β”€ feature_flags/      # Feature flags feature
β”‚   β”‚   └── presentation/   # Feature flags UI
β”‚   β”œβ”€β”€ groups/             # Group management
β”‚   β”œβ”€β”€ expenses/           # Expense tracking
β”‚   β”œβ”€β”€ payments/           # Built-in payments tracking
β”‚   β”œβ”€β”€ balances/           # Balance calculation engine
β”‚   └── export/             # Data export utilities
β”‚
β”œβ”€β”€ shared/                  # Shared resources
β”‚   β”œβ”€β”€ accessibility/      # Accessibility utilities
β”‚   β”œβ”€β”€ extensions/         # Dart extensions
β”‚   β”œβ”€β”€ theme/              # App theme configuration
β”‚   └── widgets/            # Reusable widgets
β”‚
β”œβ”€β”€ l10n/                   # Localization files (generated)
└── main.dart               # App entry point

πŸš€ Getting Started

Prerequisites

  • Flutter SDK (>=3.0.0)
  • Dart SDK (>=3.0.0)
  • Android Studio / VS Code with Flutter extensions
  • Xcode (for iOS development on macOS)

Local Development with Supabase

For fully offline development using a local Supabase instance:

  1. Install Supabase CLI

    npm install -g supabase
  2. Start local Supabase

    supabase start

    The CLI will print the API URL and anon key once running.

  3. Configure .env for local

    ENVIRONMENT=development
    SUPABASE_URL=http://localhost:54321
    SUPABASE_ANON_KEY=<anon key from supabase start output>

    The default anon key is already available in .env.example under SUPABASE_LOCAL_ANON_KEY.

  4. Apply migrations (if any)

    supabase db reset
  5. Run the app

    flutter run
  6. Stop local Supabase when done

    supabase stop

Note: When using Android Emulator, replace localhost with 10.0.2.2:

SUPABASE_URL=http://10.0.2.2:54321

Installation

  1. Create repository from template (if using GitHub template)

    • Click "Use this template" button on GitHub
    • Create a new repository from this template
    • Clone your new repository:
    git clone <your-repository-url>
    cd <your-project-name>

    OR clone directly (if not using template):

    git clone <repository-url>
    cd grex
  2. Install dependencies

    flutter pub get
  3. Generate code (Freezed, JSON serialization)

    flutter pub run build_runner build --delete-conflicting-outputs
  4. Set up environment configuration

    # Copy the example environment file
    cp .env.example .env
    
    # Edit .env with your configuration
    # See Configuration System section below
  5. Set up Git hooks (optional but recommended)

    Linux/macOS:

    ./scripts/linux/development/setup-git-hooks.sh

    Windows:

    .\scripts\windows\development\setup-git-hooks.ps1

    This will install Git hooks for:

    • Code formatting checks (pre-commit)
    • Commit message validation (commit-msg)
    • Test execution (pre-push)
  6. Run the app

    flutter run

Social Login Setup

The app includes comprehensive social login integration with Google OAuth and Apple Sign In.

OAuth Provider Configuration

  1. Google OAuth Setup:

    • Create OAuth 2.0 Client ID in Google Cloud Console
    • Add authorized redirect URIs: https://[project-id].supabase.co/auth/v1/callback
    • Configure in Supabase Dashboard β†’ Authentication β†’ Providers
  2. Apple Sign In Setup:

    • Create Services ID in Apple Developer Portal
    • Configure Sign In with Apple
    • Generate private key (.p8 file)
    • Configure in Supabase Dashboard β†’ Authentication β†’ Providers

Deep Link Configuration

Android (android/app/src/main/AndroidManifest.xml):

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="io.supabase.grex"
          android:host="login-callback" />
</intent-filter>

iOS (ios/Runner/Info.plist):

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>io.supabase.grex</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>io.supabase.grex</string>
        </array>
    </dict>
</array>

Features

  • OAuth Integration: Google and Apple OAuth with external browser launch
  • Account Linking: Link social providers to existing email accounts
  • Profile Setup: Guided profile completion for new social users
  • Deep Link Handling: Fast OAuth callback processing (< 1 second)
  • Session Management: Persistent sessions with automatic refresh
  • Error Handling: User-friendly error messages with retry options
  • Localization: Multi-language support for all social login UI
  • Security: HTTPS-only, minimal scopes, secure token storage
  • Performance: OAuth flow completion < 5 seconds after authorization

For detailed implementation guide, see Social Login Developer Guide.

First Steps

  1. Rename the project (if needed) - Update package name from grex to your project name
  2. Configure your environment - See Configuration System below
  3. Set up Firebase (optional) - For remote feature flags and performance monitoring
    • Add google-services.json (Android) and GoogleService-Info.plist (iOS)
    • Initialize Firebase in your app
  4. Customize the theme - Edit lib/shared/theme/app_theme.dart
  5. Explore example features - Check out lib/features/ for examples:
    • Auth - Authentication flow with social login
    • Groups & Expenses - Core expense sharing implementation
    • Feature Flags - Conditional UI rendering based on flags
  6. Add your first feature - Follow the pattern in example features
  7. Read the documentation - Check out docs/ folder for detailed guides

βš™οΈ Configuration System

This project includes a production-ready, multi-environment configuration system that supports:

  • Local Development: .env files for easy local configuration
  • CI/CD: --dart-define flags for build-time configuration
  • Fallback Chain: .env β†’ --dart-define β†’ defaults
  • Environment-Aware Defaults: Different configurations per environment
  • Feature Flags: Enable/disable features per environment
  • Network Configuration: Timeout settings for API calls
  • Debug Utilities: Tools for inspecting configuration

Architecture

The configuration system consists of two main classes:

  1. EnvConfig (lib/core/config/env_config.dart): Low-level environment variable loader

    • Loads from .env files using flutter_dotenv
    • Reads from --dart-define flags
    • Provides fallback chain: .env β†’ --dart-define β†’ defaults
  2. AppConfig (lib/core/config/app_config.dart): High-level application configuration

    • Uses EnvConfig to get values
    • Provides typed getters (String, bool, int)
    • Environment-aware defaults
    • Feature flags
    • Network timeout configuration
    • Debug utilities

Setup

1. Create .env file for local development

# Copy the example file
cp .env.example .env

# Edit .env with your values
# The .env file is gitignored and won't be committed

2. Configure your environment variables

Edit .env with your configuration:

ENVIRONMENT=development
BASE_URL=http://localhost:3000
ENABLE_LOGGING=true
ENABLE_ANALYTICS=false

Usage Examples

Local Development (using .env file)

  1. Create .env file from .env.example
  2. Fill in your values
  3. Run the app normally:
flutter run

The app will automatically load values from .env.

Staging Build (using --dart-define)

For CI/CD or when you don't want to use .env files:

flutter run \
  --dart-define=ENVIRONMENT=staging \
  --dart-define=BASE_URL=https://api-staging.example.com \
  --dart-define=ENABLE_ANALYTICS=true

Production Build (using --dart-define)

flutter build apk \
  --dart-define=ENVIRONMENT=production \
  --dart-define=BASE_URL=https://api.example.com \
  --dart-define=ENABLE_ANALYTICS=true \
  --dart-define=ENABLE_CRASH_REPORTING=true

Using Configuration in Code

Basic Usage

import 'package:grex/core/config/app_config.dart';

// Get environment
final env = AppConfig.environment; // 'development', 'staging', or 'production'

// Check environment
if (AppConfig.isDevelopment) {
  // Development-specific code
}

// Get API base URL
final baseUrl = AppConfig.baseUrl;

// Check feature flags
if (AppConfig.enableLogging) {
  logger.info('App started');
}

if (AppConfig.enableAnalytics) {
  analytics.trackEvent('app_opened');
}

Network Configuration

import 'package:grex/core/config/app_config.dart';
import 'package:dio/dio.dart';

final dio = Dio(
  BaseOptions(
    baseUrl: AppConfig.baseUrl,
    connectTimeout: Duration(seconds: AppConfig.apiConnectTimeout),
    receiveTimeout: Duration(seconds: AppConfig.apiReceiveTimeout),
    sendTimeout: Duration(seconds: AppConfig.apiSendTimeout),
  ),
);

Debug Utilities

import 'package:grex/core/config/app_config.dart';

// Print configuration to console (only in debug mode)
AppConfig.printConfig();

// Get configuration as a map
final config = AppConfig.getDebugInfo();
print(config);

Available Configuration Options

Environment Variables

Variable Type Default Description
ENVIRONMENT String development Environment name: development, staging, or production
BASE_URL String Environment-aware API base URL (see defaults below)
API_TIMEOUT int 30 API timeout in seconds
API_CONNECT_TIMEOUT int 10 API connect timeout in seconds
API_RECEIVE_TIMEOUT int 30 API receive timeout in seconds
API_SEND_TIMEOUT int 30 API send timeout in seconds
ENABLE_LOGGING bool Environment-aware Enable logging (default: true in dev/staging)
ENABLE_ANALYTICS bool Environment-aware Enable analytics (default: true in staging/prod)
ENABLE_CRASH_REPORTING bool Environment-aware Enable crash reporting (default: true in staging/prod)
ENABLE_PERFORMANCE_MONITORING bool Environment-aware Enable performance monitoring (default: true in staging/prod)
ENABLE_DEBUG_FEATURES bool Environment-aware Enable debug features (default: true in dev)
ENABLE_HTTP_LOGGING bool Environment-aware Enable HTTP request/response logging (default: true in dev)
APP_VERSION String 0.0.1 App version
APP_BUILD_NUMBER String 1 App build number

Environment-Aware Defaults

BASE_URL defaults:

  • Development: http://localhost:3000
  • Staging: https://api-staging.example.com
  • Production: https://api.example.com

Feature Flag defaults:

  • Logging: Enabled in development and staging
  • Analytics: Enabled in staging and production
  • Crash Reporting: Enabled in staging and production
  • Performance Monitoring: Enabled in staging and production
  • Debug Features: Enabled in development only
  • HTTP Logging: Enabled in development only

Best Practices

  1. Never commit .env files: They contain sensitive information and are gitignored
  2. Use .env.example as a template: Commit this file with placeholder values
  3. Use .env for local development: Easy to change values without rebuilding
  4. Use --dart-define for CI/CD: More secure and doesn't require file management
  5. Set environment-specific defaults: Let the system handle defaults based on environment
  6. Use feature flags: Enable/disable features per environment without code changes

Troubleshooting

Configuration not loading

  1. Ensure EnvConfig.load() is called in main() before runApp()
  2. Check that .env file exists in the project root
  3. Verify pubspec.yaml includes .env in assets
  4. Run flutter pub get after adding flutter_dotenv

Values not updating

  1. Hot reload doesn't reload environment variables - do a full restart
  2. For --dart-define values, rebuild the app
  3. Check that you're using the correct variable name (case-sensitive)

Debug configuration

Use AppConfig.printConfig() in debug mode to see all configuration values:

if (AppConfig.isDebugMode) {
  AppConfig.printConfig();
}

This will print all configuration values to the console, helping you verify what values are being used.

πŸ§ͺ Testing

Run Tests

# Run all tests
flutter test

# Run tests with coverage
flutter test --coverage

# Run specific test file
flutter test test/features/auth/domain/usecases/login_test.dart

Test Structure

Tests follow the same structure as the source code:

  • 66 test files with comprehensive coverage
  • Unit tests for use cases and utilities
  • Widget tests for UI components
  • Integration tests for end-to-end flows
  • Property-based tests for social login (35 properties with 100+ iterations each)
  • Test helpers and fixtures for reusable test utilities

Social Login Testing

The social login feature includes extensive testing:

# Run social login tests specifically
flutter test test/features/auth/data/repositories/social_auth_repository_test.dart
flutter test test/features/auth/presentation/widgets/social_login_button_test.dart

# Run property-based tests (100+ iterations each)
flutter test test/features/auth/property_tests/

Property Tests Include:

  • OAuth flow completion within performance requirements
  • Profile setup data preservation
  • Account linking detection and handling
  • Session persistence across app restarts
  • Error handling for all failure scenarios

Test Coverage

The project includes:

  • βœ… Domain layer tests (use cases, entities)
  • βœ… Data layer tests (repositories, data sources, models)
  • βœ… Presentation layer tests (screens, widgets, providers)
  • βœ… Core infrastructure tests (config, network, storage, logging, performance)
  • βœ… Integration tests for complete flows

πŸ—οΈ Building

Android

# Debug APK
flutter build apk --debug

# Release APK
flutter build apk --release

# App Bundle (for Play Store)
flutter build appbundle --release

iOS

# Debug
flutter build ios --debug

# Release
flutter build ios --release

Web

# Debug
flutter build web --debug

# Release
flutter build web --release

πŸ“š Documentation

Architecture

Guides

Migration Guides

Features

Deployment

API Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • How to report bugs
  • How to suggest enhancements
  • Development setup and workflow
  • Coding standards and guidelines
  • Testing requirements
  • Commit message conventions

Quick Start

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following our coding standards
  4. Write or update tests
  5. Commit your changes using conventional commits
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

For detailed guidelines, please read CONTRIBUTING.md.

πŸ“ License

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

πŸ™ Acknowledgments

πŸ“ž Support

For questions, issues, or contributions, please open an issue on GitHub.


Made with ❀️ using Flutter

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Generated from koniz-dev/flutter-starter