converse_chat_core 1.0.1 copy "converse_chat_core: ^1.0.1" to clipboard
converse_chat_core: ^1.0.1 copied to clipboard

Core logic and data models for the Converse Chat SDK.

๐Ÿ—ฃ๏ธ Converse Chat Core #

pub package GitHub Repo License: MIT

Converse Chat Core provides the domain layer, entities, and clean architecture foundation for the Converse Chat SDK.
It is platform-agnostic and can be extended or integrated with any backend (Firebase, Supabase, custom servers, etc.).


๐Ÿš€ Overview #

Converse Chat Core defines the fundamental data models, use cases, and plugin architecture that power all other Converse packages:

App / SDK
   โ†“
Converse Chat SDK
   โ†“
Converse Chat Core
   โ†“
Adapters (Firebase, REST, etc.)

It provides:

  • ๐Ÿงฑ Entities & Value Objects โ€” User, Message, Chat, Attachment
  • โš™๏ธ Use Cases โ€” SendMessage, FetchMessages, MarkRead
  • ๐Ÿ”Œ Plugin System โ€” Extend chat behavior dynamically
  • ๐Ÿงฉ Repository Interfaces โ€” For persistence & network integration
  • ๐Ÿ” Error Handling โ€” Custom error and failure hierarchy

๐Ÿง  Architecture #

This package follows Clean Architecture principles:

+------------------------+
|    Presentation Layer  |  โ† (UI / SDK / Flutter widgets)
+------------------------+
|     Domain Layer       |  โ† converse_chat_core
|  (Entities, UseCases)  |
+------------------------+
|  Data Layer / Adapters |  โ† (Firebase, REST, etc.)
+------------------------+

You can think of converse_chat_core as the heart of your chat system โ€”
independent of any backend, UI, or storage mechanism.


๐Ÿงฉ Key Features #

โœ… Pure Dart โ€” works with any backend
โœ… Extendable plugin system
โœ… Typed entities with strong immutability
โœ… Error-safe functional approach using fpdart
โœ… Lightweight and testable


๐Ÿงฐ Installation #

Add to your pubspec.yaml:

dependencies:
  converse_chat_core: ^1.0.0

Then import it:

import 'package:converse_chat_core/converse_chat_core.dart';

๐Ÿ’ฌ Example Usage #

import 'package:converse_chat_core/converse_chat_core.dart';

void main() {
  final user = User(id: UserId('alice'), name: 'Alice');
  final chat = Chat(id: ChatId('chat_1'), participants: [user]);

  final message = Message.create(
    id: MessageId.unique(),
    userId: user.id,
    text: 'Hey, this is a test!',
  );

  print('Message from ${user.name}: ${message.text}');
}

โœ… Works fully offline
โœ… Easily extendable for Firebase or custom backends


โš™๏ธ Extending with Plugins #

You can register plugins to modify message flow dynamically.

final registry = PluginRegistry();
registry.register(MyEncryptionPlugin());

final processed = await registry.runOnSend(message);

See plugin_registry.dart for details.


๐Ÿงฑ Folder Structure #

lib/
โ”œโ”€ converse_chat_core.dart       # โœ… Public entrypoint (exports everything below)
โ””โ”€ src/
    โ”œโ”€ domain/
    โ”‚   โ”œโ”€ entities/
    โ”‚   โ”‚   โ”œโ”€ message.dart           # Defines Message entity (id, text, senderId, timestamp, status)
    โ”‚   โ”‚   โ”œโ”€ chat.dart              # Defines Chat entity (id, participants, metadata)
    โ”‚   โ”‚   โ”œโ”€ user.dart              # Defines User entity (id, name, avatar, presence)
    โ”‚   โ”‚   โ”œโ”€ attachment.dart        # Defines Attachment entity (type, url, mime)
    โ”‚   โ”‚   โ””โ”€ message_status.dart    # Enum for sent, delivered, read, failed
    โ”‚   โ”‚
    โ”‚   โ””โ”€ value_objects/
    โ”‚       โ”œโ”€ user_id.dart           # Value object for unique user identifiers
    โ”‚       โ”œโ”€ message_id.dart        # Value object for message IDs
    โ”‚       โ”œโ”€ chat_id.dart           # Value object for chat IDs
    โ”‚       โ””โ”€ timestamp.dart         # Immutable value object for time metadata
    โ”‚
    โ”œโ”€ usecases/
    โ”‚   โ”œโ”€ send_message.dart          # Handles message send logic
    โ”‚   โ”œโ”€ fetch_messages.dart        # Retrieves chat history
    โ”‚   โ””โ”€ mark_read.dart             # Marks message as read
    โ”‚
    โ”œโ”€ ports/
    โ”‚   โ”œโ”€ i_chat_repository.dart     # Abstract repository for chat operations
    โ”‚   โ”œโ”€ i_user_repository.dart     # Abstract user repository
    โ”‚   โ”œโ”€ i_attachment_repository.dart # For media uploads/downloads
    โ”‚   โ””โ”€ i_presence_repository.dart # For tracking online/offline state
    โ”‚
    โ”œโ”€ services/
    โ”‚   โ”œโ”€ message_pipeline.dart      # Message preprocessing & plugin chain
    โ”‚   โ”œโ”€ encryption_strategy.dart   # Defines encrypt/decrypt strategy interface
    โ”‚   โ””โ”€ ...                        # (Future) notification or caching services
    โ”‚
    โ”œโ”€ plugins/
    โ”‚   โ”œโ”€ chat_plugin.dart           # Abstract class for plugins (onSend/onReceive)
    โ”‚   โ””โ”€ plugin_registry.dart       # Registers and runs plugins sequentially
    โ”‚
    โ”œโ”€ controller/
    โ”‚   โ””โ”€ chat_controller.dart       # Coordinates between use cases and SDK layer
    โ”‚
    โ””โ”€ errors/
        โ”œโ”€ core_errors.dart           # Common exceptions (e.g., NetworkError, InvalidEntity)
        โ”œโ”€ chat_failure.dart          # Failure models for domain layer (used with fpdart Either)
        โ””โ”€ error_mapper.dart          # Maps exceptions into Failures or Error types


๐Ÿงช Example Project #

A minimal runnable example is available in the example/ directory:

dart run example/main.dart

Package Description
converse_chat_sdk High-level SDK with Firebase and adapters
converse_chat_adapters Infrastructure integrations (Firebase, REST, etc.)

๐Ÿง  Topics #

firebase chat, chat, messaging, sdk, firebase, realtime, flutter, core, clean-architecture


๐Ÿชช License #

This project is licensed under the MIT License.


๐Ÿ‘จโ€๐Ÿ’ป Author #

Rajendra Bisht
GitHub @rbishtdev

0
likes
150
points
110
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

Core logic and data models for the Converse Chat SDK.

Homepage
Repository (GitHub)
View/report issues

Topics

#chat #sdk #flutter #core #firebase-chat

Documentation

API reference

License

MIT (license)

Dependencies

crypto, fpdart, uuid

More

Packages that depend on converse_chat_core