How bnb-chain/example-hub works
Main Components
• Hub Repository – At the center, represent the repository as the core “Example Hub” that aggregates all examples, tools, and resources.
• Example Categories – Create distinct components for each language or domain:
• Go Examples: Includes the “eip7702-demo” smart contracts and blockchain-related components.
• Python Examples: For instance, the LangChain chatbot and Pancake Swap example, revolving around blockchain integrations and AI functionalities.
• TypeScript Examples: Such as the Eliza Chatbot which uses browser-based or Node.js frameworks.
• Web Resources: Contains the static files (like list.json and template.json), serving as potential front-end resources.
• Tooling and Packages:
• Create-bnb-app: This package under “packages/create-bnb-app” is a CLI tool for scaffolding new projects (invoked via “npx create-bnb-app@latest”).
• Additional Utilities: Under “packages/new-example” and similar that assist developers in setting up new examples.
• CI/CD and Configuration:
• GitHub Actions (under .github/workflows) and other configuration files (such as .editorconfig, commitlintrc.js, etc.) can be represented as supplementary components ensuring quality and automated release processes.
Relationships and Interactions
• Flow of Usage: Show how a developer interacts with the hub by using the create-bnb-app CLI tool, which then pulls one of the many example directories (from Go, Python, or TypeScript) that further integrate with the corresponding language runtimes and blockchain networks (e.g., BNB Chain).
• Dependencies: Illustrate how each example is self-contained yet follows a consistent standards guide set by the hub (e.g., standardized README files, configuration, and testing setups).
• CI/CD Integration: Indicate how commits or pull requests trigger GitHub Actions workflows, ensuring that all examples, packages, and supporting files are validated and released.
Architectural Patterns and Design Principles
• Modular Monorepo Approach: The repository is structured so that each example or toolkit has its own sub-directory and build configuration allowing independent development and testing.
• Separation of Concerns: Different directories (go, python, typescript, web, packages) encapsulate distinct languages and functionalities, ensuring that concerns (like frontend vs. smart contracts) remain isolated.
• Extensibility: The clear “How to Add a New Example” instructions suggest that the system is designed to be extended, so it's important to highlight extensibility points (e.g., new examples and automation for their scaffolding).
Relevant Technologies, Frameworks, and Libraries
• Developer Tools: Mention Node.js (via package.json for create-bnb-app), TypeScript configurations (tsconfig.json), and Python tools (Black, Prettier for formatting).
• Blockchain Integrations: Show that smart contract examples (written in Go) are integral to demonstrating blockchain functionalities on the BNB Chain.
• Web and Chatbot Frameworks: For both Python (LangChain) and TypeScript (Eliza Chatbot), these examples illustrate how application logic integrates with external APIs or interacts with users.
Instructing the Principal Software Engineer – What
• "Example Hub Repository" acts as the central source.
• Nested or adjacent components for Go, Python, TypeScript examples, and the web section.
• A separate component for tooling such as "create-bnb-app" under packages.
• A CI/CD component representing GitHub Actions workflows.
• To indicate how the create-bnb-app tool interacts with and downloads specific examples.
• To show data flow between frontend/back-end elements where applicable, such as user inputs triggering blockchain smart contract functionalities.
• Visual styling:
• Annotations or callouts to emphasize extensibility points (like “New Example Addition” workflow) and to denote automated CI/CD pipelines.