Skip to content

theAlbin/nextpost

Repository files navigation

NextPost

NextPost is a full-featured Android application that demonstrates Modern Android development concepts, including user authentication, remote data retrieval, offline support, and local data persistence.

Codebase Architecture


Features

  • User Authentication: Simple registration and login using local data persistence.
  • Posts Display: Retrieves and displays a list of posts from the JSONPlaceholder API.
  • Search Functionality: Users can search for posts by title or body.
  • Favorites: Users can mark and unmark posts as favorites.
  • Offline Support: The app caches post data locally, allowing users to view posts, access favorites, and search content even without an internet connection.

Screenshots

Posts Screenshot Search Screenshot Favorites Screenshot
Login Screenshot Register Screenshot Settings Screenshot
No Internet Screenshot

Architecture Overview

When the app is first run it will attempt to load a list of posts from a JSONPlaceholder API.

The data layer is implemented as an offline-first source of app data. It is the source of truth for all data in the app.

Each repository has its own models. Repositories are the public API for other layers, they provide the way to access the app data. The repositories typically offer one or more methods for reading and writing data.

Reading Data

Data is exposed as data streams.

Writing Data

To write data, the repository provides suspend functions. It is up to the caller to ensure that their execution is suitably scoped.

Data Sources

A repository may depend on one or more data sources. For example, the OfflineFirstPostsRepository depends on the following data sources:

Name Backed by Purpose
PostsDao Room/SQLite Persistent relational data associated with Posts
UserPreferencesDataSource DataStore Persistent data associated with user preferences, specifically which Posts the user marks as favorite.
AppNetworkDataSource Remote API accessed using ktor Data for posts, provided through JSONPlaceholder REST API endpoints as JSON.

Data Synchronization

Repositories are responsible for reconciling data in local storage with remote sources. Once data is obtained from JSONPlaceholder it is immediately written to local storage. The updated data is emitted from local storage (Room) into the relevant data stream and received by any listening clients.

This approach ensures that the read and write concerns of the app are separate and do not interfere with each other.


Technical Specifications

  • Language: Kotlin
  • UI Toolkit: Jetpack Compose
  • Architecture: MVVM (Model-View-ViewModel)
  • Concurrency: Kotlin Coroutines and Flow
  • Local Cache: Room
  • Local Preferences: DataStore
  • Architecture Practices: Clean Architecture
  • Network Client: Ktor
  • Dependency Injection: Hilt
  • Data Serialization: Kotlinx Serialization

System Requirements

To build and run this project, you need the following:

  • Android Studio: Latest version
  • Java: 21 or later
  • Android API: compileSdk 36, targetSdk 36, and minSdk 29
  • Kotlin: 2.2.10
  • Gradle: 9.0.0

Setup and Build Instructions

To set up and run the project locally, follow these steps:

  1. Clone the repository:

  2. Open in Android Studio:

  3. Sync Gradle

  4. Run the app


Assumptions and Limitations

  • Backend: User authentication is handled locally. No external backend service is used for this feature.
  • Password Storage: For simplicity, user registration data is stored locally. In a production app, a more secure method should be used.
  • UI Design: Simple bare-minimum UI, no fancy design.
  • API: The app relies on the JSONPlaceholder API.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages