How bigcommerce/b2b-buyer-portal works
Main Components
• Frontend Application (Storefront): The core of the project resides in the “apps/storefront” workspace. This is the next‐gen buyer portal built in React and includes the pages (e.g., Login, Dashboard, Invoice, Quote, etc.), a host of React components (buttons, dialogs, forms, etc.), custom hooks, state management (e.g., in the “store” folder), and a variety of utilities.
• Shared Packages & Libraries: Under “packages” you have several workspaces:
– ESLint configurations (eslint-config-b3, etc.).
– Shared TypeScript configurations (“tsconfig”).
– UI Components and Shared Store logic (e.g., packages/ui, packages/store, packages/global-b3).
– Language and utilities packages (packages/lang, packages/utils, packages/hooks).
• CI/CD & Build Infrastructure: The integration files in .circleci, .github/workflows, plus configuration files like “turbo.json”, “vite.config.ts”, and various deployment/config scripts in the “config” and “deployment” directories represent the automated build, deployment, and development infrastructure.
• Documentation & Development Guides: The “docs” folder, README, and RFC materials help document the architectural decisions and provide usage guidelines.
Relationships and Interactions
• The “Storefront” acts as the central user-facing component. It renders pages built with reusable components from the “src/components” directories and organizes application routing using React Router.
• Custom hooks and state management (in “src/hooks” and “src/store”) supply business logic and manage app-level state.
• Shared libraries and utilities (under “packages”) are imported into the storefront and other possible packages to enforce consistency (e.g., TypeScript settings from “packages/tsconfig”, UI components from “packages/ui”, language support from “packages/lang”).
• CI/CD workflows (in .github/workflows and .circleci) connect to deployment pipelines and automated tests, ensuring quality and ease of delivery.
• External integrations are implied: while not explicitly depicted in internal code, the README points to connectivity with BigCommerce SaaS APIs and external storefront settings (e.g., header/footer scripts, cross-origin configuration).
Important Architectural Patterns and Design Principles
• Modularity: The monorepo structure (using Turborepo) clearly separates the frontend application from shared packages and configuration.
• Reusability: Extensive use of reusable components, hooks, and shared modules in “packages” minimizes duplication and eases maintenance.
• Separation of Concerns: Dividing code into pages, components, hooks, store logic, and utilities enables clear responsibilities and easier testing.
• CI/CD Integration: With dedicated directories and configuration files for deployment and testing, the project embraces continuous integration and continuous deployment practices.
– Pages: Represented as submodules (Login, Dashboard, Account Settings, Orders, etc.).
– UI / Component Library: A layer containing common components, form controls, dialogs, and layout components.
– State Management: Include a separate section for the redux-like store slices or context providers (see “src/store”).
– Custom Hooks and Utilities: Represent the logic components that handle business rules, API calls, and formatting (all under “src/hooks” and “src/utils”).
– ESLint Configurations, TSConfig, Language, and other utilities.
• On the far external side, include “External Services” to denote BigCommerce SaaS APIs and the integration points with store endpoints (as described in the README).
– Data flow from user interactions in the browser to the Storefront UI components.
– Dependencies from Storefront to Shared Packages.
– Integration with CI/CD pipelines that trigger builds/tests/deployment.