How 1b4dev/bear1x works
Main Components
• Frontend Client: This is where the requests originate (web browsers or mobile apps). Emphasize that the API calls from the frontend must be prefixed with “/bff/” to ensure routing through Bear1x.
• Bear1x Middleware:
• Core File: BFF.php (residing inside the “middleware” directory) which encapsulates the logic for token extraction, configuration (API endpoint or host), error handling, and proxying the requests.
• Routing Logic: Visible via index.php that routes “/bff” paths to the middleware.
• Backend Server: The destination for forwarded requests and token validation. In Direct Integration, the backend is essentially the same set of files where Bear1x is integrated. In Middleware Mode, it’s an external service identified by a configured URL.
Relationships and Data Flow
• Inside the middleware, show a sub-component labeled “Token Extraction & Validation” that processes the cookie.
Architectural Patterns and Design Principles
• Proxy pattern inherent in Bear1x—it intercepts and forwards requests transparently.
• Non-intrusiveness: the middleware does not require changes in the backend logic.
• That the system is built with OOP PHP principles, which could be annotated near the BFF.php component.
• Error flow (e.g., when an exception is caught during token extraction or proxy operation, an error response is generated).
Relevant Technologies and Frameworks
• PHP is the core language.
• Role of the .htaccess file for URL rewriting and request routing.
• That the project eliminates cUrl dependency, which simplifies HTTP operations.