Skip to main content

Overview

mezon-sdk is a powerful TypeScript SDK providing a robust client-side interface for interacting with the Mezon platform, enabling real-time communication and efficient data management for applications and bots.

Why mezon-sdk?

This project simplifies Mezon applications and bots development by providing a comprehensive and well-structured TypeScript library. The core features include:

  • ๐ŸŸข Real-time Communication: Leverages WebSockets for instant, bidirectional communication with the Mezon server, ensuring low-latency interactions.
  • ๐Ÿ”ต Comprehensive API: Offers a complete set of methods for interacting with all aspects of the Mezon service, including authentication, channel management, and message handling.
  • ๐ŸŸก Type Safety: Built with TypeScript and enforced strict type checking, minimizing runtime errors and improving code maintainability.
  • ๐Ÿ”ด Efficient Message Handling: Employs asynchronous queues and caching mechanisms to optimize performance, even under high message volume.
  • ๐ŸŸฃ Modular Design: Well-structured and modular architecture, featuring distinct managers for sessions, sockets, channels, and events, promotes easy extension, maintenance, and integration into existing projects.
  • ๐ŸŸ  Robust Error Handling: Includes comprehensive error handling throughout the codebase, ensuring application stability and a better user experience.
  • โš™๏ธ Data Persistence: Integrates with SQLite for local message storage, allowing for offline access and improved performance.

Featuresโ€‹

ComponentDetails
โš™๏ธArchitecture
  • Modular, with components like MezonClient, SessionManager, SocketManager, ChannelManager, EventManager.
  • Event-driven for real-time updates.
  • Utilizes an API client for HTTP requests and a WebSocket adapter for real-time communication.
๐Ÿ”ฉCode Quality
  • Uses TypeScript for type safety.
  • Employs ESLint and Prettier for linting and formatting.
  • Jest and Jest-Cucumber for testing.
๐Ÿ“„Documentation
  • Comprehensive (This document).
  • Generated Protocol Buffer definitions for API and real-time messages.
๐Ÿ”ŒIntegrations
  • Uses ws for WebSocket communication.
  • better-sqlite3 for local SQLite database interaction (e.g., MessageDatabase.ts).
  • Protocol Buffers for efficient data serialization (realtime.ts, struct.ts).
  • Base64 for data encoding.
๐ŸงฉModularity
  • Organized into managers, structures, API layers, and utility functions.
  • Clear separation of concerns (e.g., API interaction, socket management, data structures).
๐ŸงชTesting
  • Uses Jest and Jest-Cucumber.
  • Configuration in jest.config.js.
โšก๏ธPerformance
  • AsyncThrottleQueue for rate-limiting and managing asynchronous tasks.
  • CacheManager for efficient data retrieval.
  • SQLite for optimized local data access.
๐Ÿ›ก๏ธSecurity
  • Session management with JWTs (session.ts).
  • HTTPS and WSS by default.
  • Base64 encoding for certain data transformations.
๐Ÿ“ฆDependencies
  • Core: ws, better-sqlite3, js-base64.
  • Development: TypeScript, ESLint, Prettier, Jest, Nodemon, ts-node.
๐Ÿš€Scalability
  • Client-side scalability aided by efficient data management and asynchronous operations.
  • Server-side scalability depends on Mezon platform architecture. SQLite usage is for local client caching, not server-side primary storage.

Note: This table is based on information from the project structure and file summaries.


Project Structureโ€‹

โ””โ”€โ”€ mezon-sdk/
โ”œโ”€โ”€ jest.config.js
โ”œโ”€โ”€ nodemon.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src
โ”‚ โ”œโ”€โ”€ api
โ”‚ โ”‚ โ””โ”€โ”€ api.ts
โ”‚ โ”œโ”€โ”€ api.ts
โ”‚ โ”œโ”€โ”€ client.ts
โ”‚ โ”œโ”€โ”€ constants
โ”‚ โ”‚ โ”œโ”€โ”€ enum.ts
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ google
โ”‚ โ”‚ โ””โ”€โ”€ protobuf
โ”‚ โ”‚ โ”œโ”€โ”€ struct.ts
โ”‚ โ”‚ โ”œโ”€โ”€ timestamp.ts
โ”‚ โ”‚ โ””โ”€โ”€ wrappers.ts
โ”‚ โ”œโ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ interfaces
โ”‚ โ”‚ โ”œโ”€โ”€ api.ts
โ”‚ โ”‚ โ”œโ”€โ”€ client.ts
โ”‚ โ”‚ โ”œโ”€โ”€ index.ts
โ”‚ โ”‚ โ””โ”€โ”€ socket.ts
โ”‚ โ”œโ”€โ”€ message-socket-events
โ”‚ โ”‚ โ”œโ”€โ”€ base_event.ts
โ”‚ โ”‚ โ”œโ”€โ”€ index.ts
โ”‚ โ”‚ โ”œโ”€โ”€ user_channel_added.ts
โ”‚ โ”‚ โ””โ”€โ”€ user_channel_updated.ts
โ”‚ โ”œโ”€โ”€ mezon-client
โ”‚ โ”‚ โ”œโ”€โ”€ client
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ MezonClient.ts
โ”‚ โ”‚ โ”œโ”€โ”€ manager
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ channel_manager.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ event_manager.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ session_manager.ts
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ socket_manager.ts
โ”‚ โ”‚ โ”œโ”€โ”€ structures
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Clan.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Message.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ TextChannel.ts
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ User.ts
โ”‚ โ”‚ โ””โ”€โ”€ utils
โ”‚ โ”‚ โ”œโ”€โ”€ AsyncThrottleQueue.ts
โ”‚ โ”‚ โ”œโ”€โ”€ CacheManager.ts
โ”‚ โ”‚ โ””โ”€โ”€ Collection.ts
โ”‚ โ”œโ”€โ”€ rtapi
โ”‚ โ”‚ โ””โ”€โ”€ realtime.ts
โ”‚ โ”œโ”€โ”€ session.ts
โ”‚ โ”œโ”€โ”€ socket.ts
โ”‚ โ”œโ”€โ”€ sqlite
โ”‚ โ”‚ โ””โ”€โ”€ MessageDatabase.ts
โ”‚ โ”œโ”€โ”€ utils
โ”‚ โ”‚ โ”œโ”€โ”€ format_message_input.ts
โ”‚ โ”‚ โ”œโ”€โ”€ generate_reply_message.ts
โ”‚ โ”‚ โ”œโ”€โ”€ helper.ts
โ”‚ โ”‚ โ””โ”€โ”€ stack.ts
โ”‚ โ”œโ”€โ”€ utils.ts
โ”‚ โ”œโ”€โ”€ web_socket_adapter.ts
โ”‚ โ””โ”€โ”€ web_socket_adapter_pb.ts
โ”œโ”€โ”€ tsconfig.esm.json
โ””โ”€โ”€ tsconfig.json