How mathvdias/pokedex works
Project type and purpose
• This is a cross-platform Flutter application (“PokeDex”) targeting iOS, Android, Web (PWA), macOS, Windows and Linux.
• It follows Clean Architecture with MVVM and SOLID principles, uses Provider for state management, Dio/http for network calls, and interacts with the external PokeApi to fetch Pokémon data.
File structure
• lib/ layer:
• src/app → app entrypoint, configuration, theming
• src/pages → presentation layer (UI widgets for splash, home, details; mobile + web variants)
• src/viewmodels → MVVM ViewModels
• src/states → UI state representations
• src/services/domain → domain models
• src/services/data/providers → HTTP client interface + Dio implementation
• src/services/data/repository → repository interfaces + implementations
• platform folders (android/, ios/, macos/, linux/, windows/, web/): Flutter embedding and native boilerplate.
• test/: unit and widget tests for repositories and ViewModels.
Key insights from README
• Clean Architecture + MVVM
• Multi-platform Flutter with Material 3
• Testing with Mockito + widget tests
• Core functionality: list/search Pokémon, detail view, data fetched from PokeApi.
Main components
a. Presentation Layer
• SplashPage, PokemonsPage (home), DetailsPokemonPage
• UI Components (cards, grids, search bar, charts)
• Bound to ViewModels (PokemonsViewModel, PokemonDetailViewModel)
b. State & ViewModel Layer
• ViewModels expose Stream/ChangeNotifier of UI states (loading, loaded, error)
• States defined in src/states
c. Domain Layer
• Domain models (PokemonListModel, PokemonModel, PokemonDetails, StatsModel)
• Repository interfaces
d. Data Layer
• HTTPClient interface → implemented by DioClientProvider
• Repositories (PokemonRepository, PokemonListRepository, PokemonDetailsRepository)
• Network DTOs → domain models
e. External Services
• PokeApi (REST endpoints)
f. Platform Embedding
• Flutter engine on Android, iOS, Web, Windows, macOS, Linux (can be shown as a single “Flutter host” block per platform or grouped)
Relationships & Data Flow
• UI triggers user action → calls method on ViewModel
• ViewModel calls repository interface (domain contract)
• Repository implementation calls HTTPClient → makes a network request to PokeApi
• HTTPClient returns JSON → mapped to domain models → returned up to ViewModel
• ViewModel updates state → UI rebuilds with new data
• Platform embedding hosts the Flutter engine and passes native events if needed (e.g., deep links, lifecycle)
Architectural patterns & principles
• Clean Architecture layers (Presentation, Domain, Data) separated by interfaces
• Dependency Inversion: ViewModels depend on abstractions (repository interfaces)
• Single Responsibility: each layer/folder has one concern
• MVVM: UI ↔ ViewModel ↔ Model
• Provider for DI & state management