srcbookdev / srcbook

TypeScript-centric app development platform
https://srcbook.com
Apache License 2.0
2.6k stars 101 forks source link

Extract encoding / decoding of Srcbooks into its own package, introduce versioning #208

Open nichochar opened 3 months ago

nichochar commented 3 months ago

Refactor Srcbook Serialization: Extract and Version Encoding/Decoding Logic

Current State

Problem

Proposed Solution

  1. Extract encoding/decoding logic into a separate package:

    • Suggested package name: @srcbook/serde
    • This package will encapsulate all serialization and deserialization functionality.
  2. Implement versioning for the encoding algorithm:

    • Introduce a version identifier in the serialized output.
    • Develop a mechanism to detect and handle different versions during deserialization.

Benefits

  1. Improved Portability:

    • Enables Srcbook decoding in a wider range of environments.
    • Facilitates easier integration with third-party tools and services.
  2. Enhanced Maintainability:

    • Centralizes serialization logic, reducing code duplication.
    • Simplifies future updates and bug fixes.
  3. Robust Compatibility Management:

    • Allows for graceful handling of different encoding versions.
    • Enables the introduction of new concepts without breaking existing implementations.
    • Provides a foundation for potential data migrations in the future.

Next Steps

Sanjoy-droid commented 1 month ago

@nichochar can you please provide details about the exact components having Encoding and decoding operations in both client and server?

or any beginner friendly approach to fix this issue?

Refactor Srcbook Serialization: Extract and Version Encoding/Decoding Logic

Current State

  • Encoding and decoding operations are currently implemented in both client and server components.

Problem

  • Limited portability of Srcbook decoding capabilities.
  • Lack of versioning for the encoding algorithm poses potential compatibility issues.

Proposed Solution

  1. Extract encoding/decoding logic into a separate package:

    • Suggested package name: @srcbook/serde
    • This package will encapsulate all serialization and deserialization functionality.
  2. Implement versioning for the encoding algorithm:

    • Introduce a version identifier in the serialized output.
    • Develop a mechanism to detect and handle different versions during deserialization.

Benefits

  1. Improved Portability:

    • Enables Srcbook decoding in a wider range of environments.
    • Facilitates easier integration with third-party tools and services.
  2. Enhanced Maintainability:

    • Centralizes serialization logic, reducing code duplication.
    • Simplifies future updates and bug fixes.
  3. Robust Compatibility Management:

    • Allows for graceful handling of different encoding versions.
    • Enables the introduction of new concepts without breaking existing implementations.
    • Provides a foundation for potential data migrations in the future.

Next Steps

  • Design the API for the @srcbook/serde package.
  • Implement versioning mechanism and initial compatibility checks.
  • Refactor existing code to utilize the new package.
  • Update documentation to reflect the changes in serialization handling.