How amrsalahdev/evira-e-commerce works
Project type and purpose
• This is a multi-platform Flutter application (Android, iOS, Web, Windows, macOS, Linux) serving as a premium E-Commerce & Online Shop front-end.
• It leverages Supabase as its backend (authentication, database, storage), uses Bloc/Cubit for state management, GetIt/Injectable for dependency injection, and integrates Sentry and Microsoft Clarity for monitoring/analytics.
File structure
• Top-level platforms: android/, ios/, web/, windows/, macos/, linux/
• Flutter entrypoint: lib/main.dart
• Core modules under lib/core – constants, theme, routes, DI, services, utils, localization
• Feature modules under lib/features – each with UI (screens, widgets), Cubit (state management), and domain/data layers (for onboarding)
• Shared module under lib/shared – reusable widgets, mixins, domain/usecases, cubits
• Configuration & generated code: pubspec.yaml, build_runner, flutter_gen, injectable_generator, flutter_native_splash
README for additional insights
• Architecture pattern: a layered “clean” approach with Presentation (UI + Cubit), Domain (entities, use cases), Data (models, Supabase client)
• State management: flutter_bloc (Cubit per screen/feature)
• Dependency injection: get_it + injectable
• External services: supabase_flutter, sentry_flutter, clarity_flutter
Main components and their relationships
a. Client Platforms (Android, iOS, Web, Desktop)
b. Presentation Layer
• Widgets & Screens (lib/features/.../ui/screen, lib/shared/widgets)
• Cubits (lib/features/.../ui/cubit, lib/shared/cubits)
• Routes & Navigation (go_router in lib/core/routes/app_router.dart)
c. Domain Layer
• Entities (e.g., OnboardingEntity)
• Use Cases (e.g., GetThemeModeUseCase, SetThemeModeUseCase)
d. Data Layer
• Models (e.g., OnboardingModel)
• Services (Supabase client via supabase_flutter in lib/core/services)
• DI configuration (lib/core/di/di.dart, di.config.dart)
e. Cross-cutting Services
• ThemeService, AppUtils, AppTheme
• Localization (ARB files, intl)
f. External Services & APIs
• Supabase (Auth, Database, Storage)
• Sentry (Error Monitoring)
• Microsoft Clarity (Analytics)
Data flow & interactions
• User taps UI → triggers Cubit event → Cubit invokes UseCase/Service via injected repository → Service calls Supabase API → returns data or error → Cubit emits new state → UI rebuilds → optional logging to Sentry/Clarity.
• Theme changes go through ThemeService and persisted via UseCase.
• Navigation via go_router, passing Cubit or arguments between screens.
Architectural patterns & principles
• Layered/Clean architecture: clear separation of Presentation, Domain, Data
• Bloc/Cubit for unidirectional data flow
• Dependency Injection for loose coupling and testability
• Code generation for DI (Injectable) and assets (Flutter Gen)
• Feature-based module organization