# popstackhack/mvoterandroid architecture

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

- Interactive diagram: https://gitdiagram.com/popstackhack/mvoterandroid
- Repository: https://github.com/popstackhack/mvoterandroid

## Overview

##### Project Type and Purpose
- The README and file tree reveal that this is an Android application (mVoter 2020) that provides voter information and related public data. It is open-sourced, includes a web component, and is built primarily for Android devices.
- The app is structured for both production use and educational purposes (“public money, public code”) with support for testing, dependency injection, and modular data handling.

##### File Structure
- The top-level “app” folder contains Android–specific UI code. Notice the “src/main/java/com/popstack/mvoter2015/…” hierarchy which separates core routines, MVP/MVVM controllers (e.g. BaseActivity, MvvmController), and a variety of feature-specific packages (e.g., candidate, faq, news, party, votingguide).
- The project is modularized into multiple Gradle modules including:
– app: The presentation layer (UI, controllers, activities, view models).
– data (with submodules like data/android, data/cache, data/common, data/network, data/fakenetwork): covering data sources, caching, network API definitions, and fake network for testing.
– domain: Contains the business logic, use cases, repositories, and models (e.g., candidate use cases, faq use cases, location models).
– simplespinneradapter: A smaller UI component library.
- There is also a “buildSrc” directory that manages dependencies with Kotlin DSL, which is an important piece for the build structure.

##### Main Components
a. Presentation Layer (app module):
– UI Components: Activities (e.g., HostActivity, SplashController), Fragments/Controllers (e.g., CandidateListController, FaqController), and view holders for RecyclerViews.
– Core framework elements: BaseActivity, BaseController, MVVM/MVP controllers (mvvm, mvp packages).
– Feature-specific components: Each feature (candidate, faq, news, party, voting guide, etc.) is its own sub-component.
– Dependency injection: Layers like AppInjector and Dagger view model factories from the “di” sub-packages.
b. Domain Layer (domain module):
– Use Cases: Each feature (Candidate, Faq, Location, News, Party) includes use case classes (e.g., GetCandidate, GetFaqList, GetNewsList).
– Business Models: Domain models for Candidate, Constituency, Townships, etc.
– Utility components: Common domain logic like DispatcherProvider, CoroutineUseCase.
c. Data Layer (data modules):
– Data Sources:
- Network Sources (in data/network and data/fakenetwork): API models, JSON adapters, Retrofit/OkHttp providers, authentication interceptors.
- Cache Sources (in data/cache): SQLDelight setup, caching logic, column adapters, proto files.
- Android-specific and common modules for handling platform-dependent data.
– Repositories: Implementations that combine multiple data sources.
d. Cross-Cutting and Infrastructure:
– Dependency Injection: Components and modules under “di” (application-level DI and feature-specific DI sets).
– Helper libraries: Included in “helper”, “logging”, “extensions” – these support both UI and data operations.
– Testing: Test folders show that unit tests are organized per module (app, data, domain).

- Clear labels for each component and module.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer (App)"
        UI_Feature["UI Components & Feature Modules"]:::presentation
        Core["Core Framework & Base Classes"]:::presentation
        DI["Dependency Injection (Dagger)"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Domain["Business Logic, Use Cases & Domain Models"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        Data_Android["Android Data Sources"]:::data
        Data_Cache["Caching Components"]:::data
        Data_Common["Common Data Sources & Repositories"]:::data
        Data_Network["Network Source & API Definitions"]:::data
        Data_Fake["Fake Network Data for Testing"]:::data
    end

    %% Infrastructure & External Services
    subgraph "Infrastructure"
        Build["Build & Dependency Management (Kotlin DSL)"]:::infrastructure
        Spinner["Simple Spinner Adapter"]:::infrastructure
        Dagger["Dagger"]:::external
        Retrofit["Retrofit/OkHttp"]:::external
        SQLDelight["SQLDelight"]:::external
    end

    %% Connections between layers
    UI_Feature -->|"triggers"| Domain
    Domain -->|"calls"| Data_Common
    Data_Common -->|"integratesWith"| Data_Android
    Data_Common -->|"fetchesFrom"| Data_Network
    Data_Common -->|"fetchesFrom"| Data_Cache
    Domain -->|"canUse(forTests)"| Data_Fake

    %% Internal Presentation relationships
    UI_Feature -->|"extends"| Core
    DI -->|"injectsTo"| UI_Feature
    DI -->|"injectsTo"| Domain
    DI -->|"injectsTo"| Data_Common
    DI -->|"uses"| Dagger

    %% Infrastructure interactions
    Build -.->|"supports"| UI_Feature
    Build -.->|"supports"| Domain
    Spinner -.->|"providesUIComponentsTo"| UI_Feature

    %% External service connections
    Data_Network -->|"uses"| Retrofit
    Data_Cache -->|"implements"| SQLDelight

    %% Click Events
    click UI_Feature "https://github.com/popstackhack/mvoterandroid/tree/master/app/src/main/java/com/popstack/mvoter2015/feature"
    click Core "https://github.com/popstackhack/mvoterandroid/tree/master/app/src/main/java/com/popstack/mvoter2015/core"
    click DI "https://github.com/popstackhack/mvoterandroid/tree/master/app/src/main/java/com/popstack/mvoter2015/di"
    click Domain "https://github.com/popstackhack/mvoterandroid/tree/master/domain/src/main/java/com/popstack/mvoter2015/domain"
    click Data_Android "https://github.com/popstackhack/mvoterandroid/tree/master/data/android/src/main/java/com/popstack/mvoter2015/data/android"
    click Data_Cache "https://github.com/popstackhack/mvoterandroid/tree/master/data/cache/src/main/java/com/popstack/mvoter2015/data/cache"
    click Data_Common "https://github.com/popstackhack/mvoterandroid/tree/master/data/common/src/main/java/com/popstack/mvoter2015/data/common"
    click Data_Network "https://github.com/popstackhack/mvoterandroid/tree/master/data/network/src/main/java/com/popstack/mvoter2015/data/network"
    click Data_Fake "https://github.com/popstackhack/mvoterandroid/tree/master/data/fakenetwork/src/main/java/com/fakestack/mvoter2015/data/network"
    click Build "https://github.com/popstackhack/mvoterandroid/tree/master/buildSrc"
    click Spinner "https://github.com/popstackhack/mvoterandroid/tree/master/simplespinneradapter"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef domain fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef infrastructure fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
```
