How tarek3222/translatify works
Project type and purpose
• Translatify is a *cross-platform Flutter client app* (mobile/web/desktop) for tourists to discover and chat with translators, perform AI and image-based translations, manage bookings/payments, and personalize their profile.
• There is no in-repo backend; all data operations happen via remote APIs (your own backend, Google Translate, AWS, Stripe) and local storage (shared prefs).
File structure for architectural layers
• lib/core: core services (dependency injection, networking, theming, routing, utilities, reusable widgets)
• lib/features: 14 feature modules (onboarding, auth, home, chat, google_translate, main, payment, settings, sign_in/up, translator_profile, user_profile) each with:
• data (models, repos, local/remote data sources)
• logic (BLoCs/Cubits and states)
• ui (views and widgets)
• platform dirs (android, ios, linux, macos, windows, web) host Flutter platform code.
Main components
A. Presentation Layer (UI + Navigation)
• Feature UI modules (Widgets/Views)
• Core AppRouter (routes)
• Main entry point (main.dart → TranslatorsApp)
B. State Management Layer
• BLoC/Cubit instances per feature
• Connected to UI via BlocBuilder/BlocConsumer
C. Domain/Data Layer
• Repositories (e.g., ChatsRepo, TranslatorsListRepo, PaymentRepo, etc.)
• Data Sources
• Remote (Dio-Retrofit API clients)
• Local (SharedPreferences helpers, local data sources for caching)
D. Core Services
• DI Container (Get_it)
• Network Info (connectivity check)
• DioFactory & ApiService
• SharedPreferences helper
• Theming & Localization
E. External Services
• Your backend API (BASE_URL endpoints)
• Google Translate API
• AWS Translate/TTS
• Stripe API
Relationships & Data Flow
1. UI → BLoC/Cubit
• User interaction in a View dispatches events to its Cubit.
2. Cubit → Repository
• Cubit calls a method on its corresponding Repo.
3. Repo → Data Source
• Repo decides between remote or local data source.
4. Remote Data Source → ApiService → External API
• Uses DioFactory to get Dio instance, then Retrofit-generated service to call endpoints.
5. Local Data Source → SharedPreferences
• Caches data (e.g., chats cache, favorites).
6. External API Response → Models → Cubit → UI
• Data flows back via models (generated with json_serializable) to update Cubit state, then UI rebuilds.
Architectural patterns & design principles
• MVVM + BLoC: Views observe Cubit (like ViewModel) states.
• Dependency Injection: All services (ApiService, Repos, Cubits) are registered in a get_it container at startup.
• Layered Architecture: Clear separation between presentation, logic, data, and infrastructure.
• Feature-first modularization: Each domain area is self-contained under lib/features.
Elements
• Components labeled with their package names (e.g., lib/features/chat/logic/ChatCubit).
• Rectangles for components (UI, Cubit, Repo, DataSource)
• Clouds for external APIs (Google, AWS, Stripe, backend)
Detail level
• Core global services (DI, Networking, Theme) centrally at top or bottom.