Melos Workspace Setup

Overview

The Remind Tools project uses Melos to manage our Flutter monorepo containing two applications (Trips and Money) along with shared packages.

Workspace Structure

remind_tools/
├── melos.yaml                # Melos configuration
├── pubspec.yaml              # Workspace root configuration
├── apps/
│   ├── trips_app/           # Trips by Remind Tools
│   │   ├── lib/
│   │   │   ├── core/        # Core utilities
│   │   │   ├── features/    # Feature modules
│   │   │   ├── shared/      # Shared widgets
│   │   │   └── main.dart
│   │   └── pubspec.yaml
│   └── money_app/           # Money by Remind Tools
│       ├── lib/
│       └── pubspec.yaml
├── packages/
│   ├── core/                # Shared core utilities
│   ├── ui_components/       # Shared UI components
│   ├── data_models/        # Shared data models
│   └── services/           # Shared services
└── docs/

Getting Started

Prerequisites

  1. Flutter SDK 3.24+
  2. Dart SDK 3.5+
  3. Melos CLI

Installation

  1. Install Melos globally:
    dart pub global activate melos
    export PATH="$PATH:$HOME/.pub-cache/bin"
    
  2. Bootstrap the workspace:
    melos bootstrap
    

Available Melos Scripts

Development

  • melos run trips:dev - Run Trips app in development
  • melos run money:dev - Run Money app in development
  • melos get - Get dependencies for all packages
  • melos clean - Clean build artifacts

Testing

  • melos test - Run tests for all packages
  • melos test:unit - Run unit tests only
  • melos test:widget - Run widget tests only
  • melos test:integration - Run integration tests

Code Quality

  • melos analyze - Analyze Dart code
  • melos format - Check code formatting
  • melos format:fix - Fix code formatting
  • melos fix - Apply automated fixes

Building

  • melos run build:all - Build all apps for all platforms
  • melos run build:android - Build Android APK
  • melos run build:ios - Build iOS app
  • melos run build:web - Build web version

Code Generation

  • melos run generate - Run build_runner code generation
  • melos run generate:watch - Watch and auto-generate code

Package Dependencies

Each app references shared packages through path dependencies:
dependencies:
  core:
    path: ../../packages/core
  ui_components:
    path: ../../packages/ui_components
  data_models:
    path: ../../packages/data_models
  services:
    path: ../../packages/services

VS Code Integration

Launch Configurations

The workspace includes pre-configured launch configurations for both apps:
  • Trips App (debug/release)
  • Money App (debug/release)
  • All Apps (compound launch)

Settings

Optimized VS Code settings for Flutter development:
  • Hot reload on save enabled
  • Format on save configured
  • Dart-specific editor settings
  • Build artifacts excluded from search

Clean Architecture

Both apps follow Clean Architecture principles:

Presentation Layer

  • Flutter UI with BLoC + Riverpod
  • Feature-based organization
  • Shared UI components

Domain Layer

  • Business logic and use cases
  • Domain models
  • Repository interfaces

Data Layer

  • Supabase integration
  • API clients
  • Local storage

Shared Packages

core

Core utilities and extensions used across all apps:
  • String, DateTime, Context extensions
  • Logging and validation utilities
  • App constants and endpoints
  • Device and connectivity services

ui_components

Shared UI components and themes:
  • App themes and colors
  • Common widgets (buttons, inputs, cards)
  • Loading indicators and animations
  • Typography definitions

data_models

Shared data models:
  • User models and profiles
  • Trip-specific models (trips, itineraries, destinations)
  • Finance-specific models (transactions, budgets, accounts)
  • Common models (response, error, pagination)

services

Shared services:
  • Authentication service and repository
  • Storage services (local and secure)
  • API client and interceptors
  • Database service (Supabase)

Best Practices

  1. Package Management: Always use melos bootstrap after adding new dependencies
  2. Code Organization: Follow feature-based structure within apps
  3. Shared Code: Extract common functionality to shared packages
  4. Testing: Write tests at all levels (unit, widget, integration)
  5. Documentation: Keep package README files updated
  6. Version Control: Use conventional commits for clear history

Troubleshooting

Bootstrap Fails

  • Ensure Flutter SDK version is 3.24+
  • Check Dart SDK version is 3.5+
  • Run melos clean then melos bootstrap

IDE Issues

  • Restart IDE after bootstrap
  • Ensure Dart/Flutter plugins are installed
  • Check workspace settings in .vscode/settings.json

Package Resolution

  • Verify path dependencies in pubspec.yaml
  • Check package names match directory names
  • Run melos list to see recognized packages

Next Steps

  1. Configure environment variables for each app
  2. Set up Supabase integration
  3. Configure MapBox for Trips app
  4. Set up Gemini AI integration
  5. Implement CI/CD with Codemagic