Skip to content

shuvojoseph/BlogPostAndroid

Repository files navigation

BlogPost Android App

An Android application that allows users to register, log in, and manage blogs with co-owner functionality. Built using Kotlin and MVVM architecture, this project demonstrates clean architecture, REST API integration, JWT authentication, and unit testing.

The Android app mirrors the functionality of the iOS version while following Android best practices such as ViewModels, LiveData, Repository pattern, and Retrofit networking.


Features

Dashboard

  • Displays a list of all blogs.
  • Shows Login and Register options for unauthenticated users.
  • Logged-in users can manage blogs they own or co-own.

Authentication

  • Users can register and log in.
  • JWT authentication is used for all protected endpoints.
  • Access tokens are automatically attached to API requests.

Blog Management

Authenticated users can:

  • Create new blogs
  • Edit blogs they own or co-own
  • Delete blogs they own or co-own
  • Add co-owners from the user list

Co-owners have the same editing privileges as the blog creator.


Architecture

The project follows the MVVM architecture to ensure separation of concerns.

Layers

UI Layer

  • Activities
  • RecyclerView Adapters

Presentation Layer

  • ViewModels
  • LiveData state management

Data Layer

  • Repository pattern
  • Retrofit API services
  • Network models

This architecture ensures:

  • Clean code
  • Easier maintenance
  • Better testability

Networking

Networking is implemented using Retrofit and OkHttp.

Features:

  • Retrofit for REST API communication
  • Gson for JSON serialization/deserialization
  • OkHttp logging interceptor for debugging
  • Repository pattern for network abstraction

All API calls are handled through a centralized BlogRepository.


Authentication

  • JWT token-based authentication
  • Access token is attached automatically using OkHttp Interceptor
  • Token is persisted locally for authenticated sessions

Unit Testing

Unit tests are implemented to verify ViewModel and Repository logic.

Test Coverage

The following unit tests are included:

  • BlogRepositoryTest
  • LoginViewModelTest
  • RegisterViewModelTest
  • AddEditBlogViewModelTest
  • DashboardViewModelTest

Testing tools used:

  • JUnit
  • Mockito
  • Coroutines Test
  • Robolectric
  • AndroidX Test Core

These tests validate:

  • API interaction logic
  • ViewModel business logic
  • Coroutine execution
  • LiveData updates

App Screenshots

Login Dashboard
Login Dashboard
Register Add / Edit Blog
Register AddEditBlog

Tech Stack

Language

  • Kotlin

Architecture

  • MVVM (Model View ViewModel)
  • Repository Pattern

Networking

  • Retrofit
  • OkHttp
  • Gson Converter

UI

  • RecyclerView
  • Material Components
  • ConstraintLayout
  • CardView

Concurrency

  • Kotlin Coroutines

Lifecycle

  • ViewModel
  • LiveData

Testing

  • JUnit
  • Mockito
  • Robolectric
  • AndroidX Test

Dependencies

Key dependencies used in this project:

Core Android

  • androidx.core.ktx
  • androidx.appcompat
  • androidx.constraintlayout
  • androidx.lifecycle
  • androidx.recyclerview
  • material components

Networking

Retrofit 2.9.0
OkHttp Logging Interceptor
Gson Converter

Concurrency

Kotlin Coroutines

UI

RecyclerView
CardView
Material Components
ConstraintLayout

Testing

JUnit
Mockito
Mockito-Kotlin
Coroutines Test
Robolectric
AndroidX Test

Project Structure

BlogPost_AndroidApp
│
├── data
│   ├── model
│   │   ├── Blog
│   │   ├── User
│   │   └── Owner
│   │
│   ├── network
│   │   └── RetrofitClient
│   │
│   └── repository
│       └── BlogRepository
│
├── ui
│   ├── auth
│   ├── dashboard
│   └── blog
│       └── AddEditBlogActivity
│
├── utils
│   └── TokenManager
│   └── SessionManager
│
└── README.md

Getting Started

1 Clone the repository

git clone https://github.com/shuvojoseph/BlogPostAndroid.git

2 Open the project

Open the project using Android Studio.

3 Build the project

Allow Gradle to download dependencies.

4 Run the application

Run the project on:

  • Android Emulator
  • Physical Android device

Backend API

The backend APIs are hosted on Render Cloud and provide:

  • Blog CRUD operations
  • User registration
  • User authentication
  • Co-owner management

Example endpoint:

https://blogpostspringboot.onrender.com/api/blogs

Backend Notes

The backend service may go inactive after ~45 minutes of inactivity.

If this happens:

  1. Open the following link in a browser to wake the server:
https://blogpostspringboot.onrender.com/api/blogs
  1. Wait 1–2 minutes for the server to start.

  2. After activation, the mobile app will function normally.


Learning Goals Demonstrated

This project demonstrates understanding of:

  • Android MVVM Architecture
  • Clean code structure
  • REST API integration
  • Retrofit networking
  • JWT authentication
  • Dependency separation
  • RecyclerView UI design
  • Unit testing in Android
  • Coroutine-based asynchronous programming

Author

Shuvo Joseph

GitHub https://github.com/shuvojoseph


About

BlogPostAndroid Kotlin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages