# lucasomac/pokedex architecture

> Architecture diagram of the GitHub repository lucasomac/pokedex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lucasomac/pokedex
- Repository: https://github.com/lucasomac/pokedex

## Overview

##### Project Type and Purpose
- This is a multi-module Android application (“app” module) plus a standalone “attributes” library module.
- It implements a Pokédex client using Kotlin, Android SDK (Material Design), Clean Architecture layers (presentation, domain, data, framework), and consumes the external PokeAPI.

##### High-Level Architecture Overview
- App module: the executable Android application
- Presentation layer: Activities, Fragments, ViewModels, UI adapters, and navigation graph
- Domain layer: Entities, Repository interfaces, UseCase interfaces and implementations, paging source
- Data layer: Retrofit API definitions (PokemonApi), Response models, Repository implementations, DataSource interfaces
- Framework layer: DataSourceImpl, dependency-injection module (PokedexModule)
- Attributes module: reusable UI component library for displaying Pokémon attributes (cards, components)

##### Main Components and Their Relationships
- Presentation
- UI Components (Activity/Fragments) ←─ observes LiveData/State from → ViewModel
- ViewModel ── invokes → UseCase
- Domain
- UseCase ── depends on → Repository interface
- Repository interface ←─ implemented by → RepositoryImpl in Data layer
- Data
- RepositoryImpl ── delegates to → PokedexDataSource (interface)
- PokedexDataSourceImpl (Framework) ── calls → PokemonApi (Retrofit) → External PokeAPI
- PagingSource for infinite scroll in domain/data/source
- Models mapping: JSON response → domain Entities
- Framework/DI
- PokedexModule wires Retrofit, DataSourceImpl, RepositoryImpl, UseCaseImpl, ViewModels
- Attributes module
- Provides UI cards and components → consumed by app/ui

##### Architectural Patterns and Principles
- Clean Architecture: strict separation of layers; direction of dependency inward
- Dependency Injection: PokedexModule centralizes component wiring
- Repository pattern + DataSource abstraction for remote data
- Paging 3 for list pagination
- MVVM in Presentation: Fragments/Activities + ViewModels + LiveData/State

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "App Module"
        subgraph "Presentation Layer"
            MA["MainActivity"]:::presentation
            PF["PokedexFragment"]:::presentation
            PGF["PokedexGenericFragment"]:::presentation
            PoF["PokemonFragment"]:::presentation
            PVM["PokedexViewModel"]:::presentation
            PoVM["PokemonViewModel"]:::presentation
            PLA["PokemonListAdapter"]:::presentation
            BPTA["BubblePokemonTypeAdapter"]:::presentation
            BA["BindingAdapters"]:::presentation
            NG["nav_graph.xml"]:::presentation
        end
        subgraph "Domain Layer"
            E1["Pokedex (Entity)"]:::domain
            E2["Pokemon (Entity)"]:::domain
            E3["PokemonType (Entity)"]:::domain
            RI["PokedexRepository (Interface)"]:::domain
            UC1["PokedexUseCase"]:::domain
            UCI1["PokedexUseCaseImpl"]:::domain
            UC2["PokemonUseCase"]:::domain
            UCI2["PokemonUseCaseImpl"]:::domain
            PS["PokedexPagingSource"]:::domain
        end
        subgraph "Data Layer"
            API["PokemonApi"]:::data
            R1["PokemonListResponse"]:::data
            R2["PokemonResponse"]:::data
            RIml["PokedexRepositoryImpl"]:::data
            DS["PokedexDataSource (Interface)"]:::data
        end
        subgraph "Framework/DI Layer"
            DSImpl["PokedexDataSourceImpl"]:::framework
            DI["PokedexModule"]:::framework
        end
    end

    subgraph "Attributes Module"
        AE["Attribute (Entity)"]:::domain
        AC["PokemonAttributesCard"]:::presentation
        AComp["PokemonAttribute"]:::presentation
    end

    MA -->|"observes LiveData"| PVM
    PF -->|"observes LiveData"| PVM
    PGF -->|"observes LiveData"| PVM
    PoF -->|"observes LiveData"| PoVM
    PVM -->|"invokes"| UC1
    PoVM -->|"invokes"| UC2
    UC1 -->|"depends on"| RI
    UCI1 -->|"implements"| UC1
    UC2 -->|"implements"| PokemonUseCase
    UCI2 -->|"implements"| UC2
    RI -->|"implemented by"| RIml
    RIml -->|"delegates to"| DS
    DS -->|"implemented by"| DSImpl
    DSImpl -->|"calls"| API
    API -->|"HTTP requests"| POAPIE["PokeAPI REST Service"]:::external
    RIml -->|"uses PagingSource"| PS
    AC -->|"used by UI"| PLA
    AComp -->|"used by UI"| BA

    classDef presentation fill:#AED6F1,stroke:#31708f
    classDef domain fill:#ABEBC6,stroke:#2e7d32
    classDef data fill:#F9E79F,stroke:#b9770e
    classDef framework fill:#D5D8DC,stroke:#5d6d7e
    classDef external stroke-dasharray: 5 5,stroke:#34495e

    click MA "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/activity/MainActivity.kt"
    click PF "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/fragment/PokedexFragment.kt"
    click PGF "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/fragment/PokedexGenericFragment.kt"
    click PoF "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/fragment/PokemonFragment.kt"
    click PVM "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/viewmodel/PokedexViewModel.kt"
    click PoVM "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/presentation/viewmodel/PokemonViewModel.kt"
    click PLA "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/adapter/PokemonListAdapter.kt"
    click BPTA "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/adapter/BubblePokemonTypeAdapter.kt"
    click BA "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/ui/adapter/BindingAdapters.kt"
    click NG "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/res/navigation/nav_graph.xml"
    click E1 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/entity/Pokedex.kt"
    click E2 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/entity/Pokemon.kt"
    click E3 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/entity/PokemonType.kt"
    click RI "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/repository/PokedexRepository.kt"
    click UC1 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/usecase/PokedexUseCase.kt"
    click UCI1 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/usecase/PokedexUseCaseImpl.kt"
    click UC2 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/usecase/PokemonUseCase.kt"
    click UCI2 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/usecase/PokemonUseCaseImpl.kt"
    click PS "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/domain/data/source/PokedexPagingSource.kt"
    click API "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/data/PokemonApi.kt"
    click R1 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/data/model/response/PokemonListResponse.kt"
    click R2 "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/data/model/response/PokemonResponse.kt"
    click RIml "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/data/repository/PokedexRepositoryImpl.kt"
    click DS "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/data/source/PokedexDataSource.kt"
    click DSImpl "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/framework/data/source/PokedexDataSourceImpl.kt"
    click DI "https://github.com/lucasomac/pokedex/blob/develop/app/src/main/java/br/com/lucolimac/pokedex/framework/di/PokedexModule.kt"
    click AE "https://github.com/lucasomac/pokedex/blob/develop/attributes/src/main/java/br/com/lucolimac/pokedex/attribute/domain/entity/Attribute.kt"
    click AC "https://github.com/lucasomac/pokedex/blob/develop/attributes/src/main/java/br/com/lucolimac/pokedex/attribute/ui/cards/PokemonAttributesCard.kt"
    click AComp "https://github.com/lucasomac/pokedex/blob/develop/attributes/src/main/java/br/com/lucolimac/pokedex/attribute/ui/component/PokemonAttribute.kt"
```
