Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yorkie Schema Validation and Version Management #971

Open
hackerwins opened this issue Aug 20, 2024 · 1 comment
Open

Yorkie Schema Validation and Version Management #971

hackerwins opened this issue Aug 20, 2024 · 1 comment
Labels
enhancement 🌟 New feature or request hard 🧑‍🔬 Difficult to deal with or require research

Comments

@hackerwins
Copy link
Member

hackerwins commented Aug 20, 2024

Description:

1. Overview

Yorkie is a document store for real-time collaboration, allowing users to express models in a JSON-like format. This issue defines a schema validation and version management system for consistent document management.

2. Necessity

  • Consistently manage JSON-like model representations with high flexibility
  • Restrict document editing within specific schema boundaries
  • Maintain stable document structures through schema version management

3. Schema Definition and Management

3.1 Schema Creation

Liveblocks Schema Validation

3.2 Version Management

  • Manage schemas immutably
  • Store updates as new versions (v1, v2, v3, ...)

3.3 Schema Usage

  • Ability to specify a particular schema when creating documents in the SDK
const doc = new yorkie.Document('doc1');
await client.attach(doc, {
  schema: `doc-schema:v1` // optional
});

4. Implementation Devices

4.1 Schema Validation Device (A)

  • Location: Dashboard or server
  • Function: Validate user-defined schemas
  • Process: Tokenization → Syntax Analysis → Semantic Analysis
  • Current Status: Syntax analysis implemented (yorkie-schema repository)

4.2 Document Change Validation Device (B)

  • Location: Hybrid approach (SDK + Server)
  • Function: Validate Document changes
  • Implementation: Use Ruleset based on AST generated by Device A
  • Current Status: We need to implement a prototype

5. System Architecture

graph TB
    User[User] --> Dashboard
    Dashboard --> |Schema Definition| SchemaValidationA[Schema Validation Device A]
    SchemaValidationA --> |Validated Schema| Server
    User --> |Document Editing| SDK
    SDK --> |Basic Validation| ChangeValidationB[Change Validation Device B]
    ChangeValidationB --> |Change Request| Server
    Server --> |Final Validation| FinalValidation[Final Validation]
    FinalValidation --> |Result| SDK
    Server --> |Store Schema/Document| Database[(Database)]
Loading

6. Key Considerations and Improvements

6.1 Performance Optimization

  • Performance testing for large documents and complex schemas
  • Optimize validation speed in real-time collaboration environments

6.2 Offline Support

  • Include basic validation logic in the SDK
  • Develop temporary validation and synchronization strategies for offline states

6.3 Migration Strategy

  • Define migration process for existing documents when schema versions change
  • Establish backward compatibility maintenance plans

6.4 Custom Conflict Resolution

  • Implement handling logic for validation failures in the SDK
  • Develop conflict resolution strategies for synchronization processes

Why:

This issue aims to enhance Yorkie's document management capabilities and provide a more stable real-time collaboration environment. Continuous improvement will be necessary during the implementation process, considering performance, user experience, and the characteristics of real-time collaboration.

@hackerwins hackerwins added enhancement 🌟 New feature or request hard 🧑‍🔬 Difficult to deal with or require research labels Aug 20, 2024
@blurfx
Copy link
Member

blurfx commented Sep 9, 2024

I'm interested in this topic, can I get involved?

@hackerwins hackerwins changed the title Versioned Document Schema & Validation Yorkie Schema Validation and Version Management Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request hard 🧑‍🔬 Difficult to deal with or require research
Projects
Status: Backlog
Development

No branches or pull requests

2 participants