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

Reorganized Langchain, Actions, and Tools into Protocol-Specific Directories #179

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

biccsdev
Copy link
Contributor

Currently, /langchain, /actions and /tools folders have grown exponentially due to the high demand of this repo, making it increasingly difficult to maintain and navigate. This PR implements a comprehensive reorganization of the codebase by splitting protocol-specific code into dedicated directories.

Problem:
The monolithic structure of /langchain, /actions and /tools folders have become a maintenance burden:

  • The files have exceeded 2K lines of code
  • Finding specific protocol implementations requires extensive scrolling and searching
  • Adding new protocols or modifying existing ones risks creating merge conflicts
  • Code reuse and testing are hindered by the tightly coupled structure

Solution:
This PR reorganizes three key areas of the codebase using a consistent pattern of one directory per protocol, with each protocol's implementation living in its own index.ts file:

  1. Langchain Actions (/src/langchain/):
    New structure example:
    src/langchain/
    ├── 3land/
    │ ├── index.ts
    ├── orca/
    │ ├── index.ts
    ├── pyth/
    │ ├── index.ts
    .
    .
    .

This organization provides several advantages:

  • Each protocol's code is self-contained and focused
  • The index.ts pattern makes imports clean and consistent
  • Future protocol additions only require creating a new directory
  • Easier to implement protocol-specific utilities and helpers
  • Clear separation of concerns while maintaining easy discoverability
  1. Actions (/src/actions/):
    We've preserved the existing one-file-per-action pattern while organizing them into protocol-specific directories:
    src/actions/
    ├── bonfida/
    │ ├── getPrimaryDomain.ts
    │ ├── registerDomain.ts
    │ └── resolveSolDomain.ts
    ├── metaplex/
    │ ├── deploycollection.ts
    │ ├── mintNFT.ts
    │ └── deploytoken.ts
    ├── gibwork/
    │ ├── createGibWorkTask.ts

  2. Tools (/src/tools/):
    Similarly, we've maintained the granular file structure for tools while grouping them by protocol.

The different organizational patterns reflect the distinct purposes of each directory:

  • Langchain actions benefit from keeping protocol implementations together due to their tight integration with the framework
  • Individual actions and tools maintain their separation for better reusability and testing isolation

Benefits:

  • Improved code navigation and maintainability
  • Reduced merge conflicts through smaller, focused files
  • Better separation of concerns between different protocols
  • Easier onboarding for new team members
  • Consistent protocol-based organization while respecting existing architectural patterns

No breaking changes have been introduced - this is purely a structural reorganization that maintains all existing functionality while improving code organization.

Please review the directory structure changes and let me know if you'd like any adjustments to the organization pattern.

Let me know if you need anything else :D.
This pull request was created for https://app.gib.work/bounties/0b78790e-6d48-4ec3-b67f-46c96dac6b7d in an attempt to solve a bounty #173 . Payment for the bounty is immediately sent to the contributor after merge.

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