Skip to content

About

Pubnub Sample Chat architecture

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SampleChat

A marketplace-style messaging app for Android, built with Jetpack Compose and PubNub Chat SDK. Demonstrates real-time chat features like typing indicators, read receipts, and live inbox updates in a clean architecture codebase.

Features

  • Real-time messaging with message history
  • Typing indicators and read receipts
  • Conversation inbox with unread counts and live updates
  • Product context per conversation (title, price)
  • Date separators and message status tracking
  • Channel invites with automatic subscription

Tech Stack

Layer Technology
UI Jetpack Compose, Material 3
Real-time PubNub Chat SDK
Architecture MVVM + Clean Architecture
DI Hilt
Local storage Room, DataStore
Networking Retrofit, OkHttp, Moshi
Language Kotlin 2.0

Project Structure

app/src/main/java/dev/guillem/samplechat/
├── data/           # Repositories, Room DB, PubNub data source
├── di/             # Hilt modules
├── domain/         # Use cases, models, repository interfaces
├── ui/             # Compose screens, components, navigation, theme
└── util/           # Constants, date formatting, keys (gitignored)

Getting Started

Prerequisites

  • Android Studio Ladybug or later
  • JDK 11+
  • A PubNub account (free tier available)

PubNub Keyset Setup

Create an app and keyset in the PubNub Admin Portal with the following features enabled:

Feature Setting
Message Persistence Enabled, 7+ days retention
App Context Enabled
Presence Enabled (optional)

Build and Run

  1. Clone the repository:

    git clone https://github.com/GuillemRoca/sample-chat.git
    cd sample-chat
  2. Create the keys file at app/src/main/java/dev/guillem/samplechat/util/Keys.kt:

    package dev.guillem.samplechat.util
    
    object Keys {
        const val PUBNUB_PUBLISH_KEY = "pub-c-your-publish-key"
        const val PUBNUB_SUBSCRIBE_KEY = "sub-c-your-subscribe-key"
    }
  3. Open the project in Android Studio and run it, or build from the command line:

    ./gradlew installDebug

The app requires API 24+ (Android 7.0) and targets API 36.

Architecture

The project follows Clean Architecture with three layers:

  • UI -- Compose screens and ViewModels that observe state
  • Domain -- Use cases and repository interfaces (pure Kotlin, no Android dependencies)
  • Data -- Repository implementations, Room database, and PubNub data source

See ARCHITECTURE.md for a detailed breakdown.

License

This project is provided as a sample/demo. See the repository for license details.

About

Pubnub Sample Chat architecture

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages