BottleCRM Mobile
A modern, feature-rich Flutter CRM application for startups and enterprises. Built with a scalable architecture, BottleCRM Mobile provides comprehensive customer relationship management capabilities with multi-tenant support, real-time synchronization, and intuitive user experience.
๐ Overview
BottleCRM Mobile is designed to streamline your sales and customer management processes with:
- Multi-tenant Architecture: Organization-based data isolation and role management
- Offline-First Design: Local caching with smart synchronization
- Modern UI/UX: Material Design 3 with adaptive layouts
- Enterprise Security: OAuth 2.0, JWT tokens, and secure API communication
โจ Features
๐ Authentication & Security
- Google OAuth 2.0: Seamless single sign-on integration
- JWT Authentication: Secure token-based API communication
- Multi-tenant Support: Organization-based data isolation
- Role-based Access: Granular permissions and user management
๐ Core CRM Modules
- Dashboard: Real-time metrics, KPIs, and activity feeds
- Contacts: Complete contact management with search and filtering
- Leads: Lead capture, qualification, and conversion tracking
- Opportunities: Sales pipeline management with stages
- Tasks: Task assignment, tracking, and deadline management
- Accounts: Customer account profiles and relationship history
- Cases: Customer support ticket management
- Events: Calendar integration and meeting scheduling
- Documents: File management with cloud storage
- Teams: Collaboration tools and team management
- Invoices: Billing and invoice generation
๐จ User Experience
- Material Design 3: Modern, consistent UI patterns
- Responsive Design: Optimized for phones, tablets, and foldables
- Dark/Light Theme: System-aware theme switching
- Offline Support: Local data caching with smart sync
- Pull-to-Refresh: Intuitive data refresh patterns
- Infinite Scrolling: Smooth pagination for large datasets
๐ Requirements
System Requirements
- Flutter SDK: 3.8.1 or later
- Dart SDK: 3.0.0 or later
- Android Studio/VS Code: Latest stable version
- Git: For version control
Platform Support
- Android: API level 31+ (Android 12+)
- iOS: iOS 11.0+ (for iOS builds)
- Web: Modern browsers (Chrome, Firefox, Safari, Edge)
- Desktop: Windows, macOS, Linux (experimental)
Development Tools
- Android SDK: For Android development
- Xcode: For iOS development (macOS only)
- CocoaPods: iOS dependency management
๐ Getting Started
๐ฑ For End Users
Download the app directly from Google Play Store:
๐จโ๐ป For Developers
Quick Start
Clone the repository:
git clone https://github.com/your-username/bottlecrm_mobile_v2.git
cd bottlecrm_mobile_v2
Install Flutter dependencies:
flutter pub get
Set up Firebase & Google Sign-In:
# Copy template and configure
cp android/app/google-services.json.template android/app/google-services.json
# Edit the file with your Firebase project configuration
Run the application:
flutter run
๐ง Detailed Setup
Firebase Configuration
- Create a new Firebase project at Firebase Console
- Enable Google Sign-In authentication
- Download
google-services.json for Android
- Download
GoogleService-Info.plist for iOS (if building for iOS)
- Place files in their respective directories:
- Android:
android/app/google-services.json
- iOS:
ios/Runner/GoogleService-Info.plist
Google Cloud Console Setup
- Navigate to Google Cloud Console
- Create OAuth 2.0 Client ID for Android:
# Get your SHA-1 fingerprint
cd android
./gradlew signingReport
- Add the SHA-1 fingerprint to your OAuth client
- Configure OAuth consent screen
Environment Configuration
The app automatically switches between environments:
- Debug builds: Uses development API (ngrok URL)
- Release builds: Uses production API (bottlecrm.io)
You can modify URLs in lib/config/api_config.dart
๐ Development
Development Commands
# Run the app with hot reload
flutter run
# Run with specific device
flutter run -d <device-id>
# Run in debug mode with detailed logging
flutter run --debug --verbose
# Format code
dart format .
# Analyze code quality
flutter analyze --no-fatal-infos
# Run tests
flutter test
# Generate code coverage
flutter test --coverage
Code Quality & Standards
This project follows strict coding standards:
- Linting: Uses
flutter_lints for consistent code style
- Architecture: Singleton services with dependency injection
- Error Handling: Comprehensive try-catch with user-friendly messages
- Naming: Dart conventions (camelCase, PascalCase, snake_case)
- Documentation: Comprehensive inline documentation
Debugging
# Connect to Android device over WiFi
adb connect <device-ip>:5555
# View logs
flutter logs
# Launch DevTools
flutter pub global activate devtools
flutter pub global run devtools
๐ฆ Build & Deployment
Android Builds
# Clean and prepare
flutter clean
flutter pub get
# Debug build (uses development API)
flutter build apk --debug
# Release build (uses production API)
flutter build apk --release
# App Bundle for Play Store
flutter build appbundle --release
# Install APK directly
flutter install build/app/outputs/flutter-apk/app-release.apk
iOS Builds (macOS only)
# Build for iOS
flutter build ios --release
# Build for iOS Simulator
flutter build ios --debug --simulator
Build Configurations
The app uses different API endpoints based on build type:
- Debug builds: Development server (ngrok tunnel)
- Release builds: Production API (
https://api.bottlecrm.io)
Build configurations are managed in:
lib/config/api_config.dart - API endpoint configuration
android/app/build.gradle.kts - Android build settings
ios/Runner.xcodeproj - iOS build settings
๐ Architecture
BottleCRM Mobile follows a robust, scalable architecture designed for enterprise applications:
Core Architecture Patterns
- Singleton Services: All services use the singleton pattern for consistent state management
- Service-First Design: Business logic is encapsulated in service classes
- Repository Pattern: Data access abstraction with caching layers
- Multi-tenant Support: Organization-based data isolation at the API level
Project Structure
lib/
โโโ app.dart # Main app configuration & routing
โโโ main.dart # Application entry point
โโโ config/
โ โโโ api_config.dart # Environment-aware API configuration
โโโ models/
โ โโโ api_models.dart # Type-safe data models with JSON serialization
โโโ services/ # Business logic & API communication
โ โโโ api_service.dart # HTTP client with auto-authentication
โ โโโ auth_service.dart # Google OAuth & organization management
โ โโโ contacts_service.dart
โ โโโ dashboard_service.dart
โ โโโ leads_service.dart
โ โโโ tasks_service.dart
โโโ screens/ # UI screens organized by feature
โโโ dashboard_screen.dart
โโโ login_screen.dart
โโโ company_selection_screen.dart
โโโ ...
Key Architecture Components
1. Authentication Flow
Login โ Google OAuth โ JWT Token โ Organization Selection โ Dashboard
2. Service Pattern
class SomeService {
static final SomeService _instance = SomeService._internal();
factory SomeService() => _instance;
SomeService._internal();
// Service methods...
}
3. API Communication
- Centralized HTTP client with automatic JWT token injection
- Organization header (
X-Organization-ID) for multi-tenant requests
- Automatic logout on 401 responses
- Comprehensive error handling with user-friendly messages
4. State Management
- Service-based state management with singleton pattern
- Local caching using SharedPreferences
- Reactive UI updates with StatefulWidget patterns
- Navigation state preserved with IndexedStack
Data Flow
- Authentication: Google OAuth โ JWT storage โ Organization selection
- API Requests: Service โ ApiService โ HTTP โ Backend API
- Data Processing: JSON โ Model classes โ UI widgets
- Local Storage: Critical data cached in SharedPreferences
- Error Handling: Service level โ UI feedback โ User notification
โ๏ธ Configuration
API Configuration
The application uses environment-based API URLs configured in lib/config/api_config.dart:
// Development (debug builds)
static const String _developmentUrl = 'https://b2ad5166b831.ngrok-free.app';
// Production (release builds)
static const String _productionUrl = 'https://api.bottlecrm.io';
Environment Detection: Automatic switching based on kDebugMode flag
Authentication Setup
Google Sign-In Configuration
Firebase Console Setup:
- Create Firebase project
- Enable Google Sign-In authentication provider
- Configure OAuth consent screen
Get Android SHA-1 fingerprint:
cd android
./gradlew signingReport
Google Cloud Console:
- Create OAuth 2.0 Client ID for Android
- Add SHA-1 fingerprint to OAuth client
- Download
google-services.json
Firebase Configuration Files:
android/app/google-services.json # Android configuration
ios/Runner/GoogleService-Info.plist # iOS configuration (if applicable)
Authentication Flow
1. User clicks "Sign in with Google"
2. Google OAuth flow โ JWT token received
3. Token stored in SharedPreferences
4. User selects organization from available list
5. Organization ID added to all API requests via X-Organization-ID header
6. Dashboard and metadata loaded for selected organization
Multi-tenancy Configuration
- Organization-based Data Isolation: All API requests include organization context
- Automatic Header Injection:
ApiService adds X-Organization-ID to requests
- Organization Switching: Clear cached data when switching organizations
- Role-based Access: Different permissions based on user role in organization
Storage Configuration
- JWT Tokens: Stored securely in SharedPreferences
- Organization Data: Cached locally for offline access
- Metadata Caching: Lead statuses, sources, and other metadata cached per organization
- Auto-cleanup: Cached data cleared on logout and organization switch
๐ Dependencies
Core Dependencies
| Package |
Version |
Purpose |
flutter |
SDK |
Flutter framework |
cupertino_icons |
^1.0.8 |
iOS-style icons |
http |
^1.1.0 |
HTTP client for API requests |
google_sign_in |
^7.1.1 |
Google OAuth authentication |
shared_preferences |
^2.2.2 |
Local data persistence |
jwt_decoder |
^2.0.1 |
JWT token parsing |
font_awesome_flutter |
^10.7.0 |
FontAwesome icons |
intl |
^0.19.0 |
Internationalization support |
package_info_plus |
^8.0.2 |
App version and build info |
Development Dependencies
| Package |
Version |
Purpose |
flutter_test |
SDK |
Testing framework |
flutter_lints |
^6.0.0 |
Dart linting rules |
flutter_launcher_icons |
^0.14.4 |
App icon generation |
Key Features by Dependency
- Authentication: Google Sign-In with JWT token management
- HTTP Communication: Robust API client with error handling
- Local Storage: Secure token and metadata caching
- UI Components: Material Design with FontAwesome icons
- Code Quality: Comprehensive linting and formatting
๐งช Testing
Test Structure
test/
โโโ unit/ # Unit tests for services and models
โโโ widget/ # Widget tests for UI components
โโโ integration/ # End-to-end integration tests
Running Tests
# Run all tests
flutter test
# Run with coverage
flutter test --coverage
# Run specific test file
flutter test test/unit/auth_service_test.dart
Testing Guidelines
- Unit Tests: All service methods and model classes
- Widget Tests: Critical UI components and interactions