Skip to content

Enhancing Codebase: A New Modular Structure - #21

Open
Meenapintu wants to merge 4 commits into
bedardjo:masterfrom
yehigo:master
Open

Enhancing Codebase: A New Modular Structure#21
Meenapintu wants to merge 4 commits into
bedardjo:masterfrom
yehigo:master

Conversation

@Meenapintu

@Meenapintu Meenapintu commented Jul 4, 2025

Copy link
Copy Markdown

I've significantly improved our project's architecture by modularizing the codebase into two distinct packages. This separation allows for clearer responsibilities and greater flexibility.

What's Changed?

  1. playing_cards_lib (Server-side): This new package (https://github.com/yehigo/playing_cards_lib) now exclusively houses the core logic and functionality of our playing card system. Importantly, within playing_cards_lib, the playing_cards_lib, Suit, and CardValue models are now SerializableModel instances. This means they can be easily created from JSON and serialized to JSON, enhancing data exchange capabilities.

  2. playing_cards (Client-side): The original playing_cards package (https://github.com/bedardjo/playing_cards) is now dedicated solely to the user interface and experience.


Why the Split?

The primary driver for this refactor was to eliminate an unnecessary Flutter SDK dependency from our backend. Previously, including the playing_cards package directly in the server-side code meant pulling in Flutter's SDK, which significantly increased our backend bundle size. By isolating the core logic into playing_cards_lib, I've achieved a smaller, more efficient backend and improved overall maintainability.


The Benefits

This modular approach brings several key advantages:

  • Enhanced Modularity: A clearer separation of concerns makes the codebase easier to understand, navigate, and manage.
  • Improved Scalability: Each part can now be developed, tested, and scaled independently.
  • Increased Reusability: The playing_cards_lib can be easily integrated into other projects or contexts without the overhead of UI dependencies, and its serialization capabilities make it ideal for various data handling scenarios.

Backward Compatibility: Will This Break Existing Integrations?

No, this change will not break existing codebases for current users.

I understand the importance of a seamless transition. For this reason, I've exported playing_cards_lib within lib/playing_cards.dart of the playing_cards package. This means that any existing projects that import playing_cards will continue to function without disruption. While the best practice is to directly import playing_cards_lib for core functionality, I've prioritized backward compatibility for this update. In future versions, we might introduce deprecation warnings to guide users toward directly importing playing_cards_lib.

@Meenapintu
Meenapintu marked this pull request as ready for review July 4, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant