How popstackhack/mvoterandroid works
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.