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
81
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