converse_chat_core 1.0.1
converse_chat_core: ^1.0.1 copied to clipboard
Core logic and data models for the Converse Chat SDK.
๐ฃ๏ธ Converse Chat Core #
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
๐ฆ Related Packages #
| 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
